00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef FDASD_H
00017 #define FDASD_H
00018
00019 #include <parted/vtoc.h>
00020
00021
00022
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
00052
00053
00054
00055 typedef struct dasd_information_t {
00056 unsigned int devno;
00057 unsigned int real_devno;
00058 unsigned int schid;
00059 unsigned int cu_type : 16;
00060 unsigned int cu_model : 8;
00061 unsigned int dev_type : 16;
00062 unsigned int dev_model : 8;
00063 unsigned int open_count;
00064 unsigned int req_queue_len;
00065 unsigned int chanq_len;
00066 char type[4];
00067
00068 unsigned int status;
00069 unsigned int label_block;
00070 unsigned int FBA_layout;
00071 unsigned int characteristics_size;
00072 unsigned int confdata_size;
00073 char characteristics[64];
00074 char configuration_data[256];
00075 } dasd_information_t;
00076
00077
00078
00079
00080
00081 typedef struct format_data_t {
00082 int start_unit;
00083 int stop_unit;
00084 int blksize;
00085 int intensity;
00086 } format_data_t;
00087
00088
00089
00090
00091
00092
00093
00094
00095 #define DASD_FMT_INT_FMT_R0 1
00096 #define DASD_FMT_INT_FMT_HA 2
00097 #define DASD_FMT_INT_INVAL 4
00098 #define DASD_FMT_INT_COMPAT 8
00099
00100
00101
00102 #define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0)
00103
00104 #define BIODASDENABLE _IO(DASD_IOCTL_LETTER,1)
00105
00106
00107 #define DASDAPIVER _IOR(DASD_IOCTL_LETTER,0,int)
00108
00109 #define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
00110
00111
00112
00113
00114
00115
00116 #define BLKRRPART _IO(0x12,95)
00117
00118 #define BLKSSZGET _IO(0x12,104)
00119
00120
00121
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
00132 #define HDIO_GETGEO 0x0301
00133
00134
00135
00136
00137
00138 #define DASD_MIN_API_VERSION 0
00139
00140 #define DEFAULT_FDASD_CONF "/etc/fdasd.conf"
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