fdasd.h

00001 /*
00002  * File...........: s390-tools/fdasd/fdasd.h
00003  * Author(s)......: Volker Sameske <sameske@de.ibm.com>
00004  *                  Horst Hummel   <Horst.Hummel@de.ibm.com>
00005  * Bugreports.to..: <Linux390@de.ibm.com>
00006  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2001-2002
00007  *
00008  * History of changes (starts March 2001)
00009  * version 1.01 - menu entry 's' to show mapping devnode - DS name
00010  *         1.02 - DS names count now from 0001 instead from 0000
00011  *         1.03 - volser checks: 'AA AAA' to 'AAAAA '
00012  *              - removed dependency to kernel headers.
00013  *         1.04 - added -p option
00014  *         1.05 - new API policy, set it back to 0
00015  */
00016 #ifndef FDASD_H
00017 #define FDASD_H
00018 
00019 #include <parted/vtoc.h>
00020 
00021 /*****************************************************************************
00022  * SECTION: Definitions needed for DASD-API (see dasd.h)                     *
00023  *****************************************************************************/
00024 
00025 #define DASD_IOCTL_LETTER 'D'
00026 
00027 #define DASD_PARTN_BITS 2
00028 
00029 #define PARTITION_LINUX_SWAP    0x82
00030 #define PARTITION_LINUX         0x83
00031 #define PARTITION_LINUX_EXT     0x85
00032 #define PARTITION_LINUX_LVM     0x8e
00033 #define PARTITION_LINUX_RAID    0xfd
00034 #define PARTITION_LINUX_LVM_OLD 0xfe
00035 
00036 #define PART_TYPE_NATIVE "NATIVE"
00037 #define PART_TYPE_SWAP   "SWAP  "
00038 #define PART_TYPE_RAID   "RAID  "
00039 #define PART_TYPE_LVM    "LVM   "
00040 
00041 #ifdef DEBUG_DASD
00042 #define PDEBUG           fprintf(stderr, "%s:%d:%s\n", \
00043                          __FILE__,                              \
00044                          __LINE__,                              \
00045                          __PRETTY_FUNCTION__);
00046 #else
00047 #define PDEBUG
00048 #endif
00049 
00050 /* 
00051  * struct dasd_information_t
00052  * represents any data about the device, which is visible to userspace.
00053  *  including foramt and featueres.
00054  */
00055 typedef struct dasd_information_t {
00056         unsigned int devno;           /* S/390 devno                         */
00057         unsigned int real_devno;      /* for aliases                         */
00058         unsigned int schid;           /* S/390 subchannel identifier         */
00059         unsigned int cu_type  : 16;   /* from SenseID                        */
00060         unsigned int cu_model :  8;   /* from SenseID                        */
00061         unsigned int dev_type : 16;   /* from SenseID                        */
00062         unsigned int dev_model : 8;   /* from SenseID                        */
00063         unsigned int open_count; 
00064         unsigned int req_queue_len; 
00065         unsigned int chanq_len;       /* length of chanq                     */
00066         char type[4];                 /* from discipline.name, 'none' for    */
00067                                       /* unknown                             */
00068         unsigned int status;          /* current device level                */
00069         unsigned int label_block;     /* where to find the VOLSER            */
00070         unsigned int FBA_layout;      /* fixed block size (like AIXVOL)      */
00071         unsigned int characteristics_size;
00072         unsigned int confdata_size;
00073         char characteristics[64];     /* from read_device_characteristics    */
00074         char configuration_data[256]; /* from read_configuration_data        */
00075 } dasd_information_t;
00076 
00077 /* 
00078  * struct format_data_t
00079  * represents all data necessary to format a dasd
00080  */
00081 typedef struct format_data_t {
00082         int start_unit; /* from track */
00083         int stop_unit;  /* to track */
00084         int blksize;    /* sectorsize */
00085         int intensity;  
00086 } format_data_t;
00087 
00088 /*
00089  * values to be used for format_data_t.intensity
00090  * 0/8: normal format
00091  * 1/9: also write record zero
00092  * 3/11: also write home address
00093  * 4/12: invalidate track
00094  */
00095 #define DASD_FMT_INT_FMT_R0 1 /* write record zero */
00096 #define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
00097 #define DASD_FMT_INT_INVAL  4 /* invalidate tracks */
00098 #define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
00099 
00100 
00101 /* Disable the volume (for Linux) */
00102 #define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0) 
00103 /* Enable the volume (for Linux) */
00104 #define BIODASDENABLE  _IO(DASD_IOCTL_LETTER,1)  
00105 
00106 /* retrieve API version number */
00107 #define DASDAPIVER     _IOR(DASD_IOCTL_LETTER,0,int)
00108 /* Get information on a dasd device (enhanced) */
00109 #define BIODASDINFO   _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
00110 
00111 
00112 /*****************************************************************************
00113  * SECTION: Further IOCTL Definitions  (see fs.h)                            *
00114  *****************************************************************************/
00115 /* re-read partition table */
00116 #define BLKRRPART  _IO(0x12,95) 
00117 /* get block device sector size */
00118 #define BLKSSZGET  _IO(0x12,104)
00119 
00120 /*****************************************************************************
00121  * SECTION: Definition from hdreq.h                                          *
00122  *****************************************************************************/
00123 
00124 struct fdasd_hd_geometry {
00125       unsigned char heads;
00126       unsigned char sectors;
00127       unsigned short cylinders;
00128       unsigned long start;
00129 };
00130 
00131 /* get device geometry */
00132 #define HDIO_GETGEO             0x0301  
00133 
00134 /*****************************************************************************
00135  * SECTION: FDASD internal types                                             *
00136  *****************************************************************************/
00137 
00138 #define DASD_MIN_API_VERSION 0
00139 
00140 #define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */
00141 
00142 #define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
00143 #define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
00144 
00145 #define FDASD_VERSION "1.05"
00146 #define FDASD_ERROR "fdasd error: "
00147 #define DEVICE "device"
00148 #define DISC   "disc"
00149 #define PART   "part"
00150 
00151 #define ALTERNATE_CYLINDERS_USED 0x10
00152 
00153 typedef struct partition_info {
00154         u_int8_t used;
00155         unsigned long start_trk;
00156         unsigned long end_trk;
00157         unsigned long len_trk;
00158         unsigned long fspace_trk;
00159         format1_label_t *f1; 
00160         struct partition_info *next;
00161         struct partition_info *prev;
00162         u_int8_t type;
00163 } partition_info_t;
00164 
00165 typedef struct config_data {
00166         unsigned long start;
00167         unsigned long stop;
00168 } config_data_t;
00169 
00170 typedef struct fdasd_anchor {
00171         int vlabel_changed;
00172         int vtoc_changed;
00173         int devname_specified;
00174         int volid_specified;
00175         int config_specified;
00176         int auto_partition;
00177         int print_table;
00178         int big_disk;
00179         int silent;
00180         int verbose;
00181         int devno;
00182         int option_reuse;
00183         int option_recreate;
00184         int partno[USABLE_PARTITIONS];
00185         u_int16_t dev_type;
00186         unsigned int used_partitions;
00187         unsigned long label_pos;
00188         unsigned int  blksize;
00189         unsigned long fspace_trk;
00190         format4_label_t  *f4;
00191         format5_label_t  *f5;
00192         format7_label_t  *f7;
00193         partition_info_t *first;
00194         partition_info_t *last;
00195         volume_label_t   *vlabel;
00196         config_data_t confdata[USABLE_PARTITIONS];
00197         struct fdasd_hd_geometry geo;
00198 } fdasd_anchor_t;
00199 
00200 enum offset {lower, upper};
00201 
00202 enum fdasd_failure {
00203         unable_to_open_disk,
00204         unable_to_seek_disk,
00205         unable_to_read_disk,
00206         read_only_disk,
00207         unable_to_ioctl,
00208         api_version_mismatch,
00209         wrong_disk_type,
00210         wrong_disk_format,
00211         disk_in_use,
00212         config_syntax_error,
00213         vlabel_corrupted,
00214         dsname_corrupted,
00215         malloc_failed,
00216         device_verification_failed
00217 };
00218 
00219 void fdasd_cleanup (fdasd_anchor_t *anchor);
00220 void fdasd_initialize_anchor (fdasd_anchor_t * anc);
00221 void fdasd_get_geometry (fdasd_anchor_t *anc, int fd);
00222 void fdasd_check_api_version (fdasd_anchor_t *anc, int fd);
00223 int fdasd_check_volume (fdasd_anchor_t *anc, int fd);
00224 int fdasd_write_labels (fdasd_anchor_t *anc, int fd);
00225 int fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc);
00226 void fdasd_recreate_vtoc(fdasd_anchor_t *anc);
00227 partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc,
00228                                         unsigned int start, unsigned int stop);
00229 int fdasd_prepare_labels (fdasd_anchor_t *anc, int fd) ;
00230 
00231 #endif /* FDASD_H */

Generated on Fri May 4 05:15:31 2007 for libparted by  doxygen 1.5.2