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