xref: /original-bsd/sys/sys/disklabel.h (revision 0a83ae40)
1 /*
2  * Copyright (c) 1987 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  *
12  *	@(#)disklabel.h	7.7 (Berkeley) 12/18/87
13  */
14 
15 /*
16  * Disk description table, see disktab(5)
17  */
18 #define	DISKTAB		"/etc/disktab"
19 
20 /*
21  * Each disk has a label which includes information about the hardware
22  * disk geometry, filesystem partitions, and drive specific information.
23  * The label is in block 0 or 1, possibly offset from the beginning
24  * to leave room for a bootstrap, etc.
25  */
26 
27 #define LABELSECTOR	0			/* sector containing label */
28 #define LABELOFFSET	64			/* offset of label in sector */
29 #define DISKMAGIC	((u_long) 0x82564557)	/* The disk magic number */
30 #ifndef MAXPARTITIONS
31 #define	MAXPARTITIONS	8
32 #endif
33 
34 
35 #ifndef LOCORE
36 struct disklabel {
37 	u_long	d_magic;		/* the magic number */
38 	short	d_type;			/* drive type */
39 	short	d_subtype;		/* controller/d_type specific */
40 	char	d_typename[16];		/* type name, e.g. "eagle" */
41 	char	d_name[16];		/* pack identifier */
42 
43 			/* disk geometry: */
44 	u_long	d_secsize;		/* # of bytes per sector */
45 	u_long	d_nsectors;		/* # of data sectors per track */
46 	u_long	d_ntracks;		/* # of tracks per cylinder */
47 	u_long	d_ncylinders;		/* # of data cylinders per unit */
48 	u_long	d_secpercyl;		/* # of data sectors per cylinder */
49 	u_long	d_secperunit;		/* # of data sectors per unit */
50 	/*
51 	 * Spares (bad sector replacements) below
52 	 * are not counted in d_nsectors or d_secpercyl.
53 	 * Spare sectors are assumed to be physical sectors
54 	 * which occupy space at the end of each track and/or cylinder.
55 	 */
56 	u_short	d_sparespertrack;	/* # of spare sectors per track */
57 	u_short	d_sparespercyl;		/* # of spare sectors per cylinder */
58 	/*
59 	 * Alternate cylinders include maintenance, replacement,
60 	 * configuration description areas, etc.
61 	 */
62 	u_long	d_acylinders;		/* # of alt. cylinders per unit */
63 
64 			/* hardware characteristics: */
65 	/*
66 	 * d_interleave, d_trackskew and d_cylskew describe perturbations
67 	 * in the media format used to compensate for a slow controller.
68 	 * Interleave is physical sector interleave, set up by the formatter
69 	 * or controller when formatting.  When interleaving is in use,
70 	 * logically adjacent sectors are not physically contiguous,
71 	 * but instead are separated by some number of sectors.
72 	 * It is specified as the ratio of physical sectors traversed
73 	 * per logical sector.  Thus an interleave of 1:1 implies contiguous
74 	 * layout, while 2:1 implies that logical sector 0 is separated
75 	 * by one sector from logical sector 1.
76 	 * d_trackskew is the offset of sector 0 on track N
77 	 * relative to sector 0 on track N-1 on the same cylinder.
78 	 * Finally, d_cylskew is the offset of sector 0 on cylinder N
79 	 * relative to sector 0 on cylinder N-1.
80 	 */
81 	u_short	d_rpm;			/* rotational speed */
82 	u_short	d_interleave;		/* hardware sector interleave */
83 	u_short	d_trackskew;		/* sector 0 skew, per track */
84 	u_short	d_cylskew;		/* sector 0 skew, per cylinder */
85 	u_long	d_headswitch;		/* head switch time, usec */
86 	u_long	d_trkseek;		/* track-to-track seek, usec */
87 	u_long	d_flags;		/* generic flags */
88 #define NDDATA 5
89 	u_long	d_drivedata[NDDATA];	/* drive-type specific information */
90 #define NSPARE 5
91 	u_long	d_spare[NSPARE];	/* reserved for future use */
92 	u_long	d_magic2;		/* the magic number (again) */
93 	u_short	d_checksum;		/* xor of data incl. partitions */
94 
95 			/* filesystem and partition information: */
96 	u_short	d_npartitions;		/* number of partitions in following */
97 	u_long	d_bbsize;		/* size of boot area at sn0, bytes */
98 	u_long	d_sbsize;		/* max size of fs superblock, bytes */
99 	struct	partition {		/* the partition table */
100 		u_long	p_size;		/* number of sectors in partition */
101 		u_long	p_offset;	/* starting sector */
102 		u_long	p_fsize;	/* filesystem basic fragment size */
103 		u_char	p_fstype;	/* filesystem type, see below */
104 		u_char	p_frag;		/* filesystem fragments per block */
105 		u_short	p_cpg;		/* filesystem cylinders per group */
106 	} d_partitions[MAXPARTITIONS];	/* actually may be more */
107 };
108 #else LOCORE
109 	/*
110 	 * offsets for asm boot files.
111 	 */
112 	.set	d_secsize,40
113 	.set	d_nsectors,44
114 	.set	d_ntracks,48
115 	.set	d_ncylinders,52
116 	.set	d_secpercyl,56
117 	.set	d_secperunit,60
118 	.set	d_end_,276		/* size of disk label */
119 #endif LOCORE
120 
121 /* d_type values: */
122 #define	DTYPE_SMD		1		/* SMD, XSMD; VAX hp/up */
123 #define	DTYPE_MSCP		2		/* MSCP */
124 #define	DTYPE_DEC		3		/* other DEC (rk, rl) */
125 #define	DTYPE_SCSI		4		/* SCSI */
126 #define	DTYPE_ESDI		5		/* ESDI interface */
127 #define	DTYPE_ST506		6		/* ST506 etc. */
128 #define	DTYPE_FLOPPY		10		/* floppy */
129 
130 #ifdef DKTYPENAMES
131 static char *dktypenames[] = {
132 	"unknown",
133 	"SMD",
134 	"MSCP",
135 	"old DEC",
136 	"SCSI",
137 	"ESDI",
138 	"type 6",
139 	"type 7",
140 	"type 8",
141 	"type 9",
142 	"floppy",
143 	0
144 };
145 #define DKMAXTYPES	(sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
146 #endif
147 
148 /*
149  * Filesystem type and version.
150  * Used to interpret other filesystem-specific
151  * per-partition information.
152  */
153 #define	FS_UNUSED	0		/* unused */
154 #define	FS_SWAP		1		/* swap */
155 #define	FS_V6		2		/* Sixth Edition */
156 #define	FS_V7		3		/* Seventh Edition */
157 #define	FS_SYSV		4		/* System V */
158 #define	FS_V71K		5		/* V7 with 1K blocks (4.1, 2.9) */
159 #define	FS_V8		6		/* Eighth Edition, 4K blocks */
160 #define	FS_BSDFFS	7		/* 4.2BSD fast file system */
161 
162 #ifdef	DKTYPENAMES
163 static char *fstypenames[] = {
164 	"unused",
165 	"swap",
166 	"Version 6",
167 	"Version 7",
168 	"System V",
169 	"4.1BSD",
170 	"Eighth Edition",
171 	"4.2BSD",
172 	0
173 };
174 #define FSMAXTYPES	(sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
175 #endif
176 
177 /*
178  * flags shared by various drives:
179  */
180 #define		D_REMOVABLE	0x01		/* removable media */
181 #define		D_ECC		0x02		/* supports ECC */
182 #define		D_BADSECT	0x04		/* supports bad sector forw. */
183 #define		D_RAMDISK	0x08		/* disk emulator */
184 #define		D_CHAIN		0x10		/* can do back-back transfers */
185 
186 /*
187  * Drive data for SMD.
188  */
189 #define	d_smdflags	d_drivedata[0]
190 #define		D_SSE		0x1		/* supports skip sectoring */
191 #define	d_mindist	d_drivedata[1]
192 #define	d_maxdist	d_drivedata[2]
193 #define	d_sdist		d_drivedata[3]
194 
195 /*
196  * Drive data for ST506.
197  */
198 #define d_precompcyl	d_drivedata[0]
199 #define d_gap3		d_drivedata[1]		/* used only when formatting */
200 
201 #ifndef LOCORE
202 /*
203  * Structure used to perform a format
204  * or other raw operation, returning data
205  * and/or register values.
206  * Register identification and format
207  * are device- and driver-dependent.
208  */
209 struct format_op {
210 	char	*df_buf;
211 	int	df_count;		/* value-result */
212 	daddr_t	df_startblk;
213 	int	df_reg[8];		/* result */
214 };
215 
216 /*
217  * Structure used internally to retrieve
218  * information about a partition on a disk.
219  */
220 struct partinfo {
221 	struct disklabel *disklab;
222 	struct partition *part;
223 };
224 
225 /*
226  * Disk-specific ioctls.
227  */
228 		/* get and set disklabel; last form used internally */
229 #define DIOCGDINFO	_IOR('d', 101, struct disklabel)/* get */
230 #define DIOCSDINFO	_IOW('d', 102, struct disklabel)/* set */
231 #define DIOCWDINFO	_IOW('d', 103, struct disklabel)/* set and write back */
232 #define DIOCGPART	_IOW('d', 104, struct partinfo)	/* get partition */
233 
234 /* do format operation, read or write */
235 #define DIOCRFORMAT	_IOWR('d', 105, struct format_op)
236 #define DIOCWFORMAT	_IOWR('d', 106, struct format_op)
237 
238 #define DIOCSSTEP	_IOW('d', 107, int)	/* set step rate */
239 #define DIOCSRETRIES	_IOW('d', 108, int)	/* set # of retries */
240 
241 #endif LOCORE
242 
243 #if !defined(KERNEL) && !defined(LOCORE)
244 struct	disklabel *getdiskbyname();
245 #endif
246