/*

                                   _JNJ`                        
                               .JNMH`                           
                              JMMF`       `;.                   
                            .NMM)          `MN.                 
                            MMM)            (MML                
                           (MMM`             MMML               
                     M  I  D  N  I  G  H  T    C  o  D  E       
                           (NMMF             MHNH               
                            NMML            .MMM                
                             NMML          .NMH                 
                              4MMNL       .#F                   
                               `4HNNL_   `                      
                                   `"""`                        

                          Copyright (C) 2004-2006
       "Ian (Larry) Latter" <ian dot latter at midnightcode dot org>

    Midnight Code is a registered trademark of Ian Latter.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, and mirrored at the Midnight Code web
    site; as at version 2 of the License only.
  
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
  
    You should have received a copy of the GNU General Public License
    (version 2) along with this program; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA, or see http://midnightcode.org/gplv2.txt

*/


/* midnightcode-disk.h :: Midnight Code low-level disk library		*/


#ifndef __MIDNIGHTCODE_DISK_H
#define __MIDNIGHTCODE_DISK_H 1


#define MIDNIGHTCODE_DISK_STRUCTURE "disk"

enum midnightcode_disk_type_t
{
  MIDNIGHTCODE_DISK_TYPE_DISK = 0,
  MIDNIGHTCODE_DISK_TYPE_TAPE = 1,
  MIDNIGHTCODE_DISK_TYPE_PRINTER = 2,
  MIDNIGHTCODE_DISK_TYPE_PROCESSOR = 3,
  MIDNIGHTCODE_DISK_TYPE_WORM = 4,
  MIDNIGHTCODE_DISK_TYPE_CDDVD = 5,
  MIDNIGHTCODE_DISK_TYPE_ALL = 255
};

enum midnightcode_disk_tray_t
{
  MIDNIGHTCODE_DISK_TRAY_UNKNOWN = 0,
  MIDNIGHTCODE_DISK_TRAY_OPEN = 1,
  MIDNIGHTCODE_DISK_TRAY_CLOSED = 2
};

enum midnightcode_disk_media_t
{
  MIDNIGHTCODE_DISK_MEDIA_UNKNOWN = 0,
  MIDNIGHTCODE_DISK_MEDIA_AUDIO = 1,
  MIDNIGHTCODE_DISK_MEDIA_DATA1 = 2,
  MIDNIGHTCODE_DISK_MEDIA_DATA2 = 3,
  MIDNIGHTCODE_DISK_MEDIA_DATA3 = 4,
  MIDNIGHTCODE_DISK_MEDIA_DATA4 = 5,
  MIDNIGHTCODE_DISK_MEDIA_MIXED = 6
};

enum midnightcode_disk_emulation_t
{
  MIDNIGHTCODE_DISK_EMULATION_UNKNOWN = 0,
  MIDNIGHTCODE_DISK_EMULATION_ENABLED = 1,
  MIDNIGHTCODE_DISK_EMULATION_DISABLED = 2
};

enum midnightcode_disk_bus_t
{
  MIDNIGHTCODE_DISK_BUS_UNKNOWN = 0,
  MIDNIGHTCODE_DISK_BUS_IDE = 1,
  MIDNIGHTCODE_DISK_BUS_SCSI = 2,
  MIDNIGHTCODE_DISK_BUS_USB = 3
};

struct midnightcode_disk_element_t
{
  int is_enabled;
  char device[64];
  char vendor_id[128];
  char product_id[128];
  char version[128];
  char serial_no[128];
  int device_type;
  char device_type_s[128];
  int bus_type;
  char bus_type_s[128];
  int scsi_channel;
  int scsi_lun;
  int scsi_id;
  int scsi_emulation;
  long double capacity_blocks;
  long double capacity_bytes;
  long double capacity_value;
  char capacity_units[64];
  char capacity_s[128];
  int dma;
  int cd_tray_state;
  int cd_media_available;
  char cd_media_label[64];
  int cd_media_type;
  int lvm_pv_created;
  int lvm_pe_size;
  int lvm_vg_member;
  char lvm_vg_label[128];
  midnightcode_list_entry(midnightcode_disk_element_t)
};

struct midnightcode_disk_device_t
{
  const char * device;
};

midnightcode_list_head(midnightcode_disk_head_t, midnightcode_disk_element_t)

int midnightcode_disk_flush(struct midnightcode_disk_element_t * disk);
int midnightcode_disk_sg_query(int fd, void * result, int result_len,
                          int opt1, int opt2);
int midnightcode_disk_probe_scsi(int fd, 
                          struct midnightcode_disk_element_t * disk);
int midnightcode_disk_probe_hdio(int fd,
                          struct midnightcode_disk_element_t * disk);
int midnightcode_disk_probe_cdrom(int fd,
                          struct midnightcode_disk_element_t * disk);
int midnightcode_disk_trayopen(struct midnightcode_disk_element_t * disk);
int midnightcode_disk_trayclose(struct midnightcode_disk_element_t * disk);
int midnightcode_disk_capacity(int fd,
                          struct midnightcode_disk_element_t * disk);
int midnightcode_disk_probe(struct midnightcode_disk_element_t * disk);
int midnightcode_disk_list(struct midnightcode_disk_head_t * elements);
int midnightcode_disk_bytype(struct midnightcode_disk_head_t *elements,
                          int type);
int midnightcode_disk_only(struct midnightcode_disk_head_t *elements,
                          int size);
int midnightcode_disk_to_config(
                          struct midnightcode_disk_head_t * disk_elements,
                          struct midnightcode_config_head_t * config_elements);
int midnightcode_disk_from_config(
                          struct midnightcode_disk_head_t * disk_elements,
                          struct midnightcode_config_head_t * config_elements);


#endif
