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