Import version 1.8.3
[s390-tools.git] / dasdfmt / dasdfmt.h
blobaee6a22b58ab4f904e7b5d817709f2e48dc1560e
1 /*
2 * File...........: s390-tools/dasdfmt/dasdfmt.h
3 * Author(s)......: Horst Hummel <Horst.Hummel@de.ibm.com>
4 * Volker Sameske <sameske@de.ibm.com>
5 * Copyright IBM Corp. 2002,2007
6 */
8 #ifndef DASDFMT_H
9 #define DASDFMT_H
11 #include <unistd.h>
12 #include <stdio.h>
13 #include <sys/types.h>
14 #include <sys/stat.h>
15 #include <fcntl.h>
16 #include <sys/ioctl.h>
17 #include <errno.h>
18 #include <getopt.h>
19 #include <limits.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <dirent.h>
23 #include <mntent.h>
24 #include <ctype.h>
25 #include <signal.h>
26 #include <limits.h>
28 /****************************************************************************
29 * SECTION: Definition needed for DASD-API (see dasd.h) *
30 ****************************************************************************/
32 #define DASD_IOCTL_LETTER 'D'
35 * struct dasd_information_t
36 * represents any data about the device, which is visible to userspace.
37 * including format and features.
39 typedef struct dasd_information_t {
40 unsigned int devno; /* S/390 devno */
41 unsigned int real_devno; /* for aliases */
42 unsigned int schid; /* S/390 subchannel identifier */
43 unsigned int cu_type : 16; /* from SenseID */
44 unsigned int cu_model : 8; /* from SenseID */
45 unsigned int dev_type : 16; /* from SenseID */
46 unsigned int dev_model : 8; /* from SenseID */
47 unsigned int open_count;
48 unsigned int req_queue_len;
49 unsigned int chanq_len; /* length of chanq */
50 char type[4]; /* from discipline.name, */
51 /* 'none' for unknown */
52 unsigned int status; /* current device level */
53 unsigned int label_block; /* where to find the VOLSER */
54 unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
55 unsigned int characteristics_size;
56 unsigned int confdata_size;
57 char characteristics[64]; /* from read_device_characteristics */
58 char configuration_data[256]; /* from read_configuration_data */
59 } dasd_information_t;
62 struct dasd_eckd_characteristics {
63 unsigned short cu_type;
64 struct {
65 unsigned char support:2;
66 unsigned char async:1;
67 unsigned char reserved:1;
68 unsigned char cache_info:1;
69 unsigned char model:3;
70 } __attribute__ ((packed)) cu_model;
71 unsigned short dev_type;
72 unsigned char dev_model;
73 struct {
74 unsigned char mult_burst:1;
75 unsigned char RT_in_LR:1;
76 unsigned char reserved1:1;
77 unsigned char RD_IN_LR:1;
78 unsigned char reserved2:4;
79 unsigned char reserved3:8;
80 unsigned char defect_wr:1;
81 unsigned char XRC_supported:1;
82 unsigned char reserved4:1;
83 unsigned char striping:1;
84 unsigned char reserved5:4;
85 unsigned char cfw:1;
86 unsigned char reserved6:2;
87 unsigned char cache:1;
88 unsigned char dual_copy:1;
89 unsigned char dfw:1;
90 unsigned char reset_alleg:1;
91 unsigned char sense_down:1;
92 } __attribute__ ((packed)) facilities;
93 unsigned char dev_class;
94 unsigned char unit_type;
95 unsigned short no_cyl;
96 unsigned short trk_per_cyl;
97 unsigned char sec_per_trk;
98 unsigned char byte_per_track[3];
99 unsigned short home_bytes;
100 unsigned char formula;
101 union {
102 struct {
103 unsigned char f1;
104 unsigned short f2;
105 unsigned short f3;
106 } __attribute__ ((packed)) f_0x01;
107 struct {
108 unsigned char f1;
109 unsigned char f2;
110 unsigned char f3;
111 unsigned char f4;
112 unsigned char f5;
113 } __attribute__ ((packed)) f_0x02;
114 } __attribute__ ((packed)) factors;
115 unsigned short first_alt_trk;
116 unsigned short no_alt_trk;
117 unsigned short first_dia_trk;
118 unsigned short no_dia_trk;
119 unsigned short first_sup_trk;
120 unsigned short no_sup_trk;
121 unsigned char MDR_ID;
122 unsigned char OBR_ID;
123 unsigned char director;
124 unsigned char rd_trk_set;
125 unsigned short max_rec_zero;
126 unsigned char reserved1;
127 unsigned char RWANY_in_LR;
128 unsigned char factor6;
129 unsigned char factor7;
130 unsigned char factor8;
131 unsigned char reserved2[3];
132 unsigned char reserved3[6];
133 unsigned int long_no_cyl;
134 } __attribute__ ((packed));
138 * struct format_data_t
139 * represents all data necessary to format a dasd
141 typedef struct format_data_t {
142 unsigned int start_unit; /* from track */
143 unsigned int stop_unit; /* to track */
144 unsigned int blksize; /* sectorsize */
145 unsigned int intensity;
146 } format_data_t;
149 * values to be used for format_data_t.intensity
150 * 0/8: normal format
151 * 1/9: also write record zero
152 * 3/11: also write home address
153 * 4/12: invalidate track
155 #define DASD_FMT_INT_FMT_R0 1 /* write record zero */
156 #define DASD_FMT_INT_FMT_HA 2 /* write home address, also set FMT_R0 ! */
157 #define DASD_FMT_INT_INVAL 4 /* invalidate tracks */
158 #define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
159 #define DASD_FMT_INT_FMT_NOR0 16 /* remove permission to write record zero */
162 /* Disable the volume (for Linux) */
163 #define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0)
164 /* Enable the volume (for Linux) */
165 #define BIODASDENABLE _IO(DASD_IOCTL_LETTER,1)
167 /* Get information on a dasd device (enhanced) */
168 #define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
170 /* #define BIODASDFORMAT _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */
171 #define BIODASDFMT _IOW(DASD_IOCTL_LETTER,1,format_data_t)
173 /****************************************************************************
174 * SECTION: Further IOCTL Definitions (see fs.h and hdreq.h ) *
175 ****************************************************************************/
176 /* re-read partition table */
177 #define BLKRRPART _IO(0x12,95)
178 /* get block device sector size */
179 #define BLKSSZGET _IO(0x12,104)
180 /* get read-only status (0 = read_write) */
181 #define BLKROGET _IO(0x12,94)
183 /* get device geometry */
184 #define HDIO_GETGEO 0x0301
186 /****************************************************************************
187 * SECTION: DASDFMT internal types *
188 ****************************************************************************/
190 #define DASD_PARTN_BITS 2
192 #define EXIT_MISUSE 1
193 #define EXIT_BUSY 2
194 #define LABEL_LENGTH 14
195 #define VLABEL_CHARS 84
196 #define LINE_LENGTH 80
197 #define ERR_LENGTH 80
199 #define DEFAULT_BLOCKSIZE 4096
200 #define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
202 #define ERRMSG(x...) {fflush(stdout);fprintf(stderr,x);}
203 #define ERRMSG_EXIT(ec,x...) {fflush(stdout);fprintf(stderr,x);exit(ec);}
205 #define CHECK_SPEC_MAX_ONCE(i,str) \
206 {if (i>1) ERRMSG_EXIT(EXIT_MISUSE,"%s: " str " " \
207 "can only be specified once\n",prog_name);}
209 #define PARSE_PARAM_INTO(x,param,base,str) \
210 {char *endptr=NULL; x=(int)strtol(param,&endptr,base); \
211 if (*endptr) ERRMSG_EXIT(EXIT_MISUSE,"%s: " str " " \
212 "is in invalid format\n",prog_name);}
214 #define dasdfmt_getopt_string "b:n:l:f:d:m:hpPLtyvVFk"
216 static struct option dasdfmt_getopt_long_options[]=
218 { "disk_layout", 1, 0, 'd'},
219 { "test", 0, 0, 't'},
220 { "version", 0, 0, 'V'},
221 { "no_label", 0, 0, 'L'},
222 { "force", 0, 0, 'F'},
223 { "progressbar", 0, 0, 'p'},
224 { "hashmarks", 1, 0, 'm'},
225 { "percentage", 0, 0, 'P'},
226 { "label", 1, 0, 'l'},
227 { "devno", 1, 0, 'n'},
228 { "device", 1, 0, 'f'},
229 { "blocksize", 1, 0, 'b'},
230 { "help", 0, 0, 'h'},
231 { "keep_volser", 0, 0, 'k'},
232 { "norecordzero", 0, 0, 'z'},
233 {0, 0, 0, 0}
236 typedef struct bootstrap1 {
237 u_int32_t key;
238 u_int32_t data[6];
239 } __attribute__ ((packed)) bootstrap1_t;
241 typedef struct bootstrap2 {
242 u_int32_t key;
243 u_int32_t data[36];
244 } __attribute__ ((packed)) bootstrap2_t;
246 typedef struct dasdfmt_info {
247 int devno;
248 char devname[PATH_MAX];
249 int usage_count;
250 int verbosity;
251 int testmode;
252 int withoutprompt;
253 int print_progressbar;
254 int print_hashmarks, hashstep;
255 int print_percentage;
256 int force;
257 int writenolabel;
258 int labelspec;
259 int cdl_format;
260 int blksize_specified;
261 int node_specified;
262 int devno_specified;
263 int device_id;
264 int keep_volser;
265 } dasdfmt_info_t;
269 C9D7D3F1 000A0000 0000000F 03000000 00000001 00000000 00000000
271 bootstrap1_t ipl1 = {
272 0xC9D7D3F1, {
273 0x000A0000, 0x0000000F, 0x03000000,
274 0x00000001, 0x00000000, 0x00000000
279 C9D7D3F2 07003AB8 40000006 31003ABE 40000005 08003AA0 00000000 06000000
280 20000000 00000000 00000000 00000400 00000000 00000000 00000000 00000000
281 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
282 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
283 00000000 00000000 00000000 00000000 00000000
285 bootstrap2_t ipl2 = {
286 0xC9D7D3F2, {
287 0x07003AB8, 0x40000006, 0x31003ABE,
288 0x40000005, 0x08003AA0, 0x00000000,
289 0x06000000, 0x20000000, 0x00000000,
290 0x00000000, 0x00000400, 0x00000000,
291 0x00000000, 0x00000000, 0x00000000,
292 0x00000000, 0x00000000, 0x00000000,
293 0x00000000, 0x00000000, 0x00000000,
294 0x00000000, 0x00000000, 0x00000000,
295 0x00000000, 0x00000000, 0x00000000,
296 0x00000000, 0x00000000, 0x00000000,
297 0x00000000, 0x00000000, 0x00000000,
298 0x00000000, 0x00000000, 0x00000000
302 #endif /* DASDFMT_H */