Import version 1.8.3
[s390-tools.git] / fdasd / fdasd.h
blob107e486471ff9b6d3e36c931887bb5623840e8c6
1 /*
2 * File...........: s390-tools/fdasd/fdasd.h
3 * Author(s)......: Volker Sameske <sameske@de.ibm.com>
4 * Horst Hummel <Horst.Hummel@de.ibm.com>
5 * Copyright IBM Corp. 2001,2007
6 */
8 #ifndef FDASD_H
9 #define FDASD_H
11 /*****************************************************************************
12 * SECTION: Definitions needed for DASD-API (see dasd.h) *
13 *****************************************************************************/
15 #define DASD_IOCTL_LETTER 'D'
17 #define DASD_PARTN_BITS 2
19 /*
20 * struct dasd_information_t
21 * represents any data about the device, which is visible to userspace.
22 * including foramt and featueres.
24 typedef struct dasd_information_t {
25 unsigned int devno; /* S/390 devno */
26 unsigned int real_devno; /* for aliases */
27 unsigned int schid; /* S/390 subchannel identifier */
28 unsigned int cu_type : 16; /* from SenseID */
29 unsigned int cu_model : 8; /* from SenseID */
30 unsigned int dev_type : 16; /* from SenseID */
31 unsigned int dev_model : 8; /* from SenseID */
32 unsigned int open_count;
33 unsigned int req_queue_len;
34 unsigned int chanq_len; /* length of chanq */
35 char type[4]; /* from discipline.name, 'none' for */
36 /* unknown */
37 unsigned int status; /* current device level */
38 unsigned int label_block; /* where to find the VOLSER */
39 unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
40 unsigned int characteristics_size;
41 unsigned int confdata_size;
42 char characteristics[64]; /* from read_device_characteristics */
43 char configuration_data[256]; /* from read_configuration_data */
44 } dasd_information_t;
46 /* Get information on a dasd device (enhanced) */
47 #define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
50 /*****************************************************************************
51 * SECTION: Further IOCTL Definitions (see fs.h and hdreq.h) *
52 *****************************************************************************/
53 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
54 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
55 #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
56 #define BLKGETSIZE64 _IOR(0x12,114,size_t) /* device size in bytes (u64 *arg)*/
58 /* get device geometry */
59 #define HDIO_GETGEO 0x0301
61 /*****************************************************************************
62 * SECTION: FDASD internal types *
63 *****************************************************************************/
65 #define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */
67 #define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
68 #define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
70 #define FDASD_ERROR "fdasd error: "
71 #define DEVICE "device"
72 #define DISC "disc"
73 #define PART "part"
75 #define ALTERNATE_CYLINDERS_USED 0x10
77 static struct option fdasd_long_options[] = {
78 { "version", no_argument, NULL, 'v'},
79 { "auto", no_argument, NULL, 'a'},
80 { "silent", no_argument, NULL, 's'},
81 { "verbose", no_argument, NULL, 'r'},
82 { "label", required_argument, NULL, 'l'},
83 { "config", required_argument, NULL, 'c'},
84 { "help", no_argument, NULL, 'h'},
85 { "table", no_argument, NULL, 'p'},
86 { "volser", no_argument, NULL, 'i'},
87 { "keep_volser", no_argument, NULL, 'k'},
88 { 0, 0, 0, 0 }
91 /* Command line option abbreviations */
92 static const char option_string[] = "vasrl:c:hpik";
94 struct fdasd_options {
95 char *device;
96 char *volser;
97 char *conffile;
100 struct fdasd_options options = {
101 NULL, /* device */
102 NULL, /* volser */
103 NULL, /* conffile */
106 typedef struct partition_info {
107 u_int8_t used;
108 unsigned long start_trk;
109 unsigned long end_trk;
110 unsigned long len_trk;
111 unsigned long fspace_trk;
112 format1_label_t *f1;
113 struct partition_info *next;
114 struct partition_info *prev;
115 } partition_info_t;
118 typedef struct config_data {
119 unsigned long start;
120 unsigned long stop;
121 } config_data_t;
124 typedef struct fdasd_anchor {
125 int vlabel_changed;
126 int vtoc_changed;
127 int auto_partition;
128 int print_table;
129 int print_volser;
130 int keep_volser;
131 int big_disk;
132 int silent;
133 int verbose;
134 int devno;
135 int option_reuse;
136 int option_recreate;
137 int partno[USABLE_PARTITIONS];
138 u_int16_t dev_type;
139 unsigned int used_partitions;
140 unsigned long label_pos;
141 unsigned int blksize;
142 unsigned long fspace_trk;
143 format4_label_t *f4;
144 format5_label_t *f5;
145 format7_label_t *f7;
146 format9_label_t *f9; /* template for all f9 labels */
147 partition_info_t *first;
148 partition_info_t *last;
149 volume_label_t *vlabel;
150 config_data_t confdata[USABLE_PARTITIONS];
151 u_int32_t hw_cylinders;
152 u_int32_t formatted_cylinders;
153 } fdasd_anchor_t;
155 enum offset {lower, upper};
157 enum fdasd_failure {
158 parser_failed,
159 unable_to_open_disk,
160 unable_to_seek_disk,
161 unable_to_read_disk,
162 read_only_disk,
163 unable_to_ioctl,
164 wrong_disk_type,
165 wrong_disk_format,
166 disk_in_use,
167 config_syntax_error,
168 vlabel_corrupted,
169 dsname_corrupted,
170 malloc_failed,
171 device_verification_failed,
172 volser_not_found
175 #define ERROR_STRING_SIZE 1024
176 #define INPUT_BUF_SIZE 1024
178 #endif /* FDASD_H */