/*

                                   _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>

    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


#define MIDNIGHTCODE_DISK_STRUCTURE "disk"

static const char * midnightcode_disk_device_t[] =
{
  "Disk",
  "Tape",
  "Printer",
  "Processor",
  "Optical Disk (Write Once)",
  "Optical Disk (CD/DVD)",
  "Scanner",
  "Optical Memory Device",
  "Medium Changer",
  "Communications Device",
  "Graphics Device (a)",
  "Graphics Device (b)",
  "Storage Array Controller",
  "Enclosure Services Device",
  "Simplified Direct Access Device",
  "Optical Card Reader/Writer Device",
  "Bridge Controller Commands",
  "Object Based Storage Device",
  "Automation/Driver Interface",
  "Unknown Device (0x13)",
  "Unknown Device (0x14)",
  "Unknown Device (0x15)",
  "Unknown Device (0x16)",
  "Unknown Device (0x17)",
  "Unknown Device (0x18)",
  "Unknown Device (0x19)",
  "Unknown Device (0x1a)",
  "Unknown Device (0x1b)",
  "Unknown Device (0x1c)",
  "Unknown Device (0x1d)",
  "Well-known Logical Unit",
  "No physical device on this Logical Unit"
};

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
};

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];
  long double capacity_blocks;
  long double capacity_bytes;
  long double capacity_value;
  char capacity_units[64];
  char capacity_s[128];
  int dma;
  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_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
