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