Import 2.3.99pre9-1
[davej-history.git] / include / linux / genhd.h
blobc07a473d144423e715279c5b6a07b349d57b4a86
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 int type; /* currently RAID or normal */
54 devfs_handle_t de; /* primary (master) devfs entry */
57 #define GENHD_FL_REMOVABLE 1
59 struct gendisk {
60 int major; /* major number of driver */
61 const char *major_name; /* name of major driver */
62 int minor_shift; /* number of times minor is shifted to
63 get real minor */
64 int max_p; /* maximum partitions per device */
66 struct hd_struct *part; /* [indexed by minor] */
67 int *sizes; /* [idem], device size in blocks */
68 int nr_real; /* number of real devices */
70 void *real_devices; /* internal use */
71 struct gendisk *next;
72 struct block_device_operations *fops;
74 devfs_handle_t *de_arr; /* one per physical disc */
75 char *flags; /* one per physical disc */
77 #endif /* __KERNEL__ */
79 #ifdef CONFIG_SOLARIS_X86_PARTITION
81 #define SOLARIS_X86_NUMSLICE 8
82 #define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
84 struct solaris_x86_slice {
85 ushort s_tag; /* ID tag of partition */
86 ushort s_flag; /* permision flags */
87 daddr_t s_start; /* start sector no of partition */
88 long s_size; /* # of blocks in partition */
91 struct solaris_x86_vtoc {
92 unsigned long v_bootinfo[3]; /* info needed by mboot (unsupported) */
93 unsigned long v_sanity; /* to verify vtoc sanity */
94 unsigned long v_version; /* layout version */
95 char v_volume[8]; /* volume name */
96 ushort v_sectorsz; /* sector size in bytes */
97 ushort v_nparts; /* number of partitions */
98 unsigned long v_reserved[10]; /* free space */
99 struct solaris_x86_slice
100 v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
101 time_t timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */
102 char v_asciilabel[128]; /* for compatibility */
105 #endif /* CONFIG_SOLARIS_X86_PARTITION */
107 #ifdef CONFIG_BSD_DISKLABEL
109 * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il>
110 * updated by Marc Espie <Marc.Espie@openbsd.org>
112 #define FREEBSD_PARTITION 0xa5 /* FreeBSD Partition ID */
113 #define OPENBSD_PARTITION 0xa6 /* OpenBSD Partition ID */
114 #define NETBSD_PARTITION 0xa9 /* NetBSD Partition ID */
115 #define BSDI_PARTITION 0xb7 /* BSDI Partition ID */
117 /* Ours is not to wonder why.. */
118 #define BSD_PARTITION FREEBSD_PARTITION
120 /* check against BSD src/sys/sys/disklabel.h for consistency */
122 #define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */
123 #define BSD_MAXPARTITIONS 8
124 #define OPENBSD_MAXPARTITIONS 16
125 #define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */
126 struct bsd_disklabel {
127 __u32 d_magic; /* the magic number */
128 __s16 d_type; /* drive type */
129 __s16 d_subtype; /* controller/d_type specific */
130 char d_typename[16]; /* type name, e.g. "eagle" */
131 char d_packname[16]; /* pack identifier */
132 __u32 d_secsize; /* # of bytes per sector */
133 __u32 d_nsectors; /* # of data sectors per track */
134 __u32 d_ntracks; /* # of tracks per cylinder */
135 __u32 d_ncylinders; /* # of data cylinders per unit */
136 __u32 d_secpercyl; /* # of data sectors per cylinder */
137 __u32 d_secperunit; /* # of data sectors per unit */
138 __u16 d_sparespertrack; /* # of spare sectors per track */
139 __u16 d_sparespercyl; /* # of spare sectors per cylinder */
140 __u32 d_acylinders; /* # of alt. cylinders per unit */
141 __u16 d_rpm; /* rotational speed */
142 __u16 d_interleave; /* hardware sector interleave */
143 __u16 d_trackskew; /* sector 0 skew, per track */
144 __u16 d_cylskew; /* sector 0 skew, per cylinder */
145 __u32 d_headswitch; /* head switch time, usec */
146 __u32 d_trkseek; /* track-to-track seek, usec */
147 __u32 d_flags; /* generic flags */
148 #define NDDATA 5
149 __u32 d_drivedata[NDDATA]; /* drive-type specific information */
150 #define NSPARE 5
151 __u32 d_spare[NSPARE]; /* reserved for future use */
152 __u32 d_magic2; /* the magic number (again) */
153 __u16 d_checksum; /* xor of data incl. partitions */
155 /* filesystem and partition information: */
156 __u16 d_npartitions; /* number of partitions in following */
157 __u32 d_bbsize; /* size of boot area at sn0, bytes */
158 __u32 d_sbsize; /* max size of fs superblock, bytes */
159 struct bsd_partition { /* the partition table */
160 __u32 p_size; /* number of sectors in partition */
161 __u32 p_offset; /* starting sector */
162 __u32 p_fsize; /* filesystem basic fragment size */
163 __u8 p_fstype; /* filesystem type, see below */
164 __u8 p_frag; /* filesystem fragments per block */
165 __u16 p_cpg; /* filesystem cylinders per group */
166 } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
169 #endif /* CONFIG_BSD_DISKLABEL */
171 #ifdef CONFIG_UNIXWARE_DISKLABEL
173 * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
174 * and Krzysztof G. Baranowski <kgb@knm.org.pl>
177 #define UNIXWARE_PARTITION 0x63 /* Partition ID, same as */
178 /* GNU_HURD and SCO Unix */
179 #define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */
180 #define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */
181 #define UNIXWARE_NUMSLICE 16
182 #define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */
184 struct unixware_slice {
185 __u16 s_label; /* label */
186 __u16 s_flags; /* permission flags */
187 __u32 start_sect; /* starting sector */
188 __u32 nr_sects; /* number of sectors in slice */
191 struct unixware_disklabel {
192 __u32 d_type; /* drive type */
193 __u32 d_magic; /* the magic number */
194 __u32 d_version; /* version number */
195 char d_serial[12]; /* serial number of the device */
196 __u32 d_ncylinders; /* # of data cylinders per device */
197 __u32 d_ntracks; /* # of tracks per cylinder */
198 __u32 d_nsectors; /* # of data sectors per track */
199 __u32 d_secsize; /* # of bytes per sector */
200 __u32 d_part_start; /* # of first sector of this partition */
201 __u32 d_unknown1[12]; /* ? */
202 __u32 d_alt_tbl; /* byte offset of alternate table */
203 __u32 d_alt_len; /* byte length of alternate table */
204 __u32 d_phys_cyl; /* # of physical cylinders per device */
205 __u32 d_phys_trk; /* # of physical tracks per cylinder */
206 __u32 d_phys_sec; /* # of physical sectors per track */
207 __u32 d_phys_bytes; /* # of physical bytes per sector */
208 __u32 d_unknown2; /* ? */
209 __u32 d_unknown3; /* ? */
210 __u32 d_pad[8]; /* pad */
212 struct unixware_vtoc {
213 __u32 v_magic; /* the magic number */
214 __u32 v_version; /* version number */
215 char v_name[8]; /* volume name */
216 __u16 v_nslices; /* # of slices */
217 __u16 v_unknown1; /* ? */
218 __u32 v_reserved[10]; /* reserved */
219 struct unixware_slice
220 v_slice[UNIXWARE_NUMSLICE]; /* slice headers */
221 } vtoc;
223 }; /* 408 */
225 #endif /* CONFIG_UNIXWARE_DISKLABEL */
227 #ifdef __KERNEL__
228 extern struct gendisk *gendisk_head; /* linked list of disks */
230 char *disk_name (struct gendisk *hd, int minor, char *buf);
232 extern void devfs_register_partitions (struct gendisk *dev, int minor,
233 int unregister);
235 int get_hardsect_size(kdev_t dev);
238 * FIXME: this should use genhd->minor_shift, but that is slow to look up.
240 static inline unsigned int disk_index (kdev_t dev)
242 int major = MAJOR(dev);
243 int minor = MINOR(dev);
244 unsigned int index;
246 switch (major) {
247 case DAC960_MAJOR+0:
248 index = (minor & 0x00f8) >> 3;
249 break;
250 case SCSI_DISK0_MAJOR:
251 index = (minor & 0x00f0) >> 4;
252 break;
253 case IDE0_MAJOR: /* same as HD_MAJOR */
254 case XT_DISK_MAJOR:
255 index = (minor & 0x0040) >> 6;
256 break;
257 case IDE1_MAJOR:
258 index = ((minor & 0x0040) >> 6) + 2;
259 break;
260 default:
261 return 0;
263 return index;
266 #endif
268 #endif