Import 2.4.0-test2pre7
[davej-history.git] / include / linux / genhd.h
blobc0f69dbb49437595f1724e882f2d1fc32e287143
1 #ifndef _LINUX_GENHD_H
2 #define _LINUX_GENHD_H
4 /*
5 * genhd.h Copyright (C) 1992 Drew Eckhardt
6 * Generic hard disk header file by
7 * Drew Eckhardt
9 * <drew@colorado.edu>
12 #include <linux/config.h>
13 #include <linux/types.h>
14 #include <linux/major.h>
16 /* These three have identical behaviour; use the second one if DOS fdisk gets
17 confused about extended/logical partitions starting past cylinder 1023. */
18 #define DOS_EXTENDED_PARTITION 5
19 #define LINUX_EXTENDED_PARTITION 0x85
20 #define WIN98_EXTENDED_PARTITION 0x0f
22 #define LINUX_SWAP_PARTITION 0x82
23 #define LINUX_RAID_PARTITION 0xfd /* autodetect RAID partition */
25 #ifdef CONFIG_SOLARIS_X86_PARTITION
26 #define SOLARIS_X86_PARTITION LINUX_SWAP_PARTITION
27 #endif
29 #define DM6_PARTITION 0x54 /* has DDO: use xlated geom & offset */
30 #define EZD_PARTITION 0x55 /* EZ-DRIVE */
31 #define DM6_AUX1PARTITION 0x51 /* no DDO: use xlated geom */
32 #define DM6_AUX3PARTITION 0x53 /* no DDO: use xlated geom */
34 struct partition {
35 unsigned char boot_ind; /* 0x80 - active */
36 unsigned char head; /* starting head */
37 unsigned char sector; /* starting sector */
38 unsigned char cyl; /* starting cylinder */
39 unsigned char sys_ind; /* What partition type */
40 unsigned char end_head; /* end head */
41 unsigned char end_sector; /* end sector */
42 unsigned char end_cyl; /* end cylinder */
43 unsigned int start_sect; /* starting sector counting from 0 */
44 unsigned int nr_sects; /* nr of sectors in partition */
45 } __attribute__((packed));
47 #ifdef __KERNEL__
48 # include <linux/devfs_fs_kernel.h>
50 struct hd_struct {
51 long start_sect;
52 long nr_sects;
53 devfs_handle_t de; /* primary (master) devfs entry */
56 #define GENHD_FL_REMOVABLE 1
58 struct gendisk {
59 int major; /* major number of driver */
60 const char *major_name; /* name of major driver */
61 int minor_shift; /* number of times minor is shifted to
62 get real minor */
63 int max_p; /* maximum partitions per device */
65 struct hd_struct *part; /* [indexed by minor] */
66 int *sizes; /* [idem], device size in blocks */
67 int nr_real; /* number of real devices */
69 void *real_devices; /* internal use */
70 struct gendisk *next;
71 struct block_device_operations *fops;
73 devfs_handle_t *de_arr; /* one per physical disc */
74 char *flags; /* one per physical disc */
76 #endif /* __KERNEL__ */
78 #ifdef CONFIG_SOLARIS_X86_PARTITION
80 #define SOLARIS_X86_NUMSLICE 8
81 #define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
83 struct solaris_x86_slice {
84 ushort s_tag; /* ID tag of partition */
85 ushort s_flag; /* permision flags */
86 daddr_t s_start; /* start sector no of partition */
87 long s_size; /* # of blocks in partition */
90 struct solaris_x86_vtoc {
91 unsigned long v_bootinfo[3]; /* info needed by mboot (unsupported) */
92 unsigned long v_sanity; /* to verify vtoc sanity */
93 unsigned long v_version; /* layout version */
94 char v_volume[8]; /* volume name */
95 ushort v_sectorsz; /* sector size in bytes */
96 ushort v_nparts; /* number of partitions */
97 unsigned long v_reserved[10]; /* free space */
98 struct solaris_x86_slice
99 v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
100 time_t timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */
101 char v_asciilabel[128]; /* for compatibility */
104 #endif /* CONFIG_SOLARIS_X86_PARTITION */
106 #ifdef CONFIG_BSD_DISKLABEL
108 * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il>
109 * updated by Marc Espie <Marc.Espie@openbsd.org>
111 #define FREEBSD_PARTITION 0xa5 /* FreeBSD Partition ID */
112 #define OPENBSD_PARTITION 0xa6 /* OpenBSD Partition ID */
113 #define NETBSD_PARTITION 0xa9 /* NetBSD Partition ID */
114 #define BSDI_PARTITION 0xb7 /* BSDI Partition ID */
116 /* Ours is not to wonder why.. */
117 #define BSD_PARTITION FREEBSD_PARTITION
119 /* check against BSD src/sys/sys/disklabel.h for consistency */
121 #define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */
122 #define BSD_MAXPARTITIONS 8
123 #define OPENBSD_MAXPARTITIONS 16
124 #define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */
125 struct bsd_disklabel {
126 __u32 d_magic; /* the magic number */
127 __s16 d_type; /* drive type */
128 __s16 d_subtype; /* controller/d_type specific */
129 char d_typename[16]; /* type name, e.g. "eagle" */
130 char d_packname[16]; /* pack identifier */
131 __u32 d_secsize; /* # of bytes per sector */
132 __u32 d_nsectors; /* # of data sectors per track */
133 __u32 d_ntracks; /* # of tracks per cylinder */
134 __u32 d_ncylinders; /* # of data cylinders per unit */
135 __u32 d_secpercyl; /* # of data sectors per cylinder */
136 __u32 d_secperunit; /* # of data sectors per unit */
137 __u16 d_sparespertrack; /* # of spare sectors per track */
138 __u16 d_sparespercyl; /* # of spare sectors per cylinder */
139 __u32 d_acylinders; /* # of alt. cylinders per unit */
140 __u16 d_rpm; /* rotational speed */
141 __u16 d_interleave; /* hardware sector interleave */
142 __u16 d_trackskew; /* sector 0 skew, per track */
143 __u16 d_cylskew; /* sector 0 skew, per cylinder */
144 __u32 d_headswitch; /* head switch time, usec */
145 __u32 d_trkseek; /* track-to-track seek, usec */
146 __u32 d_flags; /* generic flags */
147 #define NDDATA 5
148 __u32 d_drivedata[NDDATA]; /* drive-type specific information */
149 #define NSPARE 5
150 __u32 d_spare[NSPARE]; /* reserved for future use */
151 __u32 d_magic2; /* the magic number (again) */
152 __u16 d_checksum; /* xor of data incl. partitions */
154 /* filesystem and partition information: */
155 __u16 d_npartitions; /* number of partitions in following */
156 __u32 d_bbsize; /* size of boot area at sn0, bytes */
157 __u32 d_sbsize; /* max size of fs superblock, bytes */
158 struct bsd_partition { /* the partition table */
159 __u32 p_size; /* number of sectors in partition */
160 __u32 p_offset; /* starting sector */
161 __u32 p_fsize; /* filesystem basic fragment size */
162 __u8 p_fstype; /* filesystem type, see below */
163 __u8 p_frag; /* filesystem fragments per block */
164 __u16 p_cpg; /* filesystem cylinders per group */
165 } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
168 #endif /* CONFIG_BSD_DISKLABEL */
170 #ifdef CONFIG_UNIXWARE_DISKLABEL
172 * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
173 * and Krzysztof G. Baranowski <kgb@knm.org.pl>
176 #define UNIXWARE_PARTITION 0x63 /* Partition ID, same as */
177 /* GNU_HURD and SCO Unix */
178 #define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */
179 #define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */
180 #define UNIXWARE_NUMSLICE 16
181 #define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */
183 struct unixware_slice {
184 __u16 s_label; /* label */
185 __u16 s_flags; /* permission flags */
186 __u32 start_sect; /* starting sector */
187 __u32 nr_sects; /* number of sectors in slice */
190 struct unixware_disklabel {
191 __u32 d_type; /* drive type */
192 __u32 d_magic; /* the magic number */
193 __u32 d_version; /* version number */
194 char d_serial[12]; /* serial number of the device */
195 __u32 d_ncylinders; /* # of data cylinders per device */
196 __u32 d_ntracks; /* # of tracks per cylinder */
197 __u32 d_nsectors; /* # of data sectors per track */
198 __u32 d_secsize; /* # of bytes per sector */
199 __u32 d_part_start; /* # of first sector of this partition */
200 __u32 d_unknown1[12]; /* ? */
201 __u32 d_alt_tbl; /* byte offset of alternate table */
202 __u32 d_alt_len; /* byte length of alternate table */
203 __u32 d_phys_cyl; /* # of physical cylinders per device */
204 __u32 d_phys_trk; /* # of physical tracks per cylinder */
205 __u32 d_phys_sec; /* # of physical sectors per track */
206 __u32 d_phys_bytes; /* # of physical bytes per sector */
207 __u32 d_unknown2; /* ? */
208 __u32 d_unknown3; /* ? */
209 __u32 d_pad[8]; /* pad */
211 struct unixware_vtoc {
212 __u32 v_magic; /* the magic number */
213 __u32 v_version; /* version number */
214 char v_name[8]; /* volume name */
215 __u16 v_nslices; /* # of slices */
216 __u16 v_unknown1; /* ? */
217 __u32 v_reserved[10]; /* reserved */
218 struct unixware_slice
219 v_slice[UNIXWARE_NUMSLICE]; /* slice headers */
220 } vtoc;
222 }; /* 408 */
224 #endif /* CONFIG_UNIXWARE_DISKLABEL */
226 #ifdef __KERNEL__
227 extern struct gendisk *gendisk_head; /* linked list of disks */
229 char *disk_name (struct gendisk *hd, int minor, char *buf);
231 extern void devfs_register_partitions (struct gendisk *dev, int minor,
232 int unregister);
234 int get_hardsect_size(kdev_t dev);
237 * FIXME: this should use genhd->minor_shift, but that is slow to look up.
239 static inline unsigned int disk_index (kdev_t dev)
241 int major = MAJOR(dev);
242 int minor = MINOR(dev);
243 unsigned int index;
245 switch (major) {
246 case DAC960_MAJOR+0:
247 index = (minor & 0x00f8) >> 3;
248 break;
249 case SCSI_DISK0_MAJOR:
250 index = (minor & 0x00f0) >> 4;
251 break;
252 case IDE0_MAJOR: /* same as HD_MAJOR */
253 case XT_DISK_MAJOR:
254 index = (minor & 0x0040) >> 6;
255 break;
256 case IDE1_MAJOR:
257 index = ((minor & 0x0040) >> 6) + 2;
258 break;
259 default:
260 return 0;
262 return index;
265 #endif
267 #endif