1*ec184f3bShgutch.\" $NetBSD: disklabel.5,v 1.31 2022/08/28 10:48:16 hgutch Exp $ 20114e805Scgd.\" 3ae9172d6Scgd.\" Copyright (c) 1987, 1991, 1993 4ae9172d6Scgd.\" The Regents of the University of California. All rights reserved. 5ae9172d6Scgd.\" 6ae9172d6Scgd.\" This code is derived from software contributed to Berkeley by 7ae9172d6Scgd.\" Symmetric Computer Systems. 8ae9172d6Scgd.\" 9ae9172d6Scgd.\" Redistribution and use in source and binary forms, with or without 10ae9172d6Scgd.\" modification, are permitted provided that the following conditions 11ae9172d6Scgd.\" are met: 12ae9172d6Scgd.\" 1. Redistributions of source code must retain the above copyright 13ae9172d6Scgd.\" notice, this list of conditions and the following disclaimer. 14ae9172d6Scgd.\" 2. Redistributions in binary form must reproduce the above copyright 15ae9172d6Scgd.\" notice, this list of conditions and the following disclaimer in the 16ae9172d6Scgd.\" documentation and/or other materials provided with the distribution. 17bf07c871Sagc.\" 3. Neither the name of the University nor the names of its contributors 18ae9172d6Scgd.\" may be used to endorse or promote products derived from this software 19ae9172d6Scgd.\" without specific prior written permission. 20ae9172d6Scgd.\" 21ae9172d6Scgd.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22ae9172d6Scgd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23ae9172d6Scgd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24ae9172d6Scgd.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25ae9172d6Scgd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26ae9172d6Scgd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27ae9172d6Scgd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28ae9172d6Scgd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29ae9172d6Scgd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30ae9172d6Scgd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31ae9172d6Scgd.\" SUCH DAMAGE. 32ae9172d6Scgd.\" 33ae9172d6Scgd.\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93 34ae9172d6Scgd.\" 35a3477eb2Ssevan.Dd September 11, 2016 36ae9172d6Scgd.Dt DISKLABEL 5 37ae9172d6Scgd.Os 38ae9172d6Scgd.Sh NAME 39ae9172d6Scgd.Nm disklabel 40ae9172d6Scgd.Nd disk pack label 41ae9172d6Scgd.Sh SYNOPSIS 42472351e1Swiz.In sys/disklabel.h 43ae9172d6Scgd.Sh DESCRIPTION 44ae9172d6ScgdEach disk or disk pack on a system may contain a disk label 45ae9172d6Scgdwhich provides detailed information 46ae9172d6Scgdabout the geometry of the disk and the partitions into which the disk 47ae9172d6Scgdis divided. 48ae9172d6ScgdIt should be initialized when the disk is formatted, 49ae9172d6Scgdand may be changed later with the 50ae9172d6Scgd.Xr disklabel 8 51ae9172d6Scgdprogram. 52ae9172d6ScgdThis information is used by the system disk driver and by the bootstrap 53ae9172d6Scgdprogram to determine how to program the drive 54ae9172d6Scgdand where to find the file systems on the disk partitions. 55ae9172d6ScgdAdditional information is used by the file system in order 56ae9172d6Scgdto use the disk most efficiently and to locate important file system information. 57ae9172d6ScgdThe description of each partition contains an identifier for the partition 58ae9172d6Scgdtype (standard file system, swap area, etc.). 59ae9172d6ScgdThe file system updates the in-core copy of the label if it contains 60ae9172d6Scgdincomplete information about the file system. 61ae9172d6Scgd.Pp 621c4717cdSscwThe label is located in the sector number returned by the 631c4717cdSscw.Xr getlabelsector 3 641c4717cdSscwfunction, usually sector 0 where it may be found 65ae9172d6Scgdwithout any information about the disk geometry. 661c4717cdSscwIt is at an offset (specified by the 671c4717cdSscw.Xr getlabeloffset 3 681c4717cdSscwfunction) 69ae9172d6Scgdfrom the beginning of the sector, to allow room for the initial bootstrap. 70ae9172d6ScgdThe disk sector containing the label is normally made read-only 71ae9172d6Scgdso that it is not accidentally overwritten by pack-to-pack copies 72ae9172d6Scgdor swap operations; 73ae9172d6Scgdthe 74ae9172d6Scgd.Dv DIOCWLABEL 75ae9172d6Scgd.Xr ioctl 2 , 76ae9172d6Scgdwhich is done as needed by the 773d7afc6dSfair.Xr disklabel 8 78ae9172d6Scgdprogram. 79ae9172d6Scgd.Pp 80ae9172d6ScgdA copy of the in-core label for a disk can be obtained with the 81ae9172d6Scgd.Dv DIOCGDINFO 823d7afc6dSfair.Xr ioctl 2 ; 83ae9172d6Scgdthis works with a file descriptor for a block or character (``raw'') device 84ae9172d6Scgdfor any partition of the disk. 85ae9172d6ScgdThe in-core copy of the label is set by the 86ae9172d6Scgd.Dv DIOCSDINFO 873d7afc6dSfair.Xr ioctl 2 . 88ae9172d6ScgdThe offset of a partition cannot generally be changed while it is open, 89ae9172d6Scgdnor can it be made smaller while it is open. 90ae9172d6ScgdOne exception is that any change is allowed if no label was found 91ae9172d6Scgdon the disk, and the driver was able to construct only a skeletal label 92ae9172d6Scgdwithout partition information. 93ae9172d6ScgdFinally, the 94ae9172d6Scgd.Dv DIOCWDINFO 953d7afc6dSfair.Xr ioctl 2 96ae9172d6Scgdoperation sets the in-core label and then updates the on-disk label; 97ae9172d6Scgdthere must be an existing label on the disk for this operation to succeed. 98ae9172d6ScgdThus, the initial label for a disk or disk pack must be installed 99ae9172d6Scgdby writing to the raw disk. 100ae9172d6ScgdAll of these operations are normally done using 1013d7afc6dSfair.Xr disklabel 8 . 102ae9172d6Scgd.Pp 103ae9172d6ScgdThe format of the disk label, as specified in 1046fcba07cSpk.Pa sys/disklabel.h , 105ae9172d6Scgdis 106ae9172d6Scgd.Bd -literal 107ae9172d6Scgd/* 108ae9172d6Scgd * Disk description table, see disktab(5) 109ae9172d6Scgd */ 1106fcba07cSpk#define _PATH_DISKTAB "/etc/disktab" 111ae9172d6Scgd 112ae9172d6Scgd/* 113ae9172d6Scgd * Each disk has a label which includes information about the hardware 114ae9172d6Scgd * disk geometry, file system partitions, and drive specific information. 1156fcba07cSpk * The location of the label, as well as the number of partitions the 1166fcba07cSpk * label can describe and the number of the "whole disk" (raw) 11774347b52Swiz * partition are machine dependent. 118ae9172d6Scgd */ 11901869ca4Swiz#include <machine/disklabel.h> 120ae9172d6Scgd 1216fcba07cSpk/* 1226fcba07cSpk * The absolute maximum number of disk partitions allowed. 1236fcba07cSpk * This is the maximum value of MAXPARTITIONS for which 'struct disklabel' 124*ec184f3bShgutch * is <= DEV_BSIZE bytes long. If MAXPARTITIONS is greater than this, beware. 1256fcba07cSpk */ 1266fcba07cSpk#define MAXMAXPARTITIONS 22 12701869ca4Swiz#if MAXPARTITIONS > MAXMAXPARTITIONS 128169563b7Scgd#warning beware: MAXPARTITIONS bigger than MAXMAXPARTITIONS 129ae9172d6Scgd#endif 130ae9172d6Scgd 131ae9172d6Scgd 1326fcba07cSpk#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */ 133ae9172d6Scgd 1346fcba07cSpk#ifndef _LOCORE 135ae9172d6Scgdstruct disklabel { 1366fcba07cSpk u_int32_t d_magic; /* the magic number */ 1376fcba07cSpk u_int16_t d_type; /* drive type */ 1386fcba07cSpk u_int16_t d_subtype; /* controller/d_type specific */ 139b14abce7Ssnj char d_typename[16]; /* type name, e.g. "eagle" */ 1406fcba07cSpk 141ae9172d6Scgd /* 142ae9172d6Scgd * d_packname contains the pack identifier and is returned when 143ae9172d6Scgd * the disklabel is read off the disk or in-core copy. 144ae9172d6Scgd * d_boot0 and d_boot1 are the (optional) names of the 145ae9172d6Scgd * primary (block 0) and secondary (block 1-15) bootstraps 146ae9172d6Scgd * as found in /usr/mdec. These are returned when using 1476fcba07cSpk * getdiskbyname(3) to retrieve the values from /etc/disktab. 148ae9172d6Scgd */ 149ae9172d6Scgd union { 150ae9172d6Scgd char un_d_packname[16]; /* pack identifier */ 151ae9172d6Scgd struct { 152ae9172d6Scgd char *un_d_boot0; /* primary bootstrap name */ 153ae9172d6Scgd char *un_d_boot1; /* secondary bootstrap name */ 154ae9172d6Scgd } un_b; 155ae9172d6Scgd } d_un; 156ae9172d6Scgd#define d_packname d_un.un_d_packname 157ae9172d6Scgd#define d_boot0 d_un.un_b.un_d_boot0 158ae9172d6Scgd#define d_boot1 d_un.un_b.un_d_boot1 159ae9172d6Scgd 160ae9172d6Scgd /* disk geometry: */ 1616fcba07cSpk u_int32_t d_secsize; /* # of bytes per sector */ 1626fcba07cSpk u_int32_t d_nsectors; /* # of data sectors per track */ 1636fcba07cSpk u_int32_t d_ntracks; /* # of tracks per cylinder */ 1646fcba07cSpk u_int32_t d_ncylinders; /* # of data cylinders per unit */ 1656fcba07cSpk u_int32_t d_secpercyl; /* # of data sectors per cylinder */ 1666fcba07cSpk u_int32_t d_secperunit; /* # of data sectors per unit */ 1676fcba07cSpk 168ae9172d6Scgd /* 1696fcba07cSpk * Spares (bad sector replacements) below are not counted in 1706fcba07cSpk * d_nsectors or d_secpercyl. Spare sectors are assumed to 1716fcba07cSpk * be physical sectors which occupy space at the end of each 1726fcba07cSpk * track and/or cylinder. 173ae9172d6Scgd */ 1746fcba07cSpk u_int16_t d_sparespertrack; /* # of spare sectors per track */ 1756fcba07cSpk u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */ 176ae9172d6Scgd /* 1778fa8b773Senami * Alternative cylinders include maintenance, replacement, 1788fa8b773Senami * configuration description areas, etc. 179ae9172d6Scgd */ 1806fcba07cSpk u_int32_t d_acylinders; /* # of alt. cylinders per unit */ 181ae9172d6Scgd 182ae9172d6Scgd /* hardware characteristics: */ 183ae9172d6Scgd /* 184ae9172d6Scgd * d_interleave, d_trackskew and d_cylskew describe perturbations 185ae9172d6Scgd * in the media format used to compensate for a slow controller. 1866fcba07cSpk * Interleave is physical sector interleave, set up by the 1876fcba07cSpk * formatter or controller when formatting. When interleaving is 1886fcba07cSpk * in use, logically adjacent sectors are not physically 1896fcba07cSpk * contiguous, but instead are separated by some number of 1906fcba07cSpk * sectors. It is specified as the ratio of physical sectors 1916fcba07cSpk * traversed per logical sector. Thus an interleave of 1:1 1926fcba07cSpk * implies contiguous layout, while 2:1 implies that logical 1936fcba07cSpk * sector 0 is separated by one sector from logical sector 1. 1946fcba07cSpk * d_trackskew is the offset of sector 0 on track N relative to 1956fcba07cSpk * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew 1966fcba07cSpk * is the offset of sector 0 on cylinder N relative to sector 0 1976fcba07cSpk * on cylinder N-1. 198ae9172d6Scgd */ 1996fcba07cSpk u_int16_t d_rpm; /* rotational speed */ 2006fcba07cSpk u_int16_t d_interleave; /* hardware sector interleave */ 2016fcba07cSpk u_int16_t d_trackskew; /* sector 0 skew, per track */ 2026fcba07cSpk u_int16_t d_cylskew; /* sector 0 skew, per cylinder */ 2036fcba07cSpk u_int32_t d_headswitch; /* head switch time, usec */ 2046fcba07cSpk u_int32_t d_trkseek; /* track-to-track seek, usec */ 2056fcba07cSpk u_int32_t d_flags; /* generic flags */ 206ae9172d6Scgd#define NDDATA 5 2076fcba07cSpk u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */ 208ae9172d6Scgd#define NSPARE 5 2096fcba07cSpk u_int32_t d_spare[NSPARE]; /* reserved for future use */ 2106fcba07cSpk u_int32_t d_magic2; /* the magic number (again) */ 2116fcba07cSpk u_int16_t d_checksum; /* xor of data incl. partitions */ 212ae9172d6Scgd 213ae9172d6Scgd /* file system and partition information: */ 2146fcba07cSpk u_int16_t d_npartitions; /* number of partitions in following */ 2156fcba07cSpk u_int32_t d_bbsize; /* size of boot area at sn0, bytes */ 2166fcba07cSpk u_int32_t d_sbsize; /* max size of fs superblock, bytes */ 217ae9172d6Scgd struct partition { /* the partition table */ 2186fcba07cSpk u_int32_t p_size; /* number of sectors in partition */ 2196fcba07cSpk u_int32_t p_offset; /* starting sector */ 2206fcba07cSpk u_int32_t p_fsize; /* file system basic fragment size */ 2216fcba07cSpk u_int8_t p_fstype; /* file system type, see below */ 2226fcba07cSpk u_int8_t p_frag; /* file system fragments per block */ 223ae9172d6Scgd union { 2246fcba07cSpk u_int16_t cpg; /* UFS: FS cylinders per group */ 2256fcba07cSpk u_int16_t sgs; /* LFS: FS segment shift */ 226ae9172d6Scgd } __partition_u1; 227ae9172d6Scgd#define p_cpg __partition_u1.cpg 228ae9172d6Scgd#define p_sgs __partition_u1.sgs 229ae9172d6Scgd } d_partitions[MAXPARTITIONS]; /* actually may be more */ 230ae9172d6Scgd}; 2316fcba07cSpk#else /* _LOCORE */ 2326fcba07cSpk /* 2336fcba07cSpk * offsets for asm boot files. 2346fcba07cSpk */ 2356fcba07cSpk .set d_secsize,40 2366fcba07cSpk .set d_nsectors,44 2376fcba07cSpk .set d_ntracks,48 2386fcba07cSpk .set d_ncylinders,52 2396fcba07cSpk .set d_secpercyl,56 2406fcba07cSpk .set d_secperunit,60 2416fcba07cSpk .set d_end_,276 /* size of disk label */ 2426fcba07cSpk#endif /* _LOCORE */ 243ae9172d6Scgd 244ae9172d6Scgd/* d_type values: */ 245ae9172d6Scgd#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */ 246ae9172d6Scgd#define DTYPE_MSCP 2 /* MSCP */ 247ae9172d6Scgd#define DTYPE_DEC 3 /* other DEC (rk, rl) */ 248ae9172d6Scgd#define DTYPE_SCSI 4 /* SCSI */ 249ae9172d6Scgd#define DTYPE_ESDI 5 /* ESDI interface */ 250ae9172d6Scgd#define DTYPE_ST506 6 /* ST506 etc. */ 251ae9172d6Scgd#define DTYPE_HPIB 7 /* CS/80 on HP-IB */ 252ae9172d6Scgd#define DTYPE_HPFL 8 /* HP Fiber-link */ 253ae9172d6Scgd#define DTYPE_FLOPPY 10 /* floppy */ 2546fcba07cSpk#define DTYPE_CCD 11 /* concatenated disk device */ 2556fcba07cSpk#define DTYPE_VND 12 /* vnode pseudo-disk */ 25621521cffSbouyer#define DTYPE_ATAPI 13 /* ATAPI */ 25721521cffSbouyer#define DTYPE_RAID 14 /* RAIDframe */ 258b64db129Sdbj#define DTYPE_LD 15 /* logical disk */ 2597d4caebaSdbj#define DTYPE_JFS2 16 /* IBM JFS2 */ 26040d804cfStsutsui#define DTYPE_CGD 17 /* cryptographic pseudo-disk */ 261e241178dSchristos#define DTYPE_VINUM 18 /* vinum volume obsolete */ 26240d804cfStsutsui#define DTYPE_FLASH 19 /* flash memory device */ 263ae9172d6Scgd 264ae9172d6Scgd#ifdef DKTYPENAMES 2658fa8b773Senamistatic const char *const dktypenames[] = { 266ae9172d6Scgd "unknown", 267ae9172d6Scgd "SMD", 268ae9172d6Scgd "MSCP", 269ae9172d6Scgd "old DEC", 270ae9172d6Scgd "SCSI", 271ae9172d6Scgd "ESDI", 272ae9172d6Scgd "ST506", 273ae9172d6Scgd "HP-IB", 274ae9172d6Scgd "HP-FL", 275ae9172d6Scgd "type 9", 276ae9172d6Scgd "floppy", 2776fcba07cSpk "ccd", 2786fcba07cSpk "vnd", 27921521cffSbouyer "ATAPI", 28021521cffSbouyer "RAID", 281ba3c70ebSdbj "ld", 2827d4caebaSdbj "jfs", 28340d804cfStsutsui "cgd", 284e241178dSchristos "obsolete vinum", 28540d804cfStsutsui "flash", 2868fa8b773Senami NULL 287ae9172d6Scgd}; 288ae9172d6Scgd#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1) 289ae9172d6Scgd#endif 290ae9172d6Scgd 291ae9172d6Scgd/* 292ae9172d6Scgd * Filesystem type and version. 293ae9172d6Scgd * Used to interpret other file system-specific 294ae9172d6Scgd * per-partition information. 295ae9172d6Scgd */ 296ae9172d6Scgd#define FS_UNUSED 0 /* unused */ 297ae9172d6Scgd#define FS_SWAP 1 /* swap */ 298ae9172d6Scgd#define FS_V6 2 /* Sixth Edition */ 299ae9172d6Scgd#define FS_V7 3 /* Seventh Edition */ 300ae9172d6Scgd#define FS_SYSV 4 /* System V */ 301ae9172d6Scgd#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */ 302ae9172d6Scgd#define FS_V8 6 /* Eighth Edition, 4K blocks */ 303ae9172d6Scgd#define FS_BSDFFS 7 /* 4.2BSD fast file system */ 304ae9172d6Scgd#define FS_MSDOS 8 /* MSDOS file system */ 305ae9172d6Scgd#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */ 306ae9172d6Scgd#define FS_OTHER 10 /* in use, but unknown/unsupported */ 307ae9172d6Scgd#define FS_HPFS 11 /* OS/2 high-performance file system */ 308ae9172d6Scgd#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */ 309ae9172d6Scgd#define FS_BOOT 13 /* partition contains bootstrap */ 3106fcba07cSpk#define FS_ADOS 14 /* AmigaDOS fast file system */ 3116fcba07cSpk#define FS_HFS 15 /* Macintosh HFS */ 3128fa8b773Senami#define FS_FILECORE 16 /* Acorn Filecore Filing System */ 31321521cffSbouyer#define FS_EX2FS 17 /* Linux Extended 2 file system */ 31421521cffSbouyer#define FS_NTFS 18 /* Windows/NT file system */ 315565f0151Soster#define FS_RAID 19 /* RAIDframe component */ 31607702f68Senami#define FS_CCD 20 /* concatenated disk component */ 3177d4caebaSdbj#define FS_JFS2 21 /* IBM JFS2 */ 318a323eac3Sdbj#define FS_APPLEUFS 22 /* Apple UFS */ 31940d804cfStsutsui#define FS_VINUM 23 /* Vinum */ 320ae9172d6Scgd 3218fa8b773Senami#ifdef FSTYPENAMES 3228fa8b773Senamistatic const char *const fstypenames[] = { 323ae9172d6Scgd "unused", 324ae9172d6Scgd "swap", 325ae9172d6Scgd "Version 6", 326ae9172d6Scgd "Version 7", 327ae9172d6Scgd "System V", 328ae9172d6Scgd "4.1BSD", 329ae9172d6Scgd "Eighth Edition", 330ae9172d6Scgd "4.2BSD", 331ae9172d6Scgd "MSDOS", 332ae9172d6Scgd "4.4LFS", 333ae9172d6Scgd "unknown", 334ae9172d6Scgd "HPFS", 335ae9172d6Scgd "ISO9660", 336ae9172d6Scgd "boot", 3376fcba07cSpk "ADOS", 3386fcba07cSpk "HFS", 33921521cffSbouyer "FILECORE", 34021521cffSbouyer "Linux Ext2", 34121521cffSbouyer "NTFS", 342565f0151Soster "RAID", 34307702f68Senami "ccd", 3447d4caebaSdbj "jfs", 345a323eac3Sdbj "Apple UFS", 346e241178dSchristos "obsolete vinum", 3478fa8b773Senami NULL 348ae9172d6Scgd}; 349ae9172d6Scgd#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1) 350ae9172d6Scgd#endif 351ae9172d6Scgd 352ae9172d6Scgd/* 353ae9172d6Scgd * flags shared by various drives: 354ae9172d6Scgd */ 355ae9172d6Scgd#define D_REMOVABLE 0x01 /* removable media */ 356ae9172d6Scgd#define D_ECC 0x02 /* supports ECC */ 357ae9172d6Scgd#define D_BADSECT 0x04 /* supports bad sector forw. */ 358ae9172d6Scgd#define D_RAMDISK 0x08 /* disk emulator */ 359ae9172d6Scgd#define D_CHAIN 0x10 /* can do back-back transfers */ 360ae9172d6Scgd 361ae9172d6Scgd/* 362ae9172d6Scgd * Drive data for SMD. 363ae9172d6Scgd */ 364ae9172d6Scgd 365ae9172d6Scgd#define d_smdflags d_drivedata[0] 366ae9172d6Scgd#define D_SSE 0x1 /* supports skip sectoring */ 367ae9172d6Scgd#define d_mindist d_drivedata[1] 368ae9172d6Scgd#define d_maxdist d_drivedata[2] 369ae9172d6Scgd#define d_sdist d_drivedata[3] 370ae9172d6Scgd 371ae9172d6Scgd/* 372ae9172d6Scgd * Drive data for ST506. 373ae9172d6Scgd */ 374ae9172d6Scgd#define d_precompcyl d_drivedata[0] 375ae9172d6Scgd#define d_gap3 d_drivedata[1] /* used only when formatting */ 376ae9172d6Scgd 377ae9172d6Scgd/* 378ae9172d6Scgd * Drive data for SCSI. 379ae9172d6Scgd */ 380ae9172d6Scgd#define d_blind d_drivedata[0] 381ae9172d6Scgd 3826fcba07cSpk#ifndef _LOCORE 383ae9172d6Scgd/* 3846fcba07cSpk * Structure used to perform a format or other raw operation, 3856fcba07cSpk * returning data and/or register values. Register identification 3866fcba07cSpk * and format are device- and driver-dependent. 387ae9172d6Scgd */ 388ae9172d6Scgdstruct format_op { 389ae9172d6Scgd char *df_buf; 390ae9172d6Scgd int df_count; /* value-result */ 391ae9172d6Scgd daddr_t df_startblk; 392ae9172d6Scgd int df_reg[8]; /* result */ 393ae9172d6Scgd}; 394ae9172d6Scgd 395ae9172d6Scgd/* 3968fa8b773Senami * Structure used internally to retrieve information about a partition 3978fa8b773Senami * on a disk. 398ae9172d6Scgd */ 399ae9172d6Scgdstruct partinfo { 400ae9172d6Scgd struct disklabel *disklab; 401ae9172d6Scgd struct partition *part; 402ae9172d6Scgd}; 4036fcba07cSpk.Ed 4046fcba07cSpk.Pp 405c832841fSmsaitohDisk specific ioctls are defined in 4066fcba07cSpk.Pa sys/dkio.h . 4076fcba07cSpk.Bd -literal 408a3477eb2Ssevan.Pp 409ae9172d6Scgd/* 410ae9172d6Scgd * Disk-specific ioctls. 411ae9172d6Scgd */ 412ae9172d6Scgd /* get and set disklabel; DIOCGPART used internally */ 413ae9172d6Scgd#define DIOCGDINFO _IOR('d', 101, struct disklabel) /* get */ 414ae9172d6Scgd#define DIOCSDINFO _IOW('d', 102, struct disklabel) /* set */ 415ae9172d6Scgd#define DIOCWDINFO _IOW('d', 103, struct disklabel) /* set, update disk */ 416ae9172d6Scgd#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ 417ae9172d6Scgd 418ae9172d6Scgd /* do format operation, read or write */ 419ae9172d6Scgd#define DIOCRFORMAT _IOWR('d', 105, struct format_op) 420ae9172d6Scgd#define DIOCWFORMAT _IOWR('d', 106, struct format_op) 421ae9172d6Scgd 422ae9172d6Scgd#define DIOCSSTEP _IOW('d', 107, int) /* set step rate */ 423ae9172d6Scgd#define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */ 4248fa8b773Senami#define DIOCKLABEL _IOW('d', 119, int) /* keep/drop label on close? */ 425ae9172d6Scgd#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */ 426ae9172d6Scgd 427ae9172d6Scgd#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */ 4288fa8b773Senami#define DIOCEJECT _IOW('d', 112, int) /* eject removable disk */ 4298fa8b773Senami#define DIOCLOCK _IOW('d', 113, int) /* lock/unlock pack */ 430ae9172d6Scgd 4318fa8b773Senami /* get default label, clear label */ 4328fa8b773Senami#define DIOCGDEFLABEL _IOR('d', 114, struct disklabel) 4338fa8b773Senami#define DIOCCLRLABEL _IO('d', 115) 434ae9172d6Scgd.Ed 435ae9172d6Scgd.Sh SEE ALSO 436ae9172d6Scgd.Xr disktab 5 , 437a21d1e7aSlukem.Xr disklabel 8 , 438a21d1e7aSlukem.Xr dkctl 8 439c46ab392Sfair.\" .Sh HISTORY 440