disklabel.h revision 84587
16059Samurai/* 26059Samurai * Copyright (c) 1987, 1988, 1993 36059Samurai * The Regents of the University of California. All rights reserved. 46059Samurai * 56059Samurai * Redistribution and use in source and binary forms, with or without 66059Samurai * modification, are permitted provided that the following conditions 76059Samurai * are met: 86059Samurai * 1. Redistributions of source code must retain the above copyright 96059Samurai * notice, this list of conditions and the following disclaimer. 106059Samurai * 2. Redistributions in binary form must reproduce the above copyright 116059Samurai * notice, this list of conditions and the following disclaimer in the 126059Samurai * documentation and/or other materials provided with the distribution. 136059Samurai * 3. All advertising materials mentioning features or use of this software 146059Samurai * must display the following acknowledgement: 156059Samurai * This product includes software developed by the University of 166059Samurai * California, Berkeley and its contributors. 176059Samurai * 4. Neither the name of the University nor the names of its contributors 186059Samurai * may be used to endorse or promote products derived from this software 196059Samurai * without specific prior written permission. 2047695Sbrian * 218857Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 226059Samurai * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2346686Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2446686Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 256059Samurai * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2630715Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 276059Samurai * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2829048Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 296059Samurai * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 306059Samurai * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 316059Samurai * SUCH DAMAGE. 3240665Sbrian * 3330715Sbrian * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 3436285Sbrian * $FreeBSD: head/sys/sys/disklabel.h 84587 2001-10-06 12:35:22Z dfr $ 3530715Sbrian */ 3646085Sbrian 3736285Sbrian#ifndef _SYS_DISKLABEL_H_ 3836285Sbrian#define _SYS_DISKLABEL_H_ 3932614Sbrian 4030715Sbrian#ifndef _KERNEL 4136285Sbrian#include <sys/types.h> 4230715Sbrian#endif 4330715Sbrian#include <sys/ioccom.h> 4439395Sbrian 4546086Sbrian/* 4646086Sbrian * Disk description table, see disktab(5) 4746086Sbrian */ 4839395Sbrian#define _PATH_DISKTAB "/etc/disktab" 4939395Sbrian#define DISKTAB "/etc/disktab" /* deprecated */ 5039395Sbrian 5146686Sbrian/* 5238814Sbrian * Each disk has a label which includes information about the hardware 5337009Sbrian * disk geometry, filesystem partitions, and drive specific information. 5431343Sbrian * The label is in block 0 or 1, possibly offset from the beginning 5530715Sbrian * to leave room for a bootstrap, etc. 5630715Sbrian */ 5730715Sbrian 5829048Sbrian/* XXX these should be defined per controller (or drive) elsewhere, not here! */ 5946686Sbrian#ifdef __i386__ 6029048Sbrian#define LABELSECTOR 1 /* sector containing label */ 6131690Sbrian#define LABELOFFSET 0 /* offset of label in sector */ 6236285Sbrian#endif 6336285Sbrian 6438557Sbrian#ifdef __alpha__ 6538557Sbrian#define LABELSECTOR 0 6629048Sbrian#define LABELOFFSET 64 6736285Sbrian#endif 6836285Sbrian 6930715Sbrian#ifdef __ia64__ 7036285Sbrian#define LABELSECTOR 1 /* sector containing label */ 7136285Sbrian#define LABELOFFSET 0 /* offset of label in sector */ 7236285Sbrian#endif 7336285Sbrian 7436285Sbrian#ifndef LABELSECTOR 7543313Sbrian#define LABELSECTOR 0 /* sector containing label */ 7643313Sbrian#endif 7743313Sbrian 7836285Sbrian#ifndef LABELOFFSET 7936285Sbrian#define LABELOFFSET 64 /* offset of label in sector */ 8036285Sbrian#endif 8136285Sbrian 8236285Sbrian#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */ 8331690Sbrian#ifndef MAXPARTITIONS 8440561Sbrian#define MAXPARTITIONS 8 856059Samurai#endif 8636285Sbrian 8736285Sbrian#define LABEL_PART 2 /* partition containing label */ 8836285Sbrian#define RAW_PART 2 /* partition containing whole disk */ 8936285Sbrian#define SWAP_PART 1 /* partition normally containing swap */ 906059Samurai 9136285Sbrian#ifndef LOCORE 9236285Sbrianstruct disklabel { 9336285Sbrian u_int32_t d_magic; /* the magic number */ 9436285Sbrian u_int16_t d_type; /* drive type */ 9536285Sbrian u_int16_t d_subtype; /* controller/d_type specific */ 966059Samurai char d_typename[16]; /* type name, e.g. "eagle" */ 9736285Sbrian 9836285Sbrian /* 9926516Sbrian * d_packname contains the pack identifier and is returned when 10026516Sbrian * the disklabel is read off the disk or in-core copy. 10144305Sbrian * d_boot0 and d_boot1 are the (optional) names of the 10236285Sbrian * primary (block 0) and secondary (block 1-15) bootstraps 10336285Sbrian * as found in /boot. These are returned when using 10436285Sbrian * getdiskbyname(3) to retrieve the values from /etc/disktab. 10536285Sbrian */ 10636285Sbrian union { 1076059Samurai char un_d_packname[16]; /* pack identifier */ 10836285Sbrian struct { 1096059Samurai char *un_d_boot0; /* primary bootstrap name */ 1106059Samurai char *un_d_boot1; /* secondary bootstrap name */ 1116059Samurai } un_b; 1126059Samurai } d_un; 1136059Samurai#define d_packname d_un.un_d_packname 1146059Samurai#define d_boot0 d_un.un_b.un_d_boot0 11536285Sbrian#define d_boot1 d_un.un_b.un_d_boot1 1166059Samurai 1176059Samurai /* disk geometry: */ 11836285Sbrian u_int32_t d_secsize; /* # of bytes per sector */ 11936285Sbrian u_int32_t d_nsectors; /* # of data sectors per track */ 1206059Samurai u_int32_t d_ntracks; /* # of tracks per cylinder */ 1216059Samurai u_int32_t d_ncylinders; /* # of data cylinders per unit */ 12231343Sbrian u_int32_t d_secpercyl; /* # of data sectors per cylinder */ 12331171Sbrian u_int32_t d_secperunit; /* # of data sectors per unit */ 12431171Sbrian 12531171Sbrian /* 12631171Sbrian * Spares (bad sector replacements) below are not counted in 12731171Sbrian * d_nsectors or d_secpercyl. Spare sectors are assumed to 1286059Samurai * be physical sectors which occupy space at the end of each 1296059Samurai * track and/or cylinder. 13031962Sbrian */ 13131171Sbrian u_int16_t d_sparespertrack; /* # of spare sectors per track */ 13231343Sbrian u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */ 13331171Sbrian /* 13431171Sbrian * Alternate cylinders include maintenance, replacement, configuration 13531171Sbrian * description areas, etc. 13631171Sbrian */ 13731171Sbrian u_int32_t d_acylinders; /* # of alt. cylinders per unit */ 13831171Sbrian 13931171Sbrian /* hardware characteristics: */ 14031171Sbrian /* 14131962Sbrian * d_interleave, d_trackskew and d_cylskew describe perturbations 14231171Sbrian * in the media format used to compensate for a slow controller. 14331272Sbrian * Interleave is physical sector interleave, set up by the 14436285Sbrian * formatter or controller when formatting. When interleaving is 1456059Samurai * in use, logically adjacent sectors are not physically 14636285Sbrian * contiguous, but instead are separated by some number of 1476059Samurai * sectors. It is specified as the ratio of physical sectors 1486059Samurai * traversed per logical sector. Thus an interleave of 1:1 14931272Sbrian * implies contiguous layout, while 2:1 implies that logical 15036285Sbrian * sector 0 is separated by one sector from logical sector 1. 1516059Samurai * d_trackskew is the offset of sector 0 on track N relative to 15236285Sbrian * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew 1536059Samurai * is the offset of sector 0 on cylinder N relative to sector 0 1546059Samurai * on cylinder N-1. 15536285Sbrian */ 15636285Sbrian u_int16_t d_rpm; /* rotational speed */ 1576059Samurai u_int16_t d_interleave; /* hardware sector interleave */ 15836285Sbrian u_int16_t d_trackskew; /* sector 0 skew, per track */ 1596059Samurai u_int16_t d_cylskew; /* sector 0 skew, per cylinder */ 16036285Sbrian u_int32_t d_headswitch; /* head switch time, usec */ 16136285Sbrian u_int32_t d_trkseek; /* track-to-track seek, usec */ 16236285Sbrian u_int32_t d_flags; /* generic flags */ 16336285Sbrian#define NDDATA 5 16436285Sbrian u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */ 16536285Sbrian#define NSPARE 5 16636285Sbrian u_int32_t d_spare[NSPARE]; /* reserved for future use */ 16736285Sbrian u_int32_t d_magic2; /* the magic number (again) */ 16836285Sbrian u_int16_t d_checksum; /* xor of data incl. partitions */ 16936285Sbrian 17036285Sbrian /* filesystem and partition information: */ 17136285Sbrian u_int16_t d_npartitions; /* number of partitions in following */ 17236285Sbrian u_int32_t d_bbsize; /* size of boot area at sn0, bytes */ 17336285Sbrian u_int32_t d_sbsize; /* max size of fs superblock, bytes */ 17436285Sbrian struct partition { /* the partition table */ 17536285Sbrian u_int32_t p_size; /* number of sectors in partition */ 17636285Sbrian u_int32_t p_offset; /* starting sector */ 17736285Sbrian u_int32_t p_fsize; /* filesystem basic fragment size */ 17836285Sbrian u_int8_t p_fstype; /* filesystem type, see below */ 17936285Sbrian u_int8_t p_frag; /* filesystem fragments per block */ 18036285Sbrian u_int16_t p_cpg; /* filesystem cylinders per group */ 18132614Sbrian } d_partitions[MAXPARTITIONS]; /* actually may be more */ 18236285Sbrian}; 18329048Sbrian 18436285Sbrianstatic u_int16_t dkcksum(struct disklabel *lp); 18536285Sbrian 18636285Sbrianstatic __inline u_int16_t 18736285Sbriandkcksum(struct disklabel *lp) 18836285Sbrian{ 18936285Sbrian u_int16_t *start, *end; 19026516Sbrian u_int16_t sum = 0; 19136285Sbrian 19236285Sbrian start = (u_int16_t *)lp; 19331272Sbrian end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions]; 19436285Sbrian while (start < end) 19536285Sbrian sum ^= *start++; 19636285Sbrian return (sum); 19736285Sbrian} 19836285Sbrian 19936285Sbrian#else /* LOCORE */ 20036285Sbrian /* 20136285Sbrian * offsets for asm boot files. 20236285Sbrian */ 20336285Sbrian .set d_secsize,40 20436285Sbrian .set d_nsectors,44 20536285Sbrian .set d_ntracks,48 20636285Sbrian .set d_ncylinders,52 20736285Sbrian .set d_secpercyl,56 20836285Sbrian .set d_secperunit,60 20936285Sbrian .set d_end_,276 /* size of disk label */ 21036285Sbrian#endif /* LOCORE */ 21136285Sbrian 21236285Sbrian/* d_type values: */ 21336285Sbrian#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */ 21436285Sbrian#define DTYPE_MSCP 2 /* MSCP */ 21536285Sbrian#define DTYPE_DEC 3 /* other DEC (rk, rl) */ 21636285Sbrian#define DTYPE_SCSI 4 /* SCSI */ 21736285Sbrian#define DTYPE_ESDI 5 /* ESDI interface */ 21836285Sbrian#define DTYPE_ST506 6 /* ST506 etc. */ 21936285Sbrian#define DTYPE_HPIB 7 /* CS/80 on HP-IB */ 22036285Sbrian#define DTYPE_HPFL 8 /* HP Fiber-link */ 22136285Sbrian#define DTYPE_FLOPPY 10 /* floppy */ 22236285Sbrian#define DTYPE_CCD 11 /* concatenated disk */ 22336285Sbrian#define DTYPE_VINUM 12 /* vinum volume */ 22436285Sbrian#define DTYPE_DOC2K 13 /* Msys DiskOnChip */ 22536285Sbrian 22636285Sbrian#if defined(PC98) && !defined(PC98_ATCOMPAT) 22736285Sbrian#define DSTYPE_SEC256 0x80 /* physical sector size=256 */ 22836285Sbrian#endif 22936285Sbrian 23036285Sbrian#ifdef DKTYPENAMES 23136285Sbrianstatic char *dktypenames[] = { 23236285Sbrian "unknown", 23336285Sbrian "SMD", 23436285Sbrian "MSCP", 23536285Sbrian "old DEC", 23636285Sbrian "SCSI", 23736285Sbrian "ESDI", 23836285Sbrian "ST506", 23936285Sbrian "HP-IB", 24036285Sbrian "HP-FL", 24136285Sbrian "type 9", 24236285Sbrian "floppy", 24336285Sbrian "CCD", 24436285Sbrian "Vinum", 24536285Sbrian "DOC2K", 24636285Sbrian NULL 24736285Sbrian}; 24836285Sbrian#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1) 24936285Sbrian#endif 25036285Sbrian 25136285Sbrian/* 25236285Sbrian * Filesystem type and version. 25336285Sbrian * Used to interpret other filesystem-specific 25436285Sbrian * per-partition information. 25536285Sbrian */ 25636285Sbrian#define FS_UNUSED 0 /* unused */ 25736285Sbrian#define FS_SWAP 1 /* swap */ 25836285Sbrian#define FS_V6 2 /* Sixth Edition */ 25936285Sbrian#define FS_V7 3 /* Seventh Edition */ 26036285Sbrian#define FS_SYSV 4 /* System V */ 26136285Sbrian#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */ 26236285Sbrian#define FS_V8 6 /* Eighth Edition, 4K blocks */ 26336285Sbrian#define FS_BSDFFS 7 /* 4.2BSD fast file system */ 26436285Sbrian#define FS_MSDOS 8 /* MSDOS file system */ 2656059Samurai#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */ 2666059Samurai#define FS_OTHER 10 /* in use, but unknown/unsupported */ 26736285Sbrian#define FS_HPFS 11 /* OS/2 high-performance file system */ 26836285Sbrian#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */ 2696059Samurai#define FS_BOOT 13 /* partition contains bootstrap */ 27036285Sbrian#define FS_VINUM 14 /* Vinum drive */ 2716059Samurai 27236285Sbrian#ifdef DKTYPENAMES 27336285Sbrianstatic char *fstypenames[] = { 27436285Sbrian "unused", 27536285Sbrian "swap", 27636285Sbrian "Version 6", 27736285Sbrian "Version 7", 27836285Sbrian "System V", 2796059Samurai "4.1BSD", 28036285Sbrian "Eighth Edition", 28136285Sbrian "4.2BSD", 28236285Sbrian "MSDOS", 28343313Sbrian "4.4LFS", 28436285Sbrian "unknown", 28536285Sbrian "HPFS", 28636285Sbrian "ISO9660", 28744305Sbrian "boot", 28844305Sbrian "vinum", 28944305Sbrian NULL 29044305Sbrian}; 29136285Sbrian#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1) 29236285Sbrian#endif 29344455Sbrian 29436285Sbrian/* 29544455Sbrian * flags shared by various drives: 29636285Sbrian */ 29744455Sbrian#define D_REMOVABLE 0x01 /* removable media */ 29844455Sbrian#define D_ECC 0x02 /* supports ECC */ 29936285Sbrian#define D_BADSECT 0x04 /* supports bad sector forw. */ 30036285Sbrian#define D_RAMDISK 0x08 /* disk emulator */ 30136285Sbrian#define D_CHAIN 0x10 /* can do back-back transfers */ 30236285Sbrian 30336285Sbrian/* 30436285Sbrian * Drive data for SMD. 30536285Sbrian */ 30636285Sbrian#define d_smdflags d_drivedata[0] 30736285Sbrian#define D_SSE 0x1 /* supports skip sectoring */ 30836285Sbrian#define d_mindist d_drivedata[1] 30936285Sbrian#define d_maxdist d_drivedata[2] 31036285Sbrian#define d_sdist d_drivedata[3] 31136285Sbrian 31236285Sbrian/* 31336285Sbrian * Drive data for ST506. 31436285Sbrian */ 31536285Sbrian#define d_precompcyl d_drivedata[0] 31636285Sbrian#define d_gap3 d_drivedata[1] /* used only when formatting */ 31736285Sbrian 31836285Sbrian/* 31936285Sbrian * Drive data for SCSI. 32036285Sbrian */ 32136285Sbrian#define d_blind d_drivedata[0] 3226059Samurai 3236059Samurai#ifndef LOCORE 32432614Sbrian/* 32536285Sbrian * Structure used to perform a format or other raw operation, returning 32632614Sbrian * data and/or register values. Register identification and format 32736285Sbrian * are device- and driver-dependent. 32832614Sbrian */ 32936285Sbrianstruct format_op { 33032614Sbrian char *df_buf; 33132614Sbrian int df_count; /* value-result */ 33236285Sbrian daddr_t df_startblk; 33332614Sbrian int df_reg[8]; /* result */ 33432614Sbrian}; 33536285Sbrian 33632614Sbrian/* 33736285Sbrian * Structure used internally to retrieve information about a partition 33836285Sbrian * on a disk. 33936285Sbrian */ 34036285Sbrianstruct partinfo { 34136285Sbrian struct disklabel *disklab; 34232614Sbrian struct partition *part; 34332614Sbrian}; 34432614Sbrian 34532614Sbrian/* DOS partition table -- located in boot block */ 34632614Sbrian 34732614Sbrian#if defined(PC98) && !defined(PC98_ATCOMPAT) 34832614Sbrian#define DOSBBSECTOR 0 /* DOS boot block relative sector number */ 34936285Sbrian#define DOSLABELSECTOR 1 /* 0: 256b/s, 1: 512b/s */ 35036285Sbrian#define DOSPARTOFF 0 35136285Sbrian#define NDOSPART 16 35232614Sbrian#define DOSPTYP_386BSD 0x94 /* 386BSD partition type */ 35336285Sbrian#define MBR_PTYPE_FreeBSD 0x94 /* FreeBSD partition type */ 35436285Sbrian 35536285Sbrianstruct dos_partition { 35636285Sbrian unsigned char dp_mid; 35736285Sbrian#define DOSMID_386BSD (0x14|0x80) /* 386bsd|bootable */ 35844305Sbrian unsigned char dp_sid; 35936285Sbrian#define DOSSID_386BSD (0x44|0x80) /* 386bsd|active */ 36036285Sbrian unsigned char dp_dum1; 36136285Sbrian unsigned char dp_dum2; 36236285Sbrian unsigned char dp_ipl_sct; 36336285Sbrian unsigned char dp_ipl_head; 36436285Sbrian unsigned short dp_ipl_cyl; 36536285Sbrian unsigned char dp_ssect; /* starting sector */ 36636285Sbrian unsigned char dp_shd; /* starting head */ 36740561Sbrian unsigned short dp_scyl; /* starting cylinder */ 36836285Sbrian unsigned char dp_esect; /* end sector */ 36932614Sbrian unsigned char dp_ehd; /* end head */ 37036285Sbrian unsigned short dp_ecyl; /* end cylinder */ 37136285Sbrian unsigned char dp_name[16]; 37236285Sbrian}; 37336285Sbrian 37436285Sbrian#else /* IBMPC */ 37536285Sbrian#define DOSBBSECTOR 0 /* DOS boot block relative sector number */ 37636285Sbrian#define DOSPARTOFF 446 37736285Sbrian#define NDOSPART 4 37836285Sbrian#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */ 37936285Sbrian#define DOSPTYP_LINSWP 0x82 /* Linux swap partition */ 38036285Sbrian#define DOSPTYP_LINUX 0x83 /* Linux partition */ 38144305Sbrian#define DOSPTYP_EXT 5 /* DOS extended partition */ 38244305Sbrian 38344305Sbrianstruct dos_partition { 38436285Sbrian unsigned char dp_flag; /* bootstrap flags */ 38536285Sbrian unsigned char dp_shd; /* starting head */ 38636285Sbrian unsigned char dp_ssect; /* starting sector */ 38736285Sbrian unsigned char dp_scyl; /* starting cylinder */ 38836285Sbrian unsigned char dp_typ; /* partition type */ 38938557Sbrian unsigned char dp_ehd; /* end head */ 39043313Sbrian unsigned char dp_esect; /* end sector */ 39132614Sbrian unsigned char dp_ecyl; /* end cylinder */ 39232614Sbrian u_int32_t dp_start; /* absolute starting sector number */ 3936059Samurai u_int32_t dp_size; /* partition size in sectors */ 39436285Sbrian}; 3956059Samurai#endif 39636285Sbrian 39736285Sbrian#define DPSECT(s) ((s) & 0x3f) /* isolate relevant bits of sector */ 39836285Sbrian#define DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */ 39936285Sbrian 40043313Sbrian/* 40136285Sbrian * Disk-specific ioctls. 40240561Sbrian */ 40340561Sbrian /* get and set disklabel; DIOCGPART used internally */ 40436285Sbrian#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */ 40536285Sbrian#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */ 40643313Sbrian#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */ 40736285Sbrian#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ 40836285Sbrian#define DIOCGDVIRGIN _IOR('d', 105, struct disklabel) /* get virgin label */ 40940561Sbrian 41040561Sbrian#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ 41140561Sbrian 41240561Sbrian#ifdef _KERNEL 41340561Sbrian 41440561Sbrian/* 41540561Sbrian * XXX encoding of disk minor numbers, should be elsewhere. 41640561Sbrian * 41740561Sbrian * See <sys/reboot.h> for a possibly better encoding. 41840561Sbrian * 41940561Sbrian * "cpio -H newc" can be used to back up device files with large minor 42036285Sbrian * numbers (but not ones >= 2^31). Old cpio formats and all tar formats 42140561Sbrian * don't have enough bits, and cpio and tar don't notice the lossage. 42236285Sbrian * There are also some sign extension bugs. 42336285Sbrian */ 4246059Samurai 4259440Samurai/* 42636285Sbrian 3 2 1 0 42736285Sbrian 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 42836285Sbrian _________________________________________________________________ 42936285Sbrian | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 43036285Sbrian ----------------------------------------------------------------- 43136285Sbrian | TYPE |UNIT_2 | SLICE | MAJOR? | UNIT |PART | 43236285Sbrian ----------------------------------------------------------------- 43336285Sbrian*/ 43436285Sbrian 43536285Sbrian#define DKMAXUNIT 0x1ff /* Highest disk unit number */ 43636285Sbrian 43736285Sbrian#define dkmakeminor(unit, slice, part) \ 43836285Sbrian (((slice) << 16) | (((unit) & 0x1e0) << 16) | \ 43936285Sbrian (((unit) & 0x1f) << 3) | (part)) 44040561Sbrianstatic __inline dev_t 44136285Sbriandkmodpart(dev_t dev, int part) 44240561Sbrian{ 44340561Sbrian return (makedev(major(dev), (minor(dev) & ~7) | part)); 44440561Sbrian} 44540561Sbrian 44640561Sbrianstatic __inline dev_t 44736285Sbriandkmodslice(dev_t dev, int slice) 44840561Sbrian{ 44940561Sbrian return (makedev(major(dev), (minor(dev) & ~0x1f0000) | (slice << 16))); 45040561Sbrian} 45140561Sbrian 45240561Sbrian#define dkpart(dev) (minor(dev) & 7) 45340561Sbrian#define dkslice(dev) ((minor(dev) >> 16) & 0x1f) 45440561Sbrian#define dktype(dev) ((minor(dev) >> 25) & 0x7f) 45540561Sbrian 45640561Sbrianstatic __inline u_int 45736285Sbriandkunit(dev_t dev) 45843313Sbrian{ 45943313Sbrian return (((minor(dev) >> 16) & 0x1e0) | ((minor(dev) >> 3) & 0x1f)); 46043313Sbrian} 46143313Sbrian 46243313Sbrianstruct bio; 46336285Sbrianstruct buf; 46436285Sbrianstruct buf_queue_head; 46536285Sbrianstruct bio_queue_head; 46636285Sbrian 46736285Sbrianint bounds_check_with_label __P((struct bio *bp, struct disklabel *lp, 46836285Sbrian int wlabel)); 46936285Sbrianvoid diskerr __P((struct bio *bp, char *what, int blkdone, 47036285Sbrian struct disklabel *lp)); 47136285Sbrianvoid disksort __P((struct buf *ap, struct buf *bp)); 47236285Sbrianchar *readdisklabel __P((dev_t dev, struct disklabel *lp)); 47336285Sbrianvoid bioqdisksort __P((struct bio_queue_head *ap, struct bio *bp)); 47436285Sbrianint setdisklabel __P((struct disklabel *olp, struct disklabel *nlp, 47540665Sbrian u_long openmask)); 47640665Sbrianint writedisklabel __P((dev_t dev, struct disklabel *lp)); 47740665Sbrian#ifdef __alpha__ 47840665Sbrianvoid alpha_fix_srm_checksum __P((struct buf *bp)); 47940665Sbrian#endif 48040665Sbrian 48140665Sbrian#endif /* _KERNEL */ 48240665Sbrian 48340665Sbrian#endif /* LOCORE */ 48440665Sbrian 48544455Sbrian#ifndef _KERNEL 48640665Sbrian__BEGIN_DECLS 48744455Sbrianstruct disklabel *getdiskbyname __P((const char *)); 48840665Sbrian__END_DECLS 48940665Sbrian#endif 49040665Sbrian 49140665Sbrian#endif /* !_SYS_DISKLABEL_H_ */ 49240665Sbrian