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 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.8 (Berkeley) 02/08/88 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 /* 42 * d_packname contains the pack identifier and is returned when 43 * the disklabel is read off the disk or in-core copy. 44 * d_boot0 and d_boot1 are the (optional) names of the 45 * primary (block 0) and secondary (block 1-15) bootstraps 46 * as found in /usr/mdec. These are returned when using 47 * getdiskbyname(3) to retrieve the values from /etc/disktab. 48 */ 49 union { 50 char un_d_packname[16]; /* pack identifier */ 51 struct { 52 char *un_d_boot0; /* primary bootstrap name */ 53 char *un_d_boot1; /* secondary bootstrap name */ 54 } un_b; 55 } d_un; 56 #define d_packname d_un.un_d_packname 57 #define d_boot0 d_un.un_b.un_d_boot0 58 #define d_boot1 d_un.un_b.un_d_boot1 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 #ifndef LOCORE 218 /* 219 * Structure used to perform a format 220 * or other raw operation, returning data 221 * and/or register values. 222 * Register identification and format 223 * are device- and driver-dependent. 224 */ 225 struct format_op { 226 char *df_buf; 227 int df_count; /* value-result */ 228 daddr_t df_startblk; 229 int df_reg[8]; /* result */ 230 }; 231 232 /* 233 * Structure used internally to retrieve 234 * information about a partition on a disk. 235 */ 236 struct partinfo { 237 struct disklabel *disklab; 238 struct partition *part; 239 }; 240 241 /* 242 * Disk-specific ioctls. 243 */ 244 /* get and set disklabel; DIOCGPART used internally */ 245 #define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */ 246 #define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */ 247 #define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */ 248 #define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ 249 250 /* do format operation, read or write */ 251 #define DIOCRFORMAT _IOWR('d', 105, struct format_op) 252 #define DIOCWFORMAT _IOWR('d', 106, struct format_op) 253 254 #define DIOCSSTEP _IOW('d', 107, int) /* set step rate */ 255 #define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */ 256 #define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ 257 258 #endif LOCORE 259 260 #if !defined(KERNEL) && !defined(LOCORE) 261 struct disklabel *getdiskbyname(); 262 #endif 263