1: /*
   2:  * Copyright (c) 1987, 1988, 1993
   3:  *	The Regents of the University of California.  All rights reserved.
   4:  *
   5:  * Redistribution and use in source and binary forms, with or without
   6:  * modification, are permitted provided that the following conditions
   7:  * are met:
   8:  * 1. Redistributions of source code must retain the above copyright
   9:  *    notice, this list of conditions and the following disclaimer.
  10:  * 2. Redistributions in binary form must reproduce the above copyright
  11:  *    notice, this list of conditions and the following disclaimer in the
  12:  *    documentation and/or other materials provided with the distribution.
  13:  * 3. All advertising materials mentioning features or use of this software
  14:  *    must display the following acknowledgement:
  15:  *	This product includes software developed by the University of
  16:  *	California, Berkeley and its contributors.
  17:  * 4. Neither the name of the University nor the names of its contributors
  18:  *    may be used to endorse or promote products derived from this software
  19:  *    without specific prior written permission.
  20:  *
  21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31:  * SUCH DAMAGE.
  32:  *
  33:  *	@(#)disklabel.h	8.1.1 (2.11BSD) 1995/04/13
  34:  */
  35: 
  36: #ifndef _SYS_DISKLABEL_H_
  37: #define _SYS_DISKLABEL_H_
  38: 
  39: /*
  40:  * Disk description table, see disktab(5)
  41:  */
  42: #define _PATH_DISKTAB   "/etc/disktab"
  43: #define DISKTAB     "/etc/disktab"      /* deprecated */
  44: 
  45: /*
  46:  * Each disk has a label which includes information about the hardware
  47:  * disk geometry, filesystem partitions, and drive specific information.
  48:  * The label is in block 0 or 1, possibly offset from the beginning
  49:  * to leave room for a bootstrap, etc.
  50:  */
  51: 
  52: /* XXX these should be defined per controller (or drive) elsewhere, not here! */
  53: #define LABELSECTOR 1           /* sector containing label */
  54: #define LABELOFFSET 0           /* offset of label in sector */
  55: 
  56: #define DISKMAGIC   ((u_long) 0x82564557)   /* The disk magic number */
  57: #define MAXPARTITIONS   8
  58: 
  59: /*
  60:  * 2.11BSD's disklabels are different than 4.4BSD for a couple reasons:
  61:  *
  62:  *	1) D space is precious in the 2.11 kernel.  Many of the fields do
  63:  *	   not need to be a 'long' (or even a 'short'), a 'short' (or 'char')
  64:  *	   is more than adequate.  If anyone ever ports the FFS to a PDP11
  65:  *	   changing the label format will be the least of the problems.
  66:  *
  67:  *	2) There is no need to support a bootblock more than 512 bytes long.
  68:  *	   The hardware (disk bootroms) only read the first sector, thus the
  69:  *	   label is always at sector 1 (the second half of the first filesystem
  70:  *	   block).
  71:  *
  72:  * Almost all of the fields have been retained but with reduced sizes.  This
  73:  * is for future expansion and to ease the porting of the various utilities
  74:  * which use the disklabel structure.  The 2.11 kernel uses very little other
  75:  * than the partition tables.  Indeed only the partition tables are resident
  76:  * in the kernel address space, the actual label block is allocated external to
  77:  * the kernel and mapped in as needed.
  78: */
  79: 
  80: struct disklabel {
  81:     u_long  d_magic;        /* the magic number */
  82:     u_char  d_type;         /* drive type */
  83:     u_char  d_subtype;      /* controller/d_type specific */
  84:     char    d_typename[16];     /* type name, e.g. "eagle" */
  85:     /*
  86: 	 * d_packname contains the pack identifier and is returned when
  87: 	 * the disklabel is read off the disk or in-core copy.
  88: 	 * d_boot0 is the (optional) name of the primary (block 0) bootstrap
  89: 	 * as found in /mdec.  This is returned when using
  90: 	 * getdiskbyname(3) to retrieve the values from /etc/disktab.
  91: 	 */
  92: #if defined(KERNEL) || defined(STANDALONE)
  93:     char    d_packname[16];         /* pack identifier */
  94: #else
  95:     union {
  96:         char    un_d_packname[16];  /* pack identifier */
  97:         char    *un_d_boot0;        /* primary bootstrap name */
  98:     } d_un;
  99: #define d_packname  d_un.un_d_packname
 100: #define d_boot0     d_un.un_d_boot0
 101: #endif	/* ! KERNEL or STANDALONE */
 102:             /* disk geometry: */
 103:     u_short d_secsize;      /* # of bytes per sector */
 104:     u_short d_nsectors;     /* # of data sectors per track */
 105:     u_short d_ntracks;      /* # of tracks per cylinder */
 106:     u_short d_ncylinders;       /* # of data cylinders per unit */
 107:     u_short d_secpercyl;        /* # of data sectors per cylinder */
 108:     u_long  d_secperunit;       /* # of data sectors per unit */
 109:     /*
 110: 	 * Spares (bad sector replacements) below
 111: 	 * are not counted in d_nsectors or d_secpercyl.
 112: 	 * Spare sectors are assumed to be physical sectors
 113: 	 * which occupy space at the end of each track and/or cylinder.
 114: 	 */
 115:     u_short d_sparespertrack;   /* # of spare sectors per track */
 116:     u_short d_sparespercyl;     /* # of spare sectors per cylinder */
 117:     /*
 118: 	 * Alternate cylinders include maintenance, replacement,
 119: 	 * configuration description areas, etc.
 120: 	 */
 121:     u_short d_acylinders;       /* # of alt. cylinders per unit */
 122: 
 123:             /* hardware characteristics: */
 124:     /*
 125: 	 * d_interleave, d_trackskew and d_cylskew describe perturbations
 126: 	 * in the media format used to compensate for a slow controller.
 127: 	 * Interleave is physical sector interleave, set up by the formatter
 128: 	 * or controller when formatting.  When interleaving is in use,
 129: 	 * logically adjacent sectors are not physically contiguous,
 130: 	 * but instead are separated by some number of sectors.
 131: 	 * It is specified as the ratio of physical sectors traversed
 132: 	 * per logical sector.  Thus an interleave of 1:1 implies contiguous
 133: 	 * layout, while 2:1 implies that logical sector 0 is separated
 134: 	 * by one sector from logical sector 1.
 135: 	 * d_trackskew is the offset of sector 0 on track N
 136: 	 * relative to sector 0 on track N-1 on the same cylinder.
 137: 	 * Finally, d_cylskew is the offset of sector 0 on cylinder N
 138: 	 * relative to sector 0 on cylinder N-1.
 139: 	 */
 140:     u_short d_rpm;          /* rotational speed */
 141:     u_char  d_interleave;       /* hardware sector interleave */
 142:     u_char  d_trackskew;        /* sector 0 skew, per track */
 143:     u_char  d_cylskew;      /* sector 0 skew, per cylinder */
 144:     u_char  d_headswitch;       /* head swith time, usec */
 145:     u_short d_trkseek;      /* track-to-track seek, msec */
 146:     u_short d_flags;        /* generic flags */
 147: #define NDDATA 5
 148:     u_long  d_drivedata[NDDATA];    /* drive-type specific information */
 149: #define NSPARE 5
 150:     u_long  d_spare[NSPARE];    /* reserved for future use */
 151:     u_long  d_magic2;       /* the magic number (again) */
 152:     u_short d_checksum;     /* xor of data incl. partitions */
 153: 
 154:             /* filesystem and partition information: */
 155:     u_short d_npartitions;      /* number of partitions in following */
 156:     u_short d_bbsize;       /* size of boot area at sn0, bytes */
 157:     u_short d_sbsize;       /* max size of fs superblock, bytes */
 158:     struct  partition {     /* the partition table */
 159:         u_long  p_size;     /* number of sectors in partition */
 160:         u_long  p_offset;   /* starting sector */
 161:         u_short p_fsize;    /* filesystem basic fragment size */
 162:         u_char  p_fstype;   /* filesystem type, see below */
 163:         u_char  p_frag;     /* filesystem fragments per block */
 164:     } d_partitions[MAXPARTITIONS];  /* actually may be more */
 165: };
 166: 
 167: /* d_type values: */
 168: #define DTYPE_SMD       1       /* SMD, XSMD; VAX hp/up */
 169: #define DTYPE_MSCP      2       /* MSCP */
 170: #define DTYPE_DEC       3       /* other DEC (rk, rl) */
 171: #define DTYPE_SCSI      4       /* SCSI */
 172: #define DTYPE_ESDI      5       /* ESDI interface */
 173: #define DTYPE_ST506     6       /* ST506 etc. */
 174: #define DTYPE_FLOPPY        7       /* floppy */
 175: 
 176: #ifdef DKTYPENAMES
 177: static char *dktypenames[] = {
 178:     "unknown",
 179:     "SMD",
 180:     "MSCP",
 181:     "old DEC",
 182:     "SCSI",
 183:     "ESDI",
 184:     "ST506",
 185:     "floppy",
 186:     0
 187: };
 188: #define DKMAXTYPES  (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
 189: #endif
 190: 
 191: /*
 192:  * Filesystem type and version.
 193:  * Used to interpret other filesystem-specific
 194:  * per-partition information.
 195:  */
 196: #define FS_UNUSED   0       /* unused */
 197: #define FS_SWAP     1       /* swap */
 198: #define FS_V6       2       /* Sixth Edition */
 199: #define FS_V7       3       /* Seventh Edition */
 200: #define FS_SYSV     4       /* System V */
 201: /*
 202:  * 2.11BSD uses type 5 filesystems even though block numbers are 4 bytes
 203:  * (rather than the packed 3 byte format) and the directory structure is
 204:  * that of 4.3BSD (long filenames).
 205: */
 206: #define FS_V71K     5       /* V7 with 1K blocks (4.1, 2.9, 2.11) */
 207: #define FS_V8       6       /* Eighth Edition, 4K blocks */
 208: #define FS_BSDFFS   7       /* 4.2BSD fast file system */
 209: #define FS_MSDOS    8       /* MSDOS file system */
 210: #define FS_BSDLFS   9       /* 4.4BSD log-structured file system */
 211: #define FS_OTHER    10      /* in use, but unknown/unsupported */
 212: #define FS_HPFS     11      /* OS/2 high-performance file system */
 213: #define FS_ISO9660  12      /* ISO 9660, normally CD-ROM */
 214: 
 215: #ifdef  DKTYPENAMES
 216: static char *fstypenames[] = {
 217:     "unused",
 218:     "swap",
 219:     "Version 6",
 220:     "Version 7",
 221:     "System V",
 222:     "2.11BSD",
 223:     "Eighth Edition",
 224:     "4.2BSD",
 225:     "MSDOS",
 226:     "4.4LFS",
 227:     "unknown",
 228:     "HPFS",
 229:     "ISO9660",
 230:     0
 231: };
 232: #define FSMAXTYPES  (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
 233: #endif
 234: 
 235: /*
 236:  * flags shared by various drives:
 237:  */
 238: #define     D_REMOVABLE 0x01        /* removable media */
 239: #define     D_ECC       0x02        /* supports ECC */
 240: #define     D_BADSECT   0x04        /* supports bad sector forw. */
 241: #define     D_RAMDISK   0x08        /* disk emulator */
 242: 
 243: /*
 244:  * Structure used to perform a format
 245:  * or other raw operation, returning data
 246:  * and/or register values.
 247:  * Register identification and format
 248:  * are device- and driver-dependent.
 249:  */
 250: struct format_op {
 251:     char    *df_buf;
 252:     int df_count;       /* value-result */
 253:     daddr_t df_startblk;
 254:     int df_reg[8];      /* result */
 255: };
 256: 
 257: /*
 258:  * Structure used internally to retrieve
 259:  * information about a partition on a disk.
 260:  */
 261: struct partinfo {
 262:     struct disklabel *disklab;
 263:     struct partition *part;
 264: };
 265: 
 266: /*
 267:  * Disk-specific ioctls.
 268:  */
 269:         /* get and set disklabel; DIOCGPART used internally */
 270: #define DIOCGDINFO  _IOR(d, 101, struct disklabel)  /* get */
 271: #define DIOCSDINFO  _IOW(d, 102, struct disklabel)  /* set */
 272: #define DIOCWDINFO  _IOW(d, 103, struct disklabel)  /* set, update disk */
 273: #define DIOCGPART   _IOW(d, 104, struct partinfo)   /* get partition */
 274: 
 275: /* do format operation, read or write */
 276: #define DIOCRFORMAT _IOWR(d, 105, struct format_op)
 277: #define DIOCWFORMAT _IOWR(d, 106, struct format_op)
 278: 
 279: #define DIOCSSTEP   _IOW(d, 107, int)   /* set step rate */
 280: #define DIOCSRETRIES    _IOW(d, 108, int)   /* set # of retries */
 281: #define DIOCWLABEL  _IOW(d, 109, int)   /* write en/disable label */
 282: 
 283: #define DIOCSBAD    _IOW(d, 110, struct dkbad)  /* set kernel dkbad */
 284: 
 285: #ifndef KERNEL
 286: struct disklabel *getdiskbyname();
 287: #endif
 288: 
 289: #if defined(KERNEL) && !defined(SUPERVISOR)
 290: memaddr disklabelalloc();
 291: #define LABELDESC   (((btoc(sizeof (struct disklabel)) - 1) << 8) | RW)
 292: #endif
 293: 
 294: #endif	/* !_SYS_DISKLABEL_H_ */

Defined variables

dktypenames defined in line 177; used 2 times
  • in line 188(2)
fstypenames defined in line 216; used 2 times
  • in line 232(2)

Defined struct's

disklabel defined in line 80; used 224 times
format_op defined in line 250; never used

Defined macros

DIOCGPART defined in line 273; used 2 times
DIOCRFORMAT defined in line 276; never used
DIOCSBAD defined in line 283; never used
DIOCSDINFO defined in line 271; used 1 times
DIOCSRETRIES defined in line 280; never used
DIOCSSTEP defined in line 279; never used
DIOCWDINFO defined in line 272; used 1 times
DIOCWFORMAT defined in line 277; never used
DIOCWLABEL defined in line 281; used 4 times
DISKTAB defined in line 43; never used
DTYPE_ESDI defined in line 172; never used
DTYPE_FLOPPY defined in line 174; never used
DTYPE_MSCP defined in line 169; used 2 times
DTYPE_SCSI defined in line 171; never used
DTYPE_SMD defined in line 168; used 2 times
DTYPE_ST506 defined in line 173; never used
D_RAMDISK defined in line 241; used 1 times
FS_BSDFFS defined in line 208; never used
FS_BSDLFS defined in line 210; never used
FS_HPFS defined in line 212; never used
FS_ISO9660 defined in line 213; never used
FS_MSDOS defined in line 209; never used
FS_OTHER defined in line 211; never used
FS_SYSV defined in line 200; never used
FS_V6 defined in line 198; never used
FS_V7 defined in line 199; never used
FS_V8 defined in line 207; never used
LABELOFFSET defined in line 54; used 1 times
NSPARE defined in line 149; used 1 times
_PATH_DISKTAB defined in line 42; used 3 times
_SYS_DISKLABEL_H_ defined in line 37; used 1 times
  • in line 36

Usage of this include

Last modified: 1995-05-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4793
Valid CSS Valid XHTML 1.0 Strict