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