Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX_GENHD_H |
2 | #define _LINUX_GENHD_H | |
3 | ||
4 | /* | |
5 | * genhd.h Copyright (C) 1992 Drew Eckhardt | |
6 | * Generic hard disk header file by | |
7 | * Drew Eckhardt | |
8 | * | |
9 | * <drew@colorado.edu> | |
10 | */ | |
11 | ||
1da177e4 | 12 | #include <linux/types.h> |
edfaa7c3 | 13 | #include <linux/kdev_t.h> |
1da177e4 | 14 | |
9361401e DH |
15 | #ifdef CONFIG_BLOCK |
16 | ||
edfaa7c3 KS |
17 | #define kobj_to_dev(k) container_of(k, struct device, kobj) |
18 | #define dev_to_disk(device) container_of(device, struct gendisk, dev) | |
19 | #define dev_to_part(device) container_of(device, struct hd_struct, dev) | |
20 | ||
edfaa7c3 KS |
21 | extern struct device_type part_type; |
22 | extern struct kobject *block_depr; | |
23 | extern struct class block_class; | |
24 | ||
1da177e4 LT |
25 | enum { |
26 | /* These three have identical behaviour; use the second one if DOS FDISK gets | |
27 | confused about extended/logical partitions starting past cylinder 1023. */ | |
28 | DOS_EXTENDED_PARTITION = 5, | |
29 | LINUX_EXTENDED_PARTITION = 0x85, | |
30 | WIN98_EXTENDED_PARTITION = 0x0f, | |
31 | ||
d18d7682 FMDN |
32 | SUN_WHOLE_DISK = DOS_EXTENDED_PARTITION, |
33 | ||
1da177e4 | 34 | LINUX_SWAP_PARTITION = 0x82, |
4419d1ac OH |
35 | LINUX_DATA_PARTITION = 0x83, |
36 | LINUX_LVM_PARTITION = 0x8e, | |
1da177e4 LT |
37 | LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */ |
38 | ||
39 | SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION, | |
40 | NEW_SOLARIS_X86_PARTITION = 0xbf, | |
41 | ||
42 | DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */ | |
43 | DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */ | |
44 | DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */ | |
45 | EZD_PARTITION = 0x55, /* EZ-DRIVE */ | |
46 | ||
47 | FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */ | |
48 | OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */ | |
49 | NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */ | |
50 | BSDI_PARTITION = 0xb7, /* BSDI Partition ID */ | |
51 | MINIX_PARTITION = 0x81, /* Minix Partition ID */ | |
52 | UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */ | |
53 | }; | |
54 | ||
55 | #ifndef __KERNEL__ | |
56 | ||
57 | struct partition { | |
58 | unsigned char boot_ind; /* 0x80 - active */ | |
59 | unsigned char head; /* starting head */ | |
60 | unsigned char sector; /* starting sector */ | |
61 | unsigned char cyl; /* starting cylinder */ | |
62 | unsigned char sys_ind; /* What partition type */ | |
63 | unsigned char end_head; /* end head */ | |
64 | unsigned char end_sector; /* end sector */ | |
65 | unsigned char end_cyl; /* end cylinder */ | |
66 | unsigned int start_sect; /* starting sector counting from 0 */ | |
67 | unsigned int nr_sects; /* nr of sectors in partition */ | |
68 | } __attribute__((packed)); | |
69 | ||
70 | #endif | |
71 | ||
72 | #ifdef __KERNEL__ | |
34186efc DW |
73 | #include <linux/major.h> |
74 | #include <linux/device.h> | |
75 | #include <linux/smp.h> | |
76 | #include <linux/string.h> | |
77 | #include <linux/fs.h> | |
8ce7ad7b | 78 | #include <linux/workqueue.h> |
34186efc | 79 | |
1da177e4 LT |
80 | struct partition { |
81 | unsigned char boot_ind; /* 0x80 - active */ | |
82 | unsigned char head; /* starting head */ | |
83 | unsigned char sector; /* starting sector */ | |
84 | unsigned char cyl; /* starting cylinder */ | |
85 | unsigned char sys_ind; /* What partition type */ | |
86 | unsigned char end_head; /* end head */ | |
87 | unsigned char end_sector; /* end sector */ | |
88 | unsigned char end_cyl; /* end cylinder */ | |
89 | __le32 start_sect; /* starting sector counting from 0 */ | |
90 | __le32 nr_sects; /* nr of sectors in partition */ | |
91 | } __attribute__((packed)); | |
92 | ||
ea5c48ab JM |
93 | struct disk_stats { |
94 | unsigned long sectors[2]; /* READs and WRITEs */ | |
95 | unsigned long ios[2]; | |
96 | unsigned long merges[2]; | |
97 | unsigned long ticks[2]; | |
98 | unsigned long io_ticks; | |
99 | unsigned long time_in_queue; | |
100 | }; | |
101 | ||
1da177e4 LT |
102 | struct hd_struct { |
103 | sector_t start_sect; | |
104 | sector_t nr_sects; | |
edfaa7c3 | 105 | struct device dev; |
6a4d44c1 | 106 | struct kobject *holder_dir; |
1da177e4 | 107 | int policy, partno; |
c17bb495 AM |
108 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
109 | int make_it_fail; | |
ea5c48ab JM |
110 | #endif |
111 | unsigned long stamp; | |
112 | int in_flight; | |
113 | #ifdef CONFIG_SMP | |
114 | struct disk_stats *dkstats; | |
115 | #else | |
116 | struct disk_stats dkstats; | |
c17bb495 | 117 | #endif |
1da177e4 LT |
118 | }; |
119 | ||
120 | #define GENHD_FL_REMOVABLE 1 | |
121 | #define GENHD_FL_DRIVERFS 2 | |
86ce18d7 | 122 | #define GENHD_FL_MEDIA_CHANGE_NOTIFY 4 |
1da177e4 LT |
123 | #define GENHD_FL_CD 8 |
124 | #define GENHD_FL_UP 16 | |
125 | #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 | |
c17bb495 | 126 | #define GENHD_FL_FAIL 64 |
1da177e4 | 127 | |
ea5c48ab | 128 | |
1da177e4 LT |
129 | struct gendisk { |
130 | int major; /* major number of driver */ | |
131 | int first_minor; | |
132 | int minors; /* maximum number of minors, =1 for | |
133 | * disks that can't be partitioned. */ | |
134 | char disk_name[32]; /* name of major driver */ | |
135 | struct hd_struct **part; /* [indexed by minor] */ | |
136 | struct block_device_operations *fops; | |
137 | struct request_queue *queue; | |
138 | void *private_data; | |
139 | sector_t capacity; | |
140 | ||
141 | int flags; | |
edfaa7c3 KS |
142 | struct device *driverfs_dev; // FIXME: remove |
143 | struct device dev; | |
6a4d44c1 JN |
144 | struct kobject *holder_dir; |
145 | struct kobject *slave_dir; | |
1da177e4 LT |
146 | |
147 | struct timer_rand_state *random; | |
148 | int policy; | |
149 | ||
150 | atomic_t sync_io; /* RAID */ | |
20e5c81f | 151 | unsigned long stamp; |
1da177e4 LT |
152 | int in_flight; |
153 | #ifdef CONFIG_SMP | |
154 | struct disk_stats *dkstats; | |
155 | #else | |
156 | struct disk_stats dkstats; | |
157 | #endif | |
8ce7ad7b | 158 | struct work_struct async_notify; |
1da177e4 LT |
159 | }; |
160 | ||
1da177e4 LT |
161 | /* |
162 | * Macros to operate on percpu disk statistics: | |
163 | * | |
164 | * The __ variants should only be called in critical sections. The full | |
165 | * variants disable/enable preemption. | |
166 | */ | |
ea5c48ab JM |
167 | static inline struct hd_struct *get_part(struct gendisk *gendiskp, |
168 | sector_t sector) | |
169 | { | |
170 | struct hd_struct *part; | |
171 | int i; | |
172 | for (i = 0; i < gendiskp->minors - 1; i++) { | |
173 | part = gendiskp->part[i]; | |
174 | if (part && part->start_sect <= sector | |
175 | && sector < part->start_sect + part->nr_sects) | |
176 | return part; | |
177 | } | |
178 | return NULL; | |
179 | } | |
180 | ||
1da177e4 LT |
181 | #ifdef CONFIG_SMP |
182 | #define __disk_stat_add(gendiskp, field, addnd) \ | |
183 | (per_cpu_ptr(gendiskp->dkstats, smp_processor_id())->field += addnd) | |
184 | ||
185 | #define disk_stat_read(gendiskp, field) \ | |
186 | ({ \ | |
187 | typeof(gendiskp->dkstats->field) res = 0; \ | |
188 | int i; \ | |
0a945022 | 189 | for_each_possible_cpu(i) \ |
1da177e4 | 190 | res += per_cpu_ptr(gendiskp->dkstats, i)->field; \ |
1da177e4 LT |
191 | res; \ |
192 | }) | |
193 | ||
194 | static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { | |
195 | int i; | |
0a945022 | 196 | for_each_possible_cpu(i) |
394e3902 AM |
197 | memset(per_cpu_ptr(gendiskp->dkstats, i), value, |
198 | sizeof (struct disk_stats)); | |
1da177e4 | 199 | } |
ea5c48ab JM |
200 | |
201 | #define __part_stat_add(part, field, addnd) \ | |
202 | (per_cpu_ptr(part->dkstats, smp_processor_id())->field += addnd) | |
203 | ||
204 | #define __all_stat_add(gendiskp, field, addnd, sector) \ | |
205 | ({ \ | |
206 | struct hd_struct *part = get_part(gendiskp, sector); \ | |
207 | if (part) \ | |
208 | __part_stat_add(part, field, addnd); \ | |
209 | __disk_stat_add(gendiskp, field, addnd); \ | |
210 | }) | |
211 | ||
212 | #define part_stat_read(part, field) \ | |
213 | ({ \ | |
214 | typeof(part->dkstats->field) res = 0; \ | |
215 | int i; \ | |
216 | for_each_possible_cpu(i) \ | |
217 | res += per_cpu_ptr(part->dkstats, i)->field; \ | |
218 | res; \ | |
219 | }) | |
220 | ||
221 | static inline void part_stat_set_all(struct hd_struct *part, int value) { | |
222 | int i; | |
223 | for_each_possible_cpu(i) | |
224 | memset(per_cpu_ptr(part->dkstats, i), value, | |
225 | sizeof(struct disk_stats)); | |
226 | } | |
1da177e4 LT |
227 | |
228 | #else | |
229 | #define __disk_stat_add(gendiskp, field, addnd) \ | |
230 | (gendiskp->dkstats.field += addnd) | |
231 | #define disk_stat_read(gendiskp, field) (gendiskp->dkstats.field) | |
232 | ||
ea5c48ab JM |
233 | static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) |
234 | { | |
1da177e4 LT |
235 | memset(&gendiskp->dkstats, value, sizeof (struct disk_stats)); |
236 | } | |
ea5c48ab JM |
237 | |
238 | #define __part_stat_add(part, field, addnd) \ | |
239 | (part->dkstats.field += addnd) | |
240 | ||
241 | #define __all_stat_add(gendiskp, field, addnd, sector) \ | |
242 | ({ \ | |
243 | struct hd_struct *part = get_part(gendiskp, sector); \ | |
244 | if (part) \ | |
245 | part->dkstats.field += addnd; \ | |
246 | __disk_stat_add(gendiskp, field, addnd); \ | |
247 | }) | |
248 | ||
249 | #define part_stat_read(part, field) (part->dkstats.field) | |
250 | ||
251 | static inline void part_stat_set_all(struct hd_struct *part, int value) | |
252 | { | |
253 | memset(&part->dkstats, value, sizeof(struct disk_stats)); | |
254 | } | |
255 | ||
1da177e4 LT |
256 | #endif |
257 | ||
258 | #define disk_stat_add(gendiskp, field, addnd) \ | |
259 | do { \ | |
260 | preempt_disable(); \ | |
261 | __disk_stat_add(gendiskp, field, addnd); \ | |
262 | preempt_enable(); \ | |
263 | } while (0) | |
264 | ||
265 | #define __disk_stat_dec(gendiskp, field) __disk_stat_add(gendiskp, field, -1) | |
266 | #define disk_stat_dec(gendiskp, field) disk_stat_add(gendiskp, field, -1) | |
267 | ||
268 | #define __disk_stat_inc(gendiskp, field) __disk_stat_add(gendiskp, field, 1) | |
269 | #define disk_stat_inc(gendiskp, field) disk_stat_add(gendiskp, field, 1) | |
270 | ||
271 | #define __disk_stat_sub(gendiskp, field, subnd) \ | |
272 | __disk_stat_add(gendiskp, field, -subnd) | |
273 | #define disk_stat_sub(gendiskp, field, subnd) \ | |
274 | disk_stat_add(gendiskp, field, -subnd) | |
275 | ||
ea5c48ab JM |
276 | #define part_stat_add(gendiskp, field, addnd) \ |
277 | do { \ | |
278 | preempt_disable(); \ | |
279 | __part_stat_add(gendiskp, field, addnd);\ | |
280 | preempt_enable(); \ | |
281 | } while (0) | |
282 | ||
283 | #define __part_stat_dec(gendiskp, field) __part_stat_add(gendiskp, field, -1) | |
284 | #define part_stat_dec(gendiskp, field) part_stat_add(gendiskp, field, -1) | |
285 | ||
286 | #define __part_stat_inc(gendiskp, field) __part_stat_add(gendiskp, field, 1) | |
287 | #define part_stat_inc(gendiskp, field) part_stat_add(gendiskp, field, 1) | |
288 | ||
289 | #define __part_stat_sub(gendiskp, field, subnd) \ | |
290 | __part_stat_add(gendiskp, field, -subnd) | |
291 | #define part_stat_sub(gendiskp, field, subnd) \ | |
292 | part_stat_add(gendiskp, field, -subnd) | |
293 | ||
294 | #define all_stat_add(gendiskp, field, addnd, sector) \ | |
295 | do { \ | |
296 | preempt_disable(); \ | |
297 | __all_stat_add(gendiskp, field, addnd, sector); \ | |
298 | preempt_enable(); \ | |
299 | } while (0) | |
300 | ||
301 | #define __all_stat_dec(gendiskp, field, sector) \ | |
302 | __all_stat_add(gendiskp, field, -1, sector) | |
303 | #define all_stat_dec(gendiskp, field, sector) \ | |
304 | all_stat_add(gendiskp, field, -1, sector) | |
305 | ||
306 | #define __all_stat_inc(gendiskp, field, sector) \ | |
307 | __all_stat_add(gendiskp, field, 1, sector) | |
308 | #define all_stat_inc(gendiskp, field, sector) \ | |
309 | all_stat_add(gendiskp, field, 1, sector) | |
310 | ||
311 | #define __all_stat_sub(gendiskp, field, subnd, sector) \ | |
312 | __all_stat_add(gendiskp, field, -subnd, sector) | |
313 | #define all_stat_sub(gendiskp, field, subnd, sector) \ | |
314 | all_stat_add(gendiskp, field, -subnd, sector) | |
1da177e4 LT |
315 | |
316 | /* Inlines to alloc and free disk stats in struct gendisk */ | |
317 | #ifdef CONFIG_SMP | |
318 | static inline int init_disk_stats(struct gendisk *disk) | |
319 | { | |
320 | disk->dkstats = alloc_percpu(struct disk_stats); | |
321 | if (!disk->dkstats) | |
322 | return 0; | |
323 | return 1; | |
324 | } | |
325 | ||
326 | static inline void free_disk_stats(struct gendisk *disk) | |
327 | { | |
328 | free_percpu(disk->dkstats); | |
329 | } | |
ea5c48ab JM |
330 | |
331 | static inline int init_part_stats(struct hd_struct *part) | |
332 | { | |
333 | part->dkstats = alloc_percpu(struct disk_stats); | |
334 | if (!part->dkstats) | |
335 | return 0; | |
336 | return 1; | |
337 | } | |
338 | ||
339 | static inline void free_part_stats(struct hd_struct *part) | |
340 | { | |
341 | free_percpu(part->dkstats); | |
342 | } | |
343 | ||
1da177e4 LT |
344 | #else /* CONFIG_SMP */ |
345 | static inline int init_disk_stats(struct gendisk *disk) | |
346 | { | |
347 | return 1; | |
348 | } | |
349 | ||
350 | static inline void free_disk_stats(struct gendisk *disk) | |
351 | { | |
352 | } | |
ea5c48ab JM |
353 | |
354 | static inline int init_part_stats(struct hd_struct *part) | |
355 | { | |
356 | return 1; | |
357 | } | |
358 | ||
359 | static inline void free_part_stats(struct hd_struct *part) | |
360 | { | |
361 | } | |
1da177e4 LT |
362 | #endif /* CONFIG_SMP */ |
363 | ||
364 | /* drivers/block/ll_rw_blk.c */ | |
365 | extern void disk_round_stats(struct gendisk *disk); | |
6f2576af | 366 | extern void part_round_stats(struct hd_struct *part); |
1da177e4 LT |
367 | |
368 | /* drivers/block/genhd.c */ | |
ac20427e | 369 | extern int get_blkdev_list(char *, int); |
1da177e4 LT |
370 | extern void add_disk(struct gendisk *disk); |
371 | extern void del_gendisk(struct gendisk *gp); | |
372 | extern void unlink_gendisk(struct gendisk *gp); | |
373 | extern struct gendisk *get_gendisk(dev_t dev, int *part); | |
374 | ||
375 | extern void set_device_ro(struct block_device *bdev, int flag); | |
376 | extern void set_disk_ro(struct gendisk *disk, int flag); | |
377 | ||
378 | /* drivers/char/random.c */ | |
379 | extern void add_disk_randomness(struct gendisk *disk); | |
380 | extern void rand_initialize_disk(struct gendisk *disk); | |
381 | ||
382 | static inline sector_t get_start_sect(struct block_device *bdev) | |
383 | { | |
384 | return bdev->bd_contains == bdev ? 0 : bdev->bd_part->start_sect; | |
385 | } | |
386 | static inline sector_t get_capacity(struct gendisk *disk) | |
387 | { | |
388 | return disk->capacity; | |
389 | } | |
390 | static inline void set_capacity(struct gendisk *disk, sector_t size) | |
391 | { | |
392 | disk->capacity = size; | |
393 | } | |
394 | ||
395 | #endif /* __KERNEL__ */ | |
396 | ||
397 | #ifdef CONFIG_SOLARIS_X86_PARTITION | |
398 | ||
b84d8796 | 399 | #define SOLARIS_X86_NUMSLICE 16 |
1da177e4 LT |
400 | #define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) |
401 | ||
402 | struct solaris_x86_slice { | |
403 | __le16 s_tag; /* ID tag of partition */ | |
404 | __le16 s_flag; /* permission flags */ | |
405 | __le32 s_start; /* start sector no of partition */ | |
406 | __le32 s_size; /* # of blocks in partition */ | |
407 | }; | |
408 | ||
409 | struct solaris_x86_vtoc { | |
410 | unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */ | |
411 | __le32 v_sanity; /* to verify vtoc sanity */ | |
412 | __le32 v_version; /* layout version */ | |
413 | char v_volume[8]; /* volume name */ | |
414 | __le16 v_sectorsz; /* sector size in bytes */ | |
415 | __le16 v_nparts; /* number of partitions */ | |
416 | unsigned int v_reserved[10]; /* free space */ | |
417 | struct solaris_x86_slice | |
418 | v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */ | |
419 | unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */ | |
420 | char v_asciilabel[128]; /* for compatibility */ | |
421 | }; | |
422 | ||
423 | #endif /* CONFIG_SOLARIS_X86_PARTITION */ | |
424 | ||
425 | #ifdef CONFIG_BSD_DISKLABEL | |
426 | /* | |
427 | * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il> | |
428 | * updated by Marc Espie <Marc.Espie@openbsd.org> | |
429 | */ | |
430 | ||
431 | /* check against BSD src/sys/sys/disklabel.h for consistency */ | |
432 | ||
433 | #define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */ | |
434 | #define BSD_MAXPARTITIONS 16 | |
435 | #define OPENBSD_MAXPARTITIONS 16 | |
436 | #define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */ | |
437 | struct bsd_disklabel { | |
438 | __le32 d_magic; /* the magic number */ | |
439 | __s16 d_type; /* drive type */ | |
440 | __s16 d_subtype; /* controller/d_type specific */ | |
441 | char d_typename[16]; /* type name, e.g. "eagle" */ | |
442 | char d_packname[16]; /* pack identifier */ | |
443 | __u32 d_secsize; /* # of bytes per sector */ | |
444 | __u32 d_nsectors; /* # of data sectors per track */ | |
445 | __u32 d_ntracks; /* # of tracks per cylinder */ | |
446 | __u32 d_ncylinders; /* # of data cylinders per unit */ | |
447 | __u32 d_secpercyl; /* # of data sectors per cylinder */ | |
448 | __u32 d_secperunit; /* # of data sectors per unit */ | |
449 | __u16 d_sparespertrack; /* # of spare sectors per track */ | |
450 | __u16 d_sparespercyl; /* # of spare sectors per cylinder */ | |
451 | __u32 d_acylinders; /* # of alt. cylinders per unit */ | |
452 | __u16 d_rpm; /* rotational speed */ | |
453 | __u16 d_interleave; /* hardware sector interleave */ | |
454 | __u16 d_trackskew; /* sector 0 skew, per track */ | |
455 | __u16 d_cylskew; /* sector 0 skew, per cylinder */ | |
456 | __u32 d_headswitch; /* head switch time, usec */ | |
457 | __u32 d_trkseek; /* track-to-track seek, usec */ | |
458 | __u32 d_flags; /* generic flags */ | |
459 | #define NDDATA 5 | |
460 | __u32 d_drivedata[NDDATA]; /* drive-type specific information */ | |
461 | #define NSPARE 5 | |
462 | __u32 d_spare[NSPARE]; /* reserved for future use */ | |
463 | __le32 d_magic2; /* the magic number (again) */ | |
464 | __le16 d_checksum; /* xor of data incl. partitions */ | |
465 | ||
466 | /* filesystem and partition information: */ | |
467 | __le16 d_npartitions; /* number of partitions in following */ | |
468 | __le32 d_bbsize; /* size of boot area at sn0, bytes */ | |
469 | __le32 d_sbsize; /* max size of fs superblock, bytes */ | |
470 | struct bsd_partition { /* the partition table */ | |
471 | __le32 p_size; /* number of sectors in partition */ | |
472 | __le32 p_offset; /* starting sector */ | |
473 | __le32 p_fsize; /* filesystem basic fragment size */ | |
474 | __u8 p_fstype; /* filesystem type, see below */ | |
475 | __u8 p_frag; /* filesystem fragments per block */ | |
476 | __le16 p_cpg; /* filesystem cylinders per group */ | |
477 | } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */ | |
478 | }; | |
479 | ||
480 | #endif /* CONFIG_BSD_DISKLABEL */ | |
481 | ||
482 | #ifdef CONFIG_UNIXWARE_DISKLABEL | |
483 | /* | |
484 | * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl> | |
485 | * and Krzysztof G. Baranowski <kgb@knm.org.pl> | |
486 | */ | |
487 | ||
488 | #define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */ | |
489 | #define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */ | |
490 | #define UNIXWARE_NUMSLICE 16 | |
491 | #define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */ | |
492 | ||
493 | struct unixware_slice { | |
494 | __le16 s_label; /* label */ | |
495 | __le16 s_flags; /* permission flags */ | |
496 | __le32 start_sect; /* starting sector */ | |
497 | __le32 nr_sects; /* number of sectors in slice */ | |
498 | }; | |
499 | ||
500 | struct unixware_disklabel { | |
501 | __le32 d_type; /* drive type */ | |
502 | __le32 d_magic; /* the magic number */ | |
503 | __le32 d_version; /* version number */ | |
504 | char d_serial[12]; /* serial number of the device */ | |
505 | __le32 d_ncylinders; /* # of data cylinders per device */ | |
506 | __le32 d_ntracks; /* # of tracks per cylinder */ | |
507 | __le32 d_nsectors; /* # of data sectors per track */ | |
508 | __le32 d_secsize; /* # of bytes per sector */ | |
509 | __le32 d_part_start; /* # of first sector of this partition */ | |
510 | __le32 d_unknown1[12]; /* ? */ | |
511 | __le32 d_alt_tbl; /* byte offset of alternate table */ | |
512 | __le32 d_alt_len; /* byte length of alternate table */ | |
513 | __le32 d_phys_cyl; /* # of physical cylinders per device */ | |
514 | __le32 d_phys_trk; /* # of physical tracks per cylinder */ | |
515 | __le32 d_phys_sec; /* # of physical sectors per track */ | |
516 | __le32 d_phys_bytes; /* # of physical bytes per sector */ | |
517 | __le32 d_unknown2; /* ? */ | |
518 | __le32 d_unknown3; /* ? */ | |
519 | __le32 d_pad[8]; /* pad */ | |
520 | ||
521 | struct unixware_vtoc { | |
522 | __le32 v_magic; /* the magic number */ | |
523 | __le32 v_version; /* version number */ | |
524 | char v_name[8]; /* volume name */ | |
525 | __le16 v_nslices; /* # of slices */ | |
526 | __le16 v_unknown1; /* ? */ | |
527 | __le32 v_reserved[10]; /* reserved */ | |
528 | struct unixware_slice | |
529 | v_slice[UNIXWARE_NUMSLICE]; /* slice headers */ | |
530 | } vtoc; | |
531 | ||
532 | }; /* 408 */ | |
533 | ||
534 | #endif /* CONFIG_UNIXWARE_DISKLABEL */ | |
535 | ||
536 | #ifdef CONFIG_MINIX_SUBPARTITION | |
537 | # define MINIX_NR_SUBPARTITIONS 4 | |
538 | #endif /* CONFIG_MINIX_SUBPARTITION */ | |
539 | ||
540 | #ifdef __KERNEL__ | |
541 | ||
d18d7682 FMDN |
542 | #define ADDPART_FLAG_NONE 0 |
543 | #define ADDPART_FLAG_RAID 1 | |
544 | #define ADDPART_FLAG_WHOLEDISK 2 | |
545 | ||
edfaa7c3 KS |
546 | extern dev_t blk_lookup_devt(const char *name); |
547 | extern char *disk_name (struct gendisk *hd, int part, char *buf); | |
1da177e4 LT |
548 | |
549 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); | |
d18d7682 | 550 | extern void add_partition(struct gendisk *, int, sector_t, sector_t, int); |
1da177e4 | 551 | extern void delete_partition(struct gendisk *, int); |
dd2a345f | 552 | extern void printk_all_partitions(void); |
1da177e4 | 553 | |
1946089a | 554 | extern struct gendisk *alloc_disk_node(int minors, int node_id); |
1da177e4 LT |
555 | extern struct gendisk *alloc_disk(int minors); |
556 | extern struct kobject *get_disk(struct gendisk *disk); | |
557 | extern void put_disk(struct gendisk *disk); | |
edfaa7c3 | 558 | extern void blk_register_region(dev_t devt, unsigned long range, |
1da177e4 LT |
559 | struct module *module, |
560 | struct kobject *(*probe)(dev_t, int *, void *), | |
561 | int (*lock)(dev_t, void *), | |
562 | void *data); | |
edfaa7c3 | 563 | extern void blk_unregister_region(dev_t devt, unsigned long range); |
1da177e4 LT |
564 | |
565 | static inline struct block_device *bdget_disk(struct gendisk *disk, int index) | |
566 | { | |
567 | return bdget(MKDEV(disk->major, disk->first_minor) + index); | |
568 | } | |
569 | ||
570 | #endif | |
571 | ||
87c1efbf JA |
572 | #else /* CONFIG_BLOCK */ |
573 | ||
574 | static inline void printk_all_partitions(void) { } | |
575 | ||
edfaa7c3 KS |
576 | static inline dev_t blk_lookup_devt(const char *name) |
577 | { | |
578 | dev_t devt = MKDEV(0, 0); | |
579 | return devt; | |
580 | } | |
581 | ||
87c1efbf | 582 | #endif /* CONFIG_BLOCK */ |
9361401e DH |
583 | |
584 | #endif |