199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1987, 1988, 1993
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 4. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Disk description table, see disktab(5)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Each disk has a label which includes information about the hardware
199767f8919635c4928607450d9e0abb932109ceToomas Soome * disk geometry, filesystem partitions, and drive specific information.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The label is in block 0 or 1, possibly offset from the beginning
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to leave room for a bootstrap, etc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* XXX these should be defined per controller (or drive) elsewhere, not here! */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if defined(__i386__) || defined(__amd64__) || defined(__arm__) || \
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LABELSECTOR 1 /* sector containing label */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LABELOFFSET 0 /* offset of label in sector */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Size of bootblock area in sector-size neutral bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LABEL_PART 2 /* partition containing label */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define RAW_PART 2 /* partition containing whole disk */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define SWAP_PART 1 /* partition normally containing swap */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t d_subtype; /* controller/d_type specific */
199767f8919635c4928607450d9e0abb932109ceToomas Soome char d_typename[16]; /* type name, e.g. "eagle" */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* disk geometry: */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_secsize; /* # of bytes per sector */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_nsectors; /* # of data sectors per track */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_ntracks; /* # of tracks per cylinder */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_ncylinders; /* # of data cylinders per unit */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_secpercyl; /* # of data sectors per cylinder */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_secperunit; /* # of data sectors per unit */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Spares (bad sector replacements) below are not counted in
199767f8919635c4928607450d9e0abb932109ceToomas Soome * d_nsectors or d_secpercyl. Spare sectors are assumed to
199767f8919635c4928607450d9e0abb932109ceToomas Soome * be physical sectors which occupy space at the end of each
199767f8919635c4928607450d9e0abb932109ceToomas Soome * track and/or cylinder.
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t d_sparespertrack; /* # of spare sectors per track */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Alternate cylinders include maintenance, replacement, configuration
199767f8919635c4928607450d9e0abb932109ceToomas Soome * description areas, etc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_acylinders; /* # of alt. cylinders per unit */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* hardware characteristics: */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * d_interleave, d_trackskew and d_cylskew describe perturbations
199767f8919635c4928607450d9e0abb932109ceToomas Soome * in the media format used to compensate for a slow controller.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Interleave is physical sector interleave, set up by the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * formatter or controller when formatting. When interleaving is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * in use, logically adjacent sectors are not physically
199767f8919635c4928607450d9e0abb932109ceToomas Soome * contiguous, but instead are separated by some number of
199767f8919635c4928607450d9e0abb932109ceToomas Soome * sectors. It is specified as the ratio of physical sectors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * traversed per logical sector. Thus an interleave of 1:1
199767f8919635c4928607450d9e0abb932109ceToomas Soome * implies contiguous layout, while 2:1 implies that logical
199767f8919635c4928607450d9e0abb932109ceToomas Soome * sector 0 is separated by one sector from logical sector 1.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * d_trackskew is the offset of sector 0 on track N relative to
199767f8919635c4928607450d9e0abb932109ceToomas Soome * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
199767f8919635c4928607450d9e0abb932109ceToomas Soome * is the offset of sector 0 on cylinder N relative to sector 0
199767f8919635c4928607450d9e0abb932109ceToomas Soome * on cylinder N-1.
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t d_interleave; /* hardware sector interleave */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t d_trackskew; /* sector 0 skew, per track */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t d_cylskew; /* sector 0 skew, per cylinder */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_headswitch; /* head switch time, usec */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_trkseek; /* track-to-track seek, usec */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_spare[NSPARE]; /* reserved for future use */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_magic2; /* the magic number (again) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t d_checksum; /* xor of data incl. partitions */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* filesystem and partition information: */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t d_npartitions; /* number of partitions in following */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_bbsize; /* size of boot area at sn0, bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t d_sbsize; /* max size of fs superblock, bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t p_size; /* number of sectors in partition */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int32_t p_fsize; /* filesystem basic fragment size */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int8_t p_fstype; /* filesystem type, see below */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int8_t p_frag; /* filesystem fragments per block */
199767f8919635c4928607450d9e0abb932109ceToomas Soome u_int16_t p_cpg; /* filesystem cylinders per group */
199767f8919635c4928607450d9e0abb932109ceToomas Soome } d_partitions[MAXPARTITIONS]; /* actually may be more */
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCTASSERT(sizeof(struct disklabel) == 148 + MAXPARTITIONS * 16);
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic __inline u_int16_t dkcksum(struct disklabel *lp);
199767f8919635c4928607450d9e0abb932109ceToomas Soome end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions];
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* d_type values: */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Filesystem type and version.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Used to interpret other filesystem-specific
199767f8919635c4928607450d9e0abb932109ceToomas Soome * per-partition information.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_BSDFFS 7 /* 4.2BSD fast filesystem */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_BSDLFS 9 /* 4.4BSD log-structured filesystem */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_OTHER 10 /* in use, but unknown/unsupported */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_HPFS 11 /* OS/2 high-performance filesystem */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_BOOT 13 /* partition contains bootstrap */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_FILECORE 16 /* Acorn Filecore Filing System */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_CCD 20 /* concatenated disk component */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_HAMMER 22 /* DragonFlyBSD Hammer FS */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_HAMMER2 23 /* DragonFlyBSD Hammer2 FS */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_EFS 26 /* SGI's Extent File system */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FS_NANDFS 30 /* FreeBSD nandfs (NiLFS derived) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome "Version 6",
199767f8919635c4928607450d9e0abb932109ceToomas Soome "Version 7",
199767f8919635c4928607450d9e0abb932109ceToomas Soome "Eighth Edition",
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * flags shared by various drives:
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define D_BADSECT 0x04 /* supports bad sector forw. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define D_CHAIN 0x10 /* can do back-back transfers */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * NB: <sys/disk.h> defines ioctls from 'd'/128 and up.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Functions for proper encoding/decoding of struct disklabel into/from
199767f8919635c4928607450d9e0abb932109ceToomas Soome * bytestring.
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid bsd_partition_le_dec(u_char *ptr, struct partition *d);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint bsd_disklabel_le_dec(u_char *ptr, struct disklabel *d, int maxpart);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid bsd_partition_le_enc(u_char *ptr, struct partition *d);
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid bsd_disklabel_le_enc(u_char *ptr, struct disklabel *d);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_SYS_DISKLABEL_H_ */