summaryrefslogtreecommitdiffstats
path: root/sbin/disklabel
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2004-01-28 19:29:16 +0000
committerobrien <obrien@FreeBSD.org>2004-01-28 19:29:16 +0000
commitb329bb8a2cfc1fb9e2950801b3b871738397a7f1 (patch)
tree5c67714441b3be63a284ce1cd8472bcffc7080f6 /sbin/disklabel
parent51853688ba3a0bf05c1f279215e49513154bd973 (diff)
downloadFreeBSD-src-b329bb8a2cfc1fb9e2950801b3b871738397a7f1.zip
FreeBSD-src-b329bb8a2cfc1fb9e2950801b3b871738397a7f1.tar.gz
This has been disconnected from the build since May 2003. GC it, as
bsdlabel and sunlabel are what we use now.
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/Makefile12
-rw-r--r--sbin/disklabel/disklabel.5525
-rw-r--r--sbin/disklabel/disklabel.8976
-rw-r--r--sbin/disklabel/disklabel.c1581
-rw-r--r--sbin/disklabel/pathnames.h40
5 files changed, 0 insertions, 3134 deletions
diff --git a/sbin/disklabel/Makefile b/sbin/disklabel/Makefile
deleted file mode 100644
index 9884d55..0000000
--- a/sbin/disklabel/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# @(#)Makefile 8.2 (Berkeley) 3/17/94
-# $FreeBSD$
-
-PROG= disklabel
-SRCS= disklabel.c
-MAN= disklabel.5 disklabel.8
-
-.if ${MACHINE} == "pc98"
-CFLAGS+= -DPC98
-.endif
-
-.include <bsd.prog.mk>
diff --git a/sbin/disklabel/disklabel.5 b/sbin/disklabel/disklabel.5
deleted file mode 100644
index e74c603..0000000
--- a/sbin/disklabel/disklabel.5
+++ /dev/null
@@ -1,525 +0,0 @@
-.\" Copyright (c) 1987, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Symmetric Computer Systems.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgment:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93
-.\" $FreeBSD$
-.\"
-.Dd June 5, 1993
-.Dt DISKLABEL 5
-.Os
-.Sh NAME
-.Nm disklabel
-.Nd disk pack label
-.Sh SYNOPSIS
-.In sys/disklabel.h
-.Sh DESCRIPTION
-Each disk or disk pack on a system may contain a disk label
-which provides detailed information
-about the geometry of the disk and the partitions into which the disk
-is divided.
-It should be initialized when the disk is formatted,
-and may be changed later with the
-.Xr disklabel 8
-program.
-This information is used by the system disk driver and by the bootstrap
-program to determine how to program the drive
-and where to find the file systems on the disk partitions.
-Additional information is used by the file system in order
-to use the disk most efficiently and to locate important file system information.
-The description of each partition contains an identifier for the partition
-type (standard file system, swap area, etc.).
-The file system updates the in-core copy of the label if it contains
-incomplete information about the file system.
-.Pp
-The label is located in sector number
-.Dv LABELSECTOR
-of the drive, usually sector 0 where it may be found
-without any information about the disk geometry.
-It is at an offset
-.Dv LABELOFFSET
-from the beginning of the sector, to allow room for the initial bootstrap.
-The disk sector containing the label is normally made read-only
-so that it is not accidentally overwritten by pack-to-pack copies
-or swap operations;
-the
-.Dv DIOCWLABEL
-.Xr ioctl 2 ,
-which is done as needed by the
-.Xr disklabel 8
-program.
-.Pp
-A copy of the in-core label for a disk can be obtained with the
-.Dv DIOCGDINFO
-.Xr ioctl 2 ;
-this works with a file descriptor for a block or character (``raw'') device
-for any partition of the disk.
-The in-core copy of the label is set by the
-.Dv DIOCSDINFO
-.Xr ioctl 2 .
-The offset of a partition cannot generally be changed while it is open,
-nor can it be made smaller while it is open.
-One exception is that any change is allowed if no label was found
-on the disk, and the driver was able to construct only a skeletal label
-without partition information.
-Finally, the
-.Dv DIOCWDINFO
-.Xr ioctl 2
-operation sets the in-core label and then updates the on-disk label;
-there must be an existing label on the disk for this operation to succeed.
-Thus, the initial label for a disk or disk pack must be installed
-by writing to the raw disk.
-All of these operations are normally done using
-.Xr disklabel 8 .
-.Pp
-The format of the disk label, as specified in
-.In sys/disklabel.h ,
-is
-.Bd -literal
-#ifndef _SYS_DISKLABEL_H_
-#define _SYS_DISKLABEL_H_
-
-#ifndef _KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
-
-/*
- * Disk description table, see disktab(5)
- */
-#define _PATH_DISKTAB "/etc/disktab"
-#define DISKTAB "/etc/disktab" /* deprecated */
-
-/*
- * Each disk has a label which includes information about the hardware
- * disk geometry, file system partitions, and drive specific information.
- * The label is in block 0 or 1, possibly offset from the beginning
- * to leave room for a bootstrap, etc.
- */
-
-/* XXX these should be defined per controller (or drive) elsewhere, not here! */
-#ifdef __i386__
-#define LABELSECTOR 1 /* sector containing label */
-#define LABELOFFSET 0 /* offset of label in sector */
-#endif
-
-#ifdef __alpha__
-#define LABELSECTOR 0
-#define LABELOFFSET 64
-#endif
-
-#ifndef LABELSECTOR
-#define LABELSECTOR 0 /* sector containing label */
-#endif
-
-#ifndef LABELOFFSET
-#define LABELOFFSET 64 /* offset of label in sector */
-#endif
-
-#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
-#ifndef MAXPARTITIONS
-#define MAXPARTITIONS 8
-#endif
-
-#define LABEL_PART 2 /* partition containing label */
-#define RAW_PART 2 /* partition containing whole disk */
-#define SWAP_PART 1 /* partition normally containing swap */
-
-#ifndef LOCORE
-struct disklabel {
- u_int32_t d_magic; /* the magic number */
- u_int16_t d_type; /* drive type */
- u_int16_t d_subtype; /* controller/d_type specific */
- char d_typename[16]; /* type name, e.g. "eagle" */
- char d_packname[16]; /* pack identifier */
-
- /* disk geometry: */
- u_int32_t d_secsize; /* # of bytes per sector */
- u_int32_t d_nsectors; /* # of data sectors per track */
- u_int32_t d_ntracks; /* # of tracks per cylinder */
- u_int32_t d_ncylinders; /* # of data cylinders per unit */
- u_int32_t d_secpercyl; /* # of data sectors per cylinder */
- u_int32_t d_secperunit; /* # of data sectors per unit */
-
- /*
- * Spares (bad sector replacements) below are not counted in
- * d_nsectors or d_secpercyl. Spare sectors are assumed to
- * be physical sectors which occupy space at the end of each
- * track and/or cylinder.
- */
- u_int16_t d_sparespertrack; /* # of spare sectors per track */
- u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */
- /*
- * Alternate cylinders include maintenance, replacement, configuration
- * description areas, etc.
- */
- u_int32_t d_acylinders; /* # of alt. cylinders per unit */
-
- /* hardware characteristics: */
- /*
- * d_interleave, d_trackskew and d_cylskew describe perturbations
- * in the media format used to compensate for a slow controller.
- * Interleave is physical sector interleave, set up by the
- * formatter or controller when formatting. When interleaving is
- * in use, logically adjacent sectors are not physically
- * contiguous, but instead are separated by some number of
- * sectors. It is specified as the ratio of physical sectors
- * traversed per logical sector. Thus an interleave of 1:1
- * implies contiguous layout, while 2:1 implies that logical
- * sector 0 is separated by one sector from logical sector 1.
- * d_trackskew is the offset of sector 0 on track N relative to
- * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
- * is the offset of sector 0 on cylinder N relative to sector 0
- * on cylinder N-1.
- */
- u_int16_t d_rpm; /* rotational speed */
- u_int16_t d_interleave; /* hardware sector interleave */
- u_int16_t d_trackskew; /* sector 0 skew, per track */
- u_int16_t d_cylskew; /* sector 0 skew, per cylinder */
- u_int32_t d_headswitch; /* head switch time, usec */
- u_int32_t d_trkseek; /* track-to-track seek, usec */
- u_int32_t d_flags; /* generic flags */
-#define NDDATA 5
- u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */
-#define NSPARE 5
- u_int32_t d_spare[NSPARE]; /* reserved for future use */
- u_int32_t d_magic2; /* the magic number (again) */
- u_int16_t d_checksum; /* xor of data incl. partitions */
-
- /* file system and partition information: */
- u_int16_t d_npartitions; /* number of partitions in following */
- u_int32_t d_bbsize; /* size of boot area at sn0, bytes */
- u_int32_t d_sbsize; /* max size of fs superblock, bytes */
- struct partition { /* the partition table */
- u_int32_t p_size; /* number of sectors in partition */
- u_int32_t p_offset; /* starting sector */
- u_int32_t p_fsize; /* file system basic fragment size */
- u_int8_t p_fstype; /* file system type, see below */
- u_int8_t p_frag; /* file system fragments per block */
- union {
- u_int16_t cpg; /* UFS: FS cylinders per group */
- u_int16_t sgs; /* LFS: FS segment shift */
- } __partition_u1;
-#define p_cpg __partition_u1.cpg
-#define p_sgs __partition_u1.sgs
- } d_partitions[MAXPARTITIONS]; /* actually may be more */
-};
-#else /* LOCORE */
- /*
- * offsets for asm boot files.
- */
- .set d_secsize,40
- .set d_nsectors,44
- .set d_ntracks,48
- .set d_ncylinders,52
- .set d_secpercyl,56
- .set d_secperunit,60
- .set d_end_,276 /* size of disk label */
-#endif /* LOCORE */
-
-/* d_type values: */
-#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
-#define DTYPE_MSCP 2 /* MSCP */
-#define DTYPE_DEC 3 /* other DEC (rk, rl) */
-#define DTYPE_SCSI 4 /* SCSI */
-#define DTYPE_ESDI 5 /* ESDI interface */
-#define DTYPE_ST506 6 /* ST506 etc. */
-#define DTYPE_HPIB 7 /* CS/80 on HP-IB */
-#define DTYPE_HPFL 8 /* HP Fiber-link */
-#define DTYPE_FLOPPY 10 /* floppy */
-#define DTYPE_CCD 11 /* concatenated disk */
-#define DTYPE_VINUM 12 /* vinum volume */
-#define DTYPE_DOC2K 13 /* Msys DiskOnChip */
-
-#if defined(PC98) && !defined(PC98_ATCOMPAT)
-#define DSTYPE_SEC256 0x80 /* physical sector size=256 */
-#endif
-
-#ifdef DKTYPENAMES
-static char *dktypenames[] = {
- "unknown",
- "SMD",
- "MSCP",
- "old DEC",
- "SCSI",
- "ESDI",
- "ST506",
- "HP-IB",
- "HP-FL",
- "type 9",
- "floppy",
- "CCD",
- "Vinum",
- "DOC2K",
- NULL
-};
-#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
-#endif
-
-/*
- * File system type and version.
- * Used to interpret other file system-specific
- * per-partition information.
- */
-#define FS_UNUSED 0 /* unused */
-#define FS_SWAP 1 /* swap */
-#define FS_V6 2 /* Sixth Edition */
-#define FS_V7 3 /* Seventh Edition */
-#define FS_SYSV 4 /* System V */
-#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
-#define FS_V8 6 /* Eighth Edition, 4K blocks */
-#define FS_BSDFFS 7 /* 4.2BSD fast file system */
-#define FS_MSDOS 8 /* MSDOS file system */
-#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */
-#define FS_OTHER 10 /* in use, but unknown/unsupported */
-#define FS_HPFS 11 /* OS/2 high-performance file system */
-#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
-#define FS_BOOT 13 /* partition contains bootstrap */
-#define FS_VINUM 14 /* Vinum drive */
-
-#ifdef DKTYPENAMES
-static char *fstypenames[] = {
- "unused",
- "swap",
- "Version 6",
- "Version 7",
- "System V",
- "4.1BSD",
- "Eighth Edition",
- "4.2BSD",
- "MSDOS",
- "4.4LFS",
- "unknown",
- "HPFS",
- "ISO9660",
- "boot",
- "vinum",
- NULL
-};
-#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
-#endif
-
-/*
- * flags shared by various drives:
- */
-#define D_REMOVABLE 0x01 /* removable media */
-#define D_ECC 0x02 /* supports ECC */
-#define D_BADSECT 0x04 /* supports bad sector forw. */
-#define D_RAMDISK 0x08 /* disk emulator */
-#define D_CHAIN 0x10 /* can do back-back transfers */
-
-/*
- * Drive data for SMD.
- */
-#define d_smdflags d_drivedata[0]
-#define D_SSE 0x1 /* supports skip sectoring */
-#define d_mindist d_drivedata[1]
-#define d_maxdist d_drivedata[2]
-#define d_sdist d_drivedata[3]
-
-/*
- * Drive data for ST506.
- */
-#define d_precompcyl d_drivedata[0]
-#define d_gap3 d_drivedata[1] /* used only when formatting */
-
-/*
- * Drive data for SCSI.
- */
-#define d_blind d_drivedata[0]
-
-#ifndef LOCORE
-/*
- * Structure used to perform a format or other raw operation, returning
- * data and/or register values. Register identification and format
- * are device- and driver-dependent.
- */
-struct format_op {
- char *df_buf;
- int df_count; /* value-result */
- daddr_t df_startblk;
- int df_reg[8]; /* result */
-};
-
-/*
- * Structure used internally to retrieve information about a partition
- * on a disk.
- */
-struct partinfo {
- struct disklabel *disklab;
- struct partition *part;
-};
-
-/* DOS partition table -- located in boot block */
-
-#if defined(PC98) && !defined(PC98_ATCOMPAT)
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSLABELSECTOR 1 /* 0: 256b/s, 1: 512b/s */
-#define DOSPARTOFF 0
-#define NDOSPART 16
-#define DOSPTYP_386BSD 0x94 /* 386BSD partition type */
-#define MBR_PTYPE_FreeBSD 0x94 /* FreeBSD partition type */
-
-struct dos_partition {
- unsigned char dp_mid;
-#define DOSMID_386BSD (0x14|0x80) /* 386bsd|bootable */
- unsigned char dp_sid;
-#define DOSSID_386BSD (0x44|0x80) /* 386bsd|active */
- unsigned char dp_dum1;
- unsigned char dp_dum2;
- unsigned char dp_ipl_sct;
- unsigned char dp_ipl_head;
- unsigned short dp_ipl_cyl;
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_shd; /* starting head */
- unsigned short dp_scyl; /* starting cylinder */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ehd; /* end head */
- unsigned short dp_ecyl; /* end cylinder */
- unsigned char dp_name[16];
-};
-
-#else /* IBMPC */
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSPARTOFF 446
-#define NDOSPART 4
-#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
-
-struct dos_partition {
- unsigned char dp_flag; /* bootstrap flags */
- unsigned char dp_shd; /* starting head */
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_scyl; /* starting cylinder */
- unsigned char dp_typ; /* partition type */
- unsigned char dp_ehd; /* end head */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ecyl; /* end cylinder */
- u_int32_t dp_start; /* absolute starting sector number */
- u_int32_t dp_size; /* partition size in sectors */
-};
-#endif
-
-#define DPSECT(s) ((s) & 0x3f) /* isolate relevant bits of sector */
-#define DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */
-
-/*
- * Disk-specific ioctls.
- */
- /* get and set disklabel; DIOCGPART used internally */
-#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */
-#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */
-#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */
-#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */
-
-#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
-
-#ifdef _KERNEL
-
-/*
- * XXX encoding of disk minor numbers, should be elsewhere.
- *
- * See <sys/reboot.h> for a possibly better encoding.
- *
- * "cpio -H newc" can be used to back up device files with large minor
- * numbers (but not ones >= 2^31). Old cpio formats and all tar formats
- * don't have enough bits, and cpio and tar don't notice the lossage.
- * There are also some sign extension bugs.
- */
-
-/*
- 3 2 1 0
- 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
- _________________________________________________________________
- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
- -----------------------------------------------------------------
- | TYPE |UNIT_2 | SLICE | MAJOR? | UNIT |PART |
- -----------------------------------------------------------------
-*/
-#define dkmakeminor(unit, slice, part) \e
- (((slice) << 16) | (((unit) & 0x1e0) << 16) | \e
- (((unit) & 0x1f) << 3) | (part))
-static __inline dev_t
-dkmodpart(dev_t dev, int part)
-{
- return (makedev(major(dev), (minor(dev) & ~7) | part));
-}
-
-static __inline dev_t
-dkmodslice(dev_t dev, int slice)
-{
- return (makedev(major(dev), (minor(dev) & ~0x1f0000) | (slice << 16)));
-}
-
-#define dkpart(dev) (minor(dev) & 7)
-#define dkslice(dev) ((minor(dev) >> 16) & 0x1f)
-#define dktype(dev) ((minor(dev) >> 25) & 0x7f)
-
-static __inline u_int
-dkunit(dev_t dev)
-{
- return (((minor(dev) >> 16) & 0x1e0) | ((minor(dev) >> 3) & 0x1f));
-}
-
-struct buf;
-struct buf_queue_head;
-
-int bounds_check_with_label(struct buf *bp, struct disklabel *lp,
- int wlabel);
-void diskerr(struct buf *bp, char *what, int pri, int blkdone,
- struct disklabel *lp);
-void disksort(struct buf *ap, struct buf *bp);
-u_int dkcksum struct disklabel *lp);
-char *readdisklabel(dev_t dev, struct disklabel *lp);
-void bufqdisksort(struct buf_queue_head *ap, struct buf *bp);
-int setdisklabel(struct disklabel *olp, struct disklabel *nlp,
- u_long openmask);
-int writedisklabel(dev_t dev, struct disklabel *lp);
-#ifdef __alpha__
-void alpha_fix_srm_checksum(struct buf *bp);
-#endif
-
-#endif /* _KERNEL */
-
-#endif /* LOCORE */
-
-#ifndef _KERNEL
-__BEGIN_DECLS
-struct disklabel *getdiskbyname(const char *);
-__END_DECLS
-#endif
-
-#endif /* !_SYS_DISKLABEL_H_ */
-.Ed
-.Sh SEE ALSO
-.Xr disktab 5 ,
-.Xr disklabel 8
diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8
deleted file mode 100644
index 00dc6d3..0000000
--- a/sbin/disklabel/disklabel.8
+++ /dev/null
@@ -1,976 +0,0 @@
-.\" Copyright (c) 1987, 1988, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Symmetric Computer Systems.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgment:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
-.\" $FreeBSD$
-.\"
-.Dd March 15, 2003
-.Dt DISKLABEL 8
-.Os
-.Sh NAME
-.Nm disklabel
-.Nd read and write disk pack label
-.Sh SYNOPSIS
-.Nm
-.Op Fl r
-.Ar disk
-.Nm
-.Fl w
-.Op Fl nr
-.Op Fl m Ar machine
-.Ar disk type
-.Op Ar packid
-.Nm
-.Fl e
-.Op Fl nr
-.Op Fl m Ar machine
-.Ar disk
-.Nm
-.Fl R
-.Op Fl nr
-.Op Fl m Ar machine
-.Ar disk protofile
-.Pp
-.Nm
-.Fl B
-.Op Fl b Ar boot
-.Op Fl m Ar machine
-.Ar disk
-.Nm
-.Fl w B
-.Op Fl n
-.Op Fl b Ar boot
-.Op Fl m Ar machine
-.Ar disk type
-.Op Ar packid
-.Nm
-.Fl R B
-.Op Fl n
-.Op Fl b Ar boot
-.Op Fl m Ar machine
-.Ar disk protofile
-.Sh DESCRIPTION
-The
-.Nm
-utility
-installs, examines or modifies the label on a disk drive or pack.
-When writing
-the label, it can be used to change the drive identification, the disk
-partitions on the drive, or to replace a damaged label.
-There are several forms
-of the command that read (display), install, or edit the label on a disk.
-In addition,
-.Nm
-can install bootstrap code.
-.Ss Raw or In-Core Label
-The disk label resides close to or at the beginning of each disk slice.
-For faster access, the kernel maintains a copy in core at all times.
-By default, most
-.Nm
-access the in-core copy of the label.
-To access the raw (on-disk) copy, use the
-.Fl r
-option.
-This option allows a label to be installed on a disk without kernel
-support for a label, such as when labels are first installed on a system; it
-must be used when first installing a label on a disk.
-The specific effect of
-.Fl r
-is described under each command.
-.Ss Disk Device Name
-All
-.Nm
-forms require a disk device name, which should always be the raw
-device name representing the disk or slice.
-For example,
-.Pa da0
-represents the entire disk regardless of any
-.Tn DOS
-partitioning,
-and
-.Pa da0s1
-represents a slice.
-Some devices, most notably
-.Xr ccd 4 ,
-require that the
-.Dq whole-disk
-(or
-.Ql c )
-partition be specified.
-For example,
-.Pa ccd0c .
-When specifying the device,
-the
-.Pa /dev/
-path prefix may be omitted;
-the
-.Nm
-utility will automatically prepend it.
-.Ss Reading the Disk Label
-To examine the label on a disk drive, use
-.Nm
-without options:
-.Pp
-.Nm
-.Op Fl r
-.Ar disk
-.Pp
-.Ar disk
-represents the raw disk in question, and may be in the form
-.Pa da0
-or
-.Pa /dev/da0c .
-It will display all of the parameters associated with the drive and its
-partition layout.
-Unless the
-.Fl r
-option is given,
-the kernel's in-core copy of the label is displayed;
-if the disk has no label, or the partition types on the disk are incorrect,
-the kernel may have constructed or modified the label.
-If the
-.Fl r
-option is given,
-.Nm
-reads the label from the raw disk and displays it.
-Both versions are usually
-identical except in the case where a label has not yet been initialized or
-is corrupt.
-.Ss Writing a Standard Label
-To write a standard label, use the form
-.Pp
-.Nm
-.Fl w
-.Op Fl nr
-.Op Fl m Ar machine
-.Ar disk type
-.Op Ar packid
-.Pp
-The required arguments to
-.Nm
-are the drive to be labeled, and the drive type as described in the
-.Xr disktab 5
-file.
-The drive parameters and partitions are taken from that file.
-If different disks of the same physical type are to have different partitions,
-it will be necessary to have separate
-.Xr disktab 5
-entries describing each, or to edit
-the label after installation as described below.
-The optional argument is a
-pack identification string, up to 16 characters long.
-The
-.Ar packid
-must be quoted if it contains blanks.
-.Pp
-If the
-.Fl m
-option is given, then label will be written so that
-it is understood by the target
-.Ar machine ;
-defaults to the current hardware architecture.
-.Pp
-If
-.Fl n
-is used, no data will be written to the device, and instead the
-disk label that would have been written will be printed to standard output.
-.Pp
-If the
-.Fl r
-option is given, the disk sectors containing the label and bootstrap
-will be written directly.
-A side-effect of this is that any existing bootstrap code will be overwritten
-and the disk rendered unbootable.
-See the boot options below for a method of
-writing the and the bootstrap at the same time.
-If
-.Fl r
-is not specified,
-the existing label will be updated via the in-core copy, and any bootstrap
-code will be unaffected.
-If the disk does not already have a label, the
-.Fl r
-option must be used.
-In either case, the kernel's in-core label is replaced.
-.Pp
-For a virgin disk that is not known to
-.Xr disktab 5 ,
-.Ar type
-can be specified as
-.Cm auto .
-In this case, the driver is requested to produce a virgin label for the
-disk.
-This might or might not be successful, depending on whether the
-driver for the disk is able to get the required data without reading
-anything from the disk at all.
-It will likely succeed for all
-.Tn SCSI
-disks, most
-.Tn IDE
-disks, and
-.Cm vnode
-type memory disks
-.Pq Xr md 4 .
-Writing a label to the
-disk is the only supported operation, and the
-.Ar disk
-itself must be provided as the canonical name, i.e., not as a full
-path name.
-.Pp
-For most harddisks, a label based on percentages for most partitions (and
-one partition with a size of
-.Ql * )
-will produce a reasonable configuration.
-.Pp
-PC-based systems have special requirements in order for the
-.Tn BIOS
-to properly recognize a
-.Fx
-disk label.
-Older systems may require what is known as a
-.Dq dangerously-dedicated
-disk label, which creates a fake
-.Tn DOS
-partition to work around problems older
-.Tn BIOS Ns es
-have with modern disk geometries.
-On newer systems, a normal
-.Tn DOS
-partition should generally be created using
-.Xr fdisk 8 ,
-and then a
-.Fx
-disk label within that slice.
-This is described later on in this page.
-.Pp
-Installing a new disk label does not in of itself allow the system to boot
-a kernel using that label.
-Boot blocks must also be installed, which is
-described later on in this manual page.
-.Ss Editing an Existing Disk Label
-To edit an existing disk label, use the form
-.Pp
-.Nm
-.Fl e
-.Op Fl nr
-.Op Fl m Ar machine
-.Ar disk
-.Pp
-This command reads the label from the in-core kernel copy, or directly from the
-disk if the
-.Fl r
-option is also specified.
-The label is written to a file in
-.Tn ASCII
-format, and then supplied to an editor for changes.
-If no editor is specified in the
-.Ev EDITOR
-environment variable,
-.Xr vi 1
-is used.
-When the editor terminates, the label file is used to rewrite the disk label.
-Existing bootstrap code is unchanged regardless of whether
-.Fl r
-was specified.
-.Pp
-If the
-.Fl m
-option is given, then the label will be written so that
-it is understood by the target
-.Ar machine ;
-defaults to the current hardware architecture.
-.Pp
-If
-.Fl n
-is used, no data will be written to the device, and instead the
-disk label that would have been written will be printed to standard output.
-This is
-useful to see how a partitioning scheme will work out for a specific disk.
-.Ss Restoring a Disk Label From a File
-To restore a disk label from a file, use the form
-.Pp
-.Nm
-.Fl R
-.Op Fl nr
-.Op Fl m Ar machine
-.Ar disk protofile
-.Pp
-.Nm
-is capable of restoring a disk label that was previously saved in a file in
-.Tn ASCII
-format.
-The prototype file used to create the label should be in the same format as that
-produced when reading or editing a label.
-Comments are delimited by
-.Ql #
-and newline.
-As when writing a new label, any existing bootstrap code will be
-clobbered if
-.Fl r
-is specified, and will be unaffected otherwise.
-See the boot options below for a
-method of restoring the label and writing the bootstrap at the same time.
-.Pp
-If the
-.Fl m
-option is given, then the label will be written so that
-it is understood by the target
-.Ar machine ;
-defaults to the current hardware architecture.
-.Pp
-If
-.Fl n
-is used, no data will be written to the device, and instead the
-disk label that would have been written will be printed to standard output.
-This is
-useful to see how a partitioning scheme will work out for a specific disk.
-.Ss Installing Bootstraps
-The final three forms of
-.Nm
-are used to install bootstrap code.
-If a
-.Dq dangerously-dedicated
-disk is created for compatibility with older PC systems,
-the raw disk name such as
-.Pa da0
-should be specified.
-If an existing slice should be labeled,
-the slice name such as
-.Pa da0s1
-should be specified,
-and to make it bootable,
-.Tn MBR
-on the base disk should probably be updated; see
-.Xr fdisk 8 .
-.Pp
-.Nm
-.Fl B
-.Op Fl b Ar boot
-.Op Fl m Ar machine
-.Ar disk
-.Pp
-This form installs the bootstrap only.
-It does not change the disk label.
-Never use this command on a base disk, such as
-.Pa da0 ,
-unless the intent is to create a
-.Dq dangerously-dedicated
-disk.
-This command is typically run on a slice such as
-.Pa da0s1 .
-.Pp
-The
-.Fl m
-option should be specified if the label was
-created for a different hardware architecture,
-.Ar machine .
-.Pp
-.Nm
-.Fl w B
-.Op Fl n
-.Op Fl b Ar boot
-.Op Fl m Ar machine
-.Ar disk type
-.Op Ar packid
-.Pp
-This form corresponds to the
-.Dq "write label"
-command described above.
-In addition to writing a new volume label, it also installs the bootstrap.
-If run on a base disk, this command will create a
-.Dq dangerously-dedicated
-label.
-This command is normally run on a slice rather than a base disk.
-.Pp
-If the
-.Fl m
-option is given, then the label and bootstrap will be written so that
-they are understood by the target
-.Ar machine ;
-defaults to the current hardware architecture.
-.Pp
-If
-.Fl n
-is used, no data will be written to the device, and instead the
-disk label that would have been written will be printed to standard output.
-.Pp
-.Nm
-.Fl R B
-.Op Fl n
-.Op Fl b Ar boot
-.Op Fl m Ar machine
-.Ar disk protofile
-.Pp
-This form corresponds to the
-.Dq "restore label"
-command described above.
-In addition to restoring the volume label, it also installs the bootstrap.
-If run on a base disk, this command will create a
-.Dq dangerously-dedicated
-label.
-This command is normally run on a slice rather than a base disk.
-.Pp
-The bootstrap commands always access the disk directly, so it is not necessary
-to specify the
-.Fl r
-option.
-.Pp
-If the
-.Fl m
-option is given, then the label and bootstrap will be written so that
-they are understood by the target
-.Ar machine ;
-defaults to the current hardware architecture.
-.Pp
-If
-.Fl n
-is used, no data will be written to the device, and instead the
-disk label that would have been written will be printed to standard output.
-.Pp
-The bootstrap code is comprised of two boot programs compiled into a single
-.Pa /boot/boot
-image.
-An alternative boot image may be specified with the
-.Fl b
-option.
-.Ss Initializing/Formatting a Bootable Disk From Scratch
-To initialize a disk from scratch, the following sequence is recommended.
-Please note that this will wipe everything that was previously on the disk,
-including any
-.No non- Ns Fx
-slices.
-.Bl -enum
-.It
-Use
-.Xr fdisk 8
-to initialize the hard disk, and create a slice table, referred to
-as the
-.Dq "partition table"
-in
-.Tn DOS .
-.It
-Use
-.Nm
-to define partitions on
-.Fx
-slices created in the previous step.
-.It
-Finally use
-.Xr newfs 8
-to create file systems on new partitions.
-.El
-.Pp
-A typical partitioning scheme would be to have an
-.Ql a
-partition
-of approximately 128MB to hold the root file system, a
-.Ql b
-partition for
-swap, a
-.Ql d
-partition for
-.Pa /var
-(usually 128MB), an
-.Ql e
-partition
-for
-.Pa /var/tmp
-(usually 128MB), an
-.Ql f
-partition for
-.Pa /usr
-(usually around 2GB),
-and finally a
-.Ql g
-partition for
-.Pa /home
-(usually all remaining space).
-Your mileage may vary.
-.Pp
-.Nm fdisk Fl BI Pa da0
-.Pp
-.Nm
-.Fl w B
-.Pa da0s1
-.Cm auto
-.Pp
-.Nm
-.Fl e
-.Pa da0s1
-.Sh FILES
-.Bl -tag -width ".Pa /etc/disktab" -compact
-.It Pa /boot/boot
-Default boot image.
-.It Pa /etc/disktab
-Disk description file.
-.El
-.Sh SAVED FILE FORMAT
-The
-.Nm
-utility
-uses an
-.Tn ASCII
-version of the label when examining, editing, or restoring a disk
-label.
-The format is:
-.Bd -literal -offset 4n
-# /dev/da1c:
-type: SCSI
-disk: da0s1
-label:
-flags:
-bytes/sector: 512
-sectors/track: 51
-tracks/cylinder: 19
-sectors/cylinder: 969
-cylinders: 1211
-sectors/unit: 1173930
-rpm: 3600
-interleave: 1
-trackskew: 0
-cylinderskew: 0
-headswitch: 0 # milliseconds
-track-to-track seek: 0 # milliseconds
-drivedata: 0
-
-8 partitions:
-# size offset fstype [fsize bsize bps/cpg]
- a: 81920 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 84*)
- b: 160000 81920 swap # (Cyl. 84* - 218*)
- c: 1173930 0 unused 0 0 # (Cyl. 0 - 1211*)
- h: 962010 211920 vinum # (Cyl. 218*- 1211*)
-.Ed
-.Pp
-Lines starting with a
-.Ql #
-mark are comments.
-Most of the other specifications are no longer used.
-The ones which must still be set correctly are:
-.Pp
-.Bl -inset
-.It Ar label
-is an optional label, set by the
-.Ar packid
-option when writing a label.
-.It Ar flags
-may be
-.Cm removable , ecc
-or
-.Cm badsect .
-.Cm removable
-is set for removable media drives, but no current
-.Fx
-driver evaluates this
-flag.
-.Cm ecc
-is no longer supported;
-.Cm badsect
-specifies that the drive can perform bad sector remapping.
-.It Ar sectors/unit
-describes the total size of the disk.
-This value must be correct.
-.It Ar "the partition table"
-is the
-.Ux
-partition table, not the
-.Tn DOS
-partition table described in
-.Xr fdisk 8 .
-.El
-.Pp
-The partition table can have up to 8 entries.
-It contains the following information:
-.Bl -tag -width indent
-.It Ar #
-The partition identifier is a single letter in the range
-.Ql a
-to
-.Ql h .
-By convention, partition
-.Ql c
-is reserved to describe the entire disk.
-.It Ar size
-The size of the partition in sectors,
-.Cm K
-(kilobytes - 1024),
-.Cm M
-(megabytes - 1024*1024),
-.Cm G
-(gigabytes - 1024*1024*1024),
-.Cm %
-(percentage of free space
-.Em after
-removing any fixed-size partitions other than partition
-.Ql c ) ,
-or
-.Cm *
-(all remaining free space
-.Em after
-fixed-size and percentage partitions).
-For partition
-.Ql c ,
-a size of
-.Cm *
-indicates the entire disk.
-Lowercase versions of
-.Cm K , M ,
-and
-.Cm G
-are allowed.
-Size and type should be specifed without any spaces between them.
-.Pp
-Example: 2097152, 1G, 1024M and 1048576K are all the same size
-(assuming 512-byte sectors).
-.It Ar offset
-The offset of the start of the partition from the beginning of the
-drive in sectors, or
-.Cm *
-to have
-.Nm
-calculate the correct offset to use (the end of the previous partition plus
-one, ignoring partition
-.Ql c .
-For partition
-.Ql c ,
-.Cm *
-will be interpreted as an offset of 0.
-.It Ar fstype
-Describes the purpose of the partition.
-The example shows all currently used partition types.
-For
-.Tn UFS
-file systems and
-.Xr ccd 4
-partitions, use type
-.Cm 4.2BSD .
-For Vinum drives, use type
-.Cm vinum .
-Other common types are
-.Cm swap
-and
-.Cm unused .
-By convention, partition
-.Ql c
-represents the entire slice and should be of type
-.Cm unused ,
-though
-.Nm
-does not enforce this convention.
-The
-.Nm
-utility
-also knows about a number of other partition types,
-none of which are in current use.
-(See the definitions starting with
-.Dv FS_UNUSED
-in
-.In sys/disklabel.h
-for more details.)
-.It Ar fsize
-For
-.Cm 4.2BSD
-and
-.Tn LFS
-file systems only, the fragment size.
-Defaults to 1024 for partitions smaller than 1GB,
-4096 for partitions 1GB or larger.
-.It Ar bsize
-For
-.Cm 4.2BSD
-and
-.Tn LFS
-file systems only, the block size.
-Defaults to 8192 for partitions smaller than 1GB,
-16384 for partitions 1GB or larger.
-.It Ar bps/cpg
-For
-.Cm 4.2BSD
-file systems, the number of cylinders in a cylinder group.
-For
-.Tn LFS
-file systems, the segment shift value.
-Defaults to 16 for partitions smaller than 1GB,
-64 for partitions 1GB or larger.
-.El
-.Pp
-The remainder of the line is a comment and shows the cylinder allocations based
-on the obsolete (but possibly correct) geometry information about the drive.
-The asterisk
-.Pq Ql *
-indicates that the partition does not begin or end exactly on a
-cylinder boundary.
-.Sh EXAMPLES
-.Dl "disklabel da0s1"
-.Pp
-Display the in-core label for the first slice of the
-.Pa da0
-disk, as obtained via
-.Pa /dev/da0s1 .
-(If the disk is
-.Dq dangerously-dedicated ,
-the base disk name should be specified, such as
-.Pa da0 . )
-.Pp
-.Dl "disklabel da0s1 > savedlabel"
-.Pp
-Save the in-core label for
-.Pa da0s1
-into the file
-.Pa savedlabel .
-This file can be used with the
-.Fl R
-option to restore the label at a later date.
-.Pp
-.Dl "disklabel -w -r /dev/da0s1 da2212 foo"
-.Pp
-Create a label for
-.Pa da0s1
-based on information for
-.Dq da2212
-found in
-.Pa /etc/disktab .
-Any existing bootstrap code will be clobbered
-and the disk rendered unbootable.
-.Pp
-.Dl "disklabel -e -r da0s1"
-.Pp
-Read the on-disk label for
-.Pa da0s1 ,
-edit it, and reinstall in-core as well as on-disk.
-Existing bootstrap code is unaffected.
-.Pp
-.Dl "disklabel -e -r -n da0s1"
-.Pp
-Read the on-disk label for
-.Pa da0s1 ,
-edit it, and display what the new label would be (in sectors).
-It does
-.Em not
-install the new label either in-core or on-disk.
-.Pp
-.Dl "disklabel -r -w da0s1 auto"
-.Pp
-Try to auto-detect the required information from
-.Pa da0s1 ,
-and write a new label to the disk.
-Use another
-.Nm Fl e
-command to edit the
-partitioning and file system information.
-.Pp
-.Dl "disklabel -R da0s1 savedlabel"
-.Pp
-Restore the on-disk and in-core label for
-.Pa da0s1
-from information in
-.Pa savedlabel .
-Existing bootstrap code is unaffected.
-.Pp
-.Dl "disklabel -R -n da0s1 label_layout"
-.Pp
-Display what the label would be for
-.Pa da0s1
-using the partition layout in
-.Pa label_layout .
-This is useful for determining how much space would be alloted for various
-partitions with a labelling scheme using
-.Cm % Ns -based
-or
-.Cm *
-partition sizes.
-.Pp
-.Dl "disklabel -B da0s1"
-.Pp
-Install a new bootstrap on
-.Pa da0s1 .
-The boot code comes from
-.Pa /boot/boot .
-On-disk and in-core labels are unchanged.
-.Pp
-.Dl "disklabel -w -B /dev/da0s1 -b newboot da2212"
-.Pp
-Install a new label and bootstrap.
-The label is derived from
-.Xr disktab 5
-information for
-.Dq da2212 ,
-and installed both in-core and on-disk.
-The bootstrap code comes from the file
-.Pa newboot
-in the current working directory.
-.Bd -literal -offset indent
-dd if=/dev/zero of=/dev/da0 bs=512 count=32
-fdisk -BI da0
-dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
-disklabel -w -B da0s1 auto
-disklabel -e da0s1
-.Ed
-.Pp
-Completely wipe any prior information on the disk, creating a new bootable
-disk with a
-.Tn DOS
-partition table containing one slice, covering the whole disk.
-Initialize the label on this slice,
-then edit it.
-The
-.Xr dd 1
-commands are optional, but may be necessary for some
-.Tn BIOS Ns es
-to properly
-recognize the disk.
-.Pp
-This is an example disk label that uses some of the new partition size types
-such as
-.Cm % , M , G ,
-and
-.Cm * ,
-which could be used as a source file for
-.Dq Li "disklabel -R ad0s1c new_label_file" :
-.Bd -literal -offset 4n
-# /dev/ad0s1c:
-type: ESDI
-disk: ad0s1
-label:
-flags:
-bytes/sector: 512
-sectors/track: 63
-tracks/cylinder: 16
-sectors/cylinder: 1008
-cylinders: 40633
-sectors/unit: 40959009
-rpm: 3600
-interleave: 1
-trackskew: 0
-cylinderskew: 0
-headswitch: 0 # milliseconds
-track-to-track seek: 0 # milliseconds
-drivedata: 0
-
-8 partitions:
-# size offset fstype [fsize bsize bps/cpg]
- a: 400M 0 4.2BSD 4096 16384 75 # (Cyl. 0 - 812*)
- b: 1G * swap
- c: * * unused
- e: 204800 * 4.2BSD
- f: 5g * 4.2BSD
- g: * * 4.2BSD
-.Ed
-.Sh SEE ALSO
-.Xr ccd 4 ,
-.Xr md 4 ,
-.Xr disklabel 5 ,
-.Xr disktab 5 ,
-.Xr boot0cfg 8 ,
-.Xr fdisk 8 ,
-.Xr vinum 8
-.Sh DIAGNOSTICS
-The kernel device drivers will not allow the size of a disk partition
-to be decreased or the offset of a partition to be changed while it is open.
-Some device drivers create a label containing only a single large partition
-if a disk is unlabeled; thus, the label must be written to the
-.Ql a
-partition of the disk while it is open.
-This sometimes requires the desired label to be set in two steps,
-the first one creating at least one other partition,
-and the second one setting the label on the new partition
-while shrinking the
-.Ql a
-partition.
-.Pp
-On some machines, the bootstrap code may not fit entirely in the area
-allocated for it by some file systems.
-As a result,
-it may not be possible to have file systems on some partitions of a
-.Dq bootable
-disk.
-When installing bootstrap code,
-.Nm
-checks for these cases.
-If the installed boot code would overlap a partition of type
-.Dv FS_UNUSED ,
-it is marked as type
-.Dv FS_BOOT .
-The
-.Xr newfs 8
-utility will disallow creation of file systems on
-.Dv FS_BOOT
-partitions.
-Conversely, if a partition has a type other than
-.Dv FS_UNUSED
-or
-.Dv FS_BOOT ,
-.Nm
-will not install bootstrap code that overlaps it.
-.Sh BUGS
-When a disk name is given without a full pathname,
-the constructed device name uses the
-.Ql c
-partition.
-.Pp
-For the i386 architecture, the primary bootstrap sector contains
-an embedded
-.Em fdisk
-table.
-The
-.Nm
-utility takes care to not clobber it when installing a bootstrap only
-.Pq Fl B ,
-or when editing an existing label
-.Pq Fl e ,
-but it unconditionally writes the primary bootstrap program onto
-the disk for
-.Fl w
-or
-.Fl R ,
-thus replacing the
-.Em fdisk
-table by the dummy one in the bootstrap program.
-This is only of
-concern if the disk is fully dedicated, so that the
-.Fx
-disk label
-starts at absolute block 0 on the disk.
-.Pp
-The
-.Nm
-utility
-does not perform all possible error checking.
-Warnings are given if partitions overlap,
-if an absolute offset does not match the expected offset,
-if the
-.Ql c
-partition does not start at 0 or does not cover the entire slice,
-if a partition runs past the end of the device,
-and a number of other errors,
-but no warning is given if space remains unused.
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
deleted file mode 100644
index 3d393ac..0000000
--- a/sbin/disklabel/disklabel.c
+++ /dev/null
@@ -1,1581 +0,0 @@
-/*
- * Copyright (c) 1994, 1995 Gordon W. Ross
- * Copyright (c) 1994 Theo de Raadt
- * All rights reserved.
- * Copyright (c) 1987, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Symmetric Computer Systems.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * This product includes software developed by Theo de Raadt.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk $
- */
-
-#if 0
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1987, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
-/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <sys/disk.h>
-#define DKTYPENAMES
-#define FSTYPENAMES
-#include <sys/disklabel.h>
-
-#include <sys/diskmbr.h>
-#if (DOSPARTOFF != 446 || NDOSPART != 4 || DOSPTYP_386BSD != 0xa5)
-#error <sys/diskmbr.h> has changed
-#else
-#define I386_DOSPARTOFF 446
-#define I386_NDOSPART 4
-#define I386_DOSPTYP_386BSD 0xa5
-#endif
-#undef DOSPARTOFF
-#undef NDOSPART
-#undef DOSPTYP_386BSD
-
-#include <sys/diskpc98.h>
-#if (DOSPARTOFF != 0 || NDOSPART != 16 || DOSPTYP_386BSD != 0x94)
-#error <sys/diskpc98.h> has changed
-#else
-#define PC98_DOSPARTOFF 0
-#define PC98_NDOSPART 16
-#define PC98_DOSPTYP_386BSD 0x94
-#endif
-#undef DOSPARTOFF
-#undef NDOSPART
-#undef DOSPTYP_386BSD
-
-#define IS_PC98 (arch->mach == MACH_PC98)
-#define DOSPARTOFF (IS_PC98 ? PC98_DOSPARTOFF : I386_DOSPARTOFF)
-#define NDOSPART (IS_PC98 ? PC98_NDOSPART : I386_NDOSPART)
-#define DOSPTYP_386BSD (IS_PC98 ? PC98_DOSPTYP_386BSD : I386_DOSPTYP_386BSD)
-
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-
-#include "pathnames.h"
-
-/*
- * Disklabel: read and write disklabels.
- * The label is usually placed on one of the first sectors of the disk.
- * Many machines also place a bootstrap in the same area,
- * in which case the label is embedded in the bootstrap.
- * The bootstrap source must leave space at the proper offset
- * for the label on such machines.
- */
-
-#ifndef BBSIZE
-#define BBSIZE 8192 /* size of boot area, with label */
-#endif
-
-/* FIX! These are too low, but are traditional */
-#define DEFAULT_NEWFS_BLOCK 8192U
-#define DEFAULT_NEWFS_FRAG 1024U
-#define DEFAULT_NEWFS_CPG 16U
-
-#define BIG_NEWFS_BLOCK 16384U
-#define BIG_NEWFS_FRAG 2048U
-#define BIG_NEWFS_CPG 64U
-
-void makelabel(const char *, const char *, struct disklabel *);
-int writelabel(int, void *, struct disklabel *);
-void l_perror(const char *);
-struct disklabel *readlabel(int);
-struct disklabel *makebootarea(void *, struct disklabel *, int);
-void display(FILE *, const struct disklabel *);
-int edit(struct disklabel *, int);
-int editit(void);
-char *skip(char *);
-char *word(char *);
-int getasciilabel(FILE *, struct disklabel *);
-int getasciipartspec(char *, struct disklabel *, int, int);
-int checklabel(struct disklabel *);
-void Warning(const char *, ...) __printflike(1, 2);
-void usage(void);
-struct disklabel *getvirginlabel(void);
-
-#define DEFEDITOR _PATH_VI
-#define streq(a,b) (strcmp(a,b) == 0)
-
-char *dkname;
-char *specname;
-char tmpfil[] = PATH_TMPFILE;
-
-char namebuf[BBSIZE], *np = namebuf;
-struct disklabel lab;
-int64_t bootarea[BBSIZE / 8];
-char blank[] = "";
-char unknown[] = "unknown";
-
-#define MAX_PART ('z')
-#define MAX_NUM_PARTS (1 + MAX_PART - 'a')
-char part_size_type[MAX_NUM_PARTS];
-char part_offset_type[MAX_NUM_PARTS];
-int part_set[MAX_NUM_PARTS];
-
-int installboot; /* non-zero if we should install a boot program */
-char *xxboot; /* primary boot */
-char boot0[MAXPATHLEN];
-
-enum {
- UNSPEC, EDIT, READ, RESTORE, WRITE, WRITEBOOT
-} op = UNSPEC;
-
-enum { ARCH_I386, ARCH_ALPHA, ARCH_IA64 };
-
-enum { MACH_I386, MACH_PC98 };
-
-struct {
- const char *name;
- int arch;
- int mach;
- off_t label_sector;
- off_t label_offset;
-} arches[] = {
- { "i386", ARCH_I386, MACH_I386, 1, 0 },
- { "pc98", ARCH_I386, MACH_PC98, 1, 0 },
- { "alpha", ARCH_ALPHA, ARCH_ALPHA, 0, 64 },
- { "ia64", ARCH_IA64, ARCH_IA64, 1, 0 },
-}, *arch;
-#define NARCHES (int)(sizeof(arches) / sizeof(*arches))
-
-int rflag;
-int disable_write; /* set to disable writing to disk label */
-
-int
-main(int argc, char *argv[])
-{
- struct disklabel *lp;
- FILE *t;
- int ch, f = 0, error = 0, i;
- char *name = 0;
-
- while ((ch = getopt(argc, argv, "Bb:em:nRrs:w")) != -1)
- switch (ch) {
- case 'B':
- ++installboot;
- break;
- case 'b':
- xxboot = optarg;
- break;
- case 'm':
- for (i = 0; i < NARCHES &&
- strcmp(arches[i].name, optarg) != 0;
- i++);
- if (i == NARCHES)
- errx(1, "%s: unknown architecture",
- optarg);
- arch = &arches[i];
- break;
- case 'n':
- disable_write = 1;
- break;
- case 'R':
- if (op != UNSPEC)
- usage();
- op = RESTORE;
- break;
- case 'e':
- if (op != UNSPEC)
- usage();
- op = EDIT;
- break;
- case 'r':
- ++rflag;
- break;
- case 'w':
- if (op != UNSPEC)
- usage();
- op = WRITE;
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
- if (installboot) {
- rflag++;
- if (op == UNSPEC)
- op = WRITEBOOT;
- } else {
- if (op == UNSPEC)
- op = READ;
- xxboot = 0;
- }
- if (argc < 1)
- usage();
-
- if (arch == NULL) {
- for (i = 0; i < NARCHES; i++)
- if (strcmp(arches[i].name,
-#if defined(__i386__)
-#ifdef PC98
- "pc98"
-#else
- "i386"
-#endif
-#elif defined(__alpha__)
- "alpha"
-#elif defined(__ia64__)
- "ia64"
-#else
- "unknown"
-#endif
- ) == 0) {
- arch = &arches[i];
- break;
- }
- if (i == NARCHES)
- errx(1, "unsupported architecture");
- }
-
- dkname = argv[0];
- if (dkname[0] != '/') {
- (void)sprintf(np, "%s%s%c", _PATH_DEV, dkname, 'a' + RAW_PART);
- specname = np;
- np += strlen(specname) + 1;
- } else
- specname = dkname;
- f = open(specname, op == READ ? O_RDONLY : O_RDWR);
- if (f < 0 && errno == ENOENT && dkname[0] != '/') {
- (void)sprintf(specname, "%s%s", _PATH_DEV, dkname);
- np = namebuf + strlen(specname) + 1;
- f = open(specname, op == READ ? O_RDONLY : O_RDWR);
- }
- if (f < 0 && errno == EBUSY) {
- /* lets try to get by with ioctls */
- f = open(specname, O_RDONLY);
- }
- if (f < 0)
- err(4, "%s", specname);
-
- switch(op) {
-
- case UNSPEC:
- break;
-
- case EDIT:
- if (argc != 1)
- usage();
- lp = readlabel(f);
- error = edit(lp, f);
- break;
-
- case READ:
- if (argc != 1)
- usage();
- lp = readlabel(f);
- display(stdout, lp);
- error = checklabel(lp);
- break;
-
- case RESTORE:
- if (argc != 2)
- usage();
- if (!(t = fopen(argv[1], "r")))
- err(4, "%s", argv[1]);
- if (!getasciilabel(t, &lab))
- exit(1);
- lp = makebootarea(bootarea, &lab, f);
- *lp = lab;
- error = writelabel(f, bootarea, lp);
- break;
-
- case WRITE:
- if (argc == 3) {
- name = argv[2];
- argc--;
- }
- if (argc != 2)
- usage();
- makelabel(argv[1], name, &lab);
- lp = makebootarea(bootarea, &lab, f);
- *lp = lab;
- if (checklabel(lp) == 0)
- error = writelabel(f, bootarea, lp);
- break;
-
- case WRITEBOOT:
- {
- struct disklabel tlab;
-
- lp = readlabel(f);
- tlab = *lp;
- if (argc == 2)
- makelabel(argv[1], 0, &lab);
- lp = makebootarea(bootarea, &lab, f);
- *lp = tlab;
- if (checklabel(lp) == 0)
- error = writelabel(f, bootarea, lp);
- break;
- }
- }
- exit(error);
-}
-
-/*
- * Construct a prototype disklabel from /etc/disktab.
- */
-void
-makelabel(const char *type, const char *name, struct disklabel *lp)
-{
- struct disklabel *dp;
-
- if (strcmp(type, "auto") == 0)
- dp = getvirginlabel();
- else
- dp = getdiskbyname(type);
- if (dp == NULL)
- errx(1, "%s: unknown disk type", type);
- *lp = *dp;
- bzero(lp->d_packname, sizeof(lp->d_packname));
- if (name)
- (void)strncpy(lp->d_packname, name, sizeof(lp->d_packname));
-}
-
-int
-writelabel(int f, void *boot, struct disklabel *lp)
-{
- uint64_t *p, sum;
- int i;
-
- if (disable_write) {
- Warning("write to disk label supressed - label was as follows:");
- display(stdout, lp);
- return (0);
- }
-
- lp->d_magic = DISKMAGIC;
- lp->d_magic2 = DISKMAGIC;
- lp->d_checksum = 0;
- lp->d_checksum = dkcksum(lp);
- if (!rflag) {
- if (ioctl(f, DIOCWDINFO, lp) < 0) {
- l_perror("ioctl DIOCWDINFO");
- return (1);
- }
- return (0);
- }
-
- /*
- * First set the kernel disk label,
- * then write a label to the raw disk.
- * If the SDINFO ioctl fails because it is unimplemented,
- * keep going; otherwise, the kernel consistency checks
- * may prevent us from changing the current (in-core)
- * label.
- */
- if (ioctl(f, DIOCSDINFO, lp) < 0 &&
- errno != ENODEV && errno != ENOTTY) {
- l_perror("ioctl DIOCSDINFO");
- return (1);
- }
- (void)lseek(f, (off_t)0, SEEK_SET);
-
- if (arch->arch == ARCH_ALPHA) {
- /*
- * Generate the bootblock checksum for the SRM console.
- */
- for (p = (uint64_t *)boot, i = 0, sum = 0; i < 63; i++)
- sum += p[i];
- p[63] = sum;
- }
- if (ioctl(f, DIOCBSDBB, &boot) == 0)
- return (0);
- if (write(f, boot, lp->d_bbsize) != (int)lp->d_bbsize) {
- warn("write");
- return (1);
- }
- return (0);
-}
-
-void
-l_perror(const char *s)
-{
- switch (errno) {
-
- case ESRCH:
- warnx("%s: no disk label on disk;", s);
- fprintf(stderr, "add \"-r\" to install initial label\n");
- break;
-
- case EINVAL:
- warnx("%s: label magic number or checksum is wrong!", s);
- fprintf(stderr, "(disklabel or kernel is out of date?)\n");
- break;
-
- case EBUSY:
- warnx("%s: open partition would move or shrink", s);
- break;
-
- case EXDEV:
- warnx("%s: '%c' partition must start at beginning of disk",
- s, 'a' + RAW_PART);
- break;
-
- default:
- warn((char *)NULL);
- break;
- }
-}
-
-/*
- * Fetch disklabel for disk.
- * Use ioctl to get label unless -r flag is given.
- */
-struct disklabel *
-readlabel(int f)
-{
- struct disklabel *lp;
-
- if (rflag) {
- if (read(f, bootarea, BBSIZE) < BBSIZE)
- err(4, "%s", specname);
- for (lp = (struct disklabel *)bootarea;
- lp <= (struct disklabel *)
- ((char *)bootarea + BBSIZE - sizeof(*lp));
- lp = (struct disklabel *)((char *)lp + 16))
- if (lp->d_magic == DISKMAGIC &&
- lp->d_magic2 == DISKMAGIC)
- break;
- if (lp > (struct disklabel *)
- ((char *)bootarea + BBSIZE - sizeof(*lp)) ||
- lp->d_magic != DISKMAGIC || lp->d_magic2 != DISKMAGIC ||
- dkcksum(lp) != 0)
- errx(1,
- "bad pack magic number (label is damaged, or pack is unlabeled)");
- } else {
- lp = &lab;
- if (ioctl(f, DIOCGDINFO, lp) < 0)
- err(4, "ioctl DIOCGDINFO");
- }
- return (lp);
-}
-
-/*
- * Construct a bootarea (d_bbsize bytes) in the specified buffer ``boot''
- * Returns a pointer to the disklabel portion of the bootarea.
- */
-struct disklabel *
-makebootarea(void *boot, struct disklabel *dp, int f)
-{
- struct disklabel *lp;
- char *p;
- int b;
- char *dkbasename;
- struct stat sb;
- uint64_t *bootinfo;
- int n;
- char *tmpbuf;
- int i, found, dps;
-
- /* XXX */
- if (dp->d_secsize == 0) {
- dp->d_secsize = DEV_BSIZE;
- dp->d_bbsize = BBSIZE;
- }
- lp = (struct disklabel *)
- ((char *)boot + (arch->label_sector * dp->d_secsize) +
- arch->label_offset);
- bzero((char *)lp, sizeof *lp);
- /*
- * If we are not installing a boot program but we are installing a
- * label on disk then we must read the current bootarea so we don't
- * clobber the existing boot.
- */
- if (!installboot) {
- if (rflag) {
- if (read(f, boot, BBSIZE) < BBSIZE)
- err(4, "%s", specname);
- bzero((char *)lp, sizeof *lp);
- }
- return (lp);
- }
- /*
- * We are installing a boot program. Determine the name(s) and
- * read them into the appropriate places in the boot area.
- */
- if (!xxboot) {
- dkbasename = np;
- if ((p = rindex(dkname, '/')) == NULL)
- p = dkname;
- else
- p++;
- while (*p && !isdigit(*p))
- *np++ = *p++;
- *np++ = '\0';
-
- if (!xxboot) {
- (void)sprintf(boot0, "%s/boot", _PATH_BOOTDIR);
- xxboot = boot0;
- }
- }
-
- b = open(xxboot, O_RDONLY);
- if (b < 0)
- err(4, "%s", xxboot);
- if (fstat(b, &sb) != 0)
- err(4, "%s", xxboot);
- if (arch->arch == ARCH_I386) {
- if (sb.st_size > BBSIZE)
- errx(4, "%s too large", xxboot);
- /*
- * XXX Botch alert.
- * The i386/PC98 has the so-called fdisk table embedded into the
- * primary bootstrap. We take care to not clobber it, but
- * only if it does already contain some data. (Otherwise,
- * the xxboot provides a template.)
- */
- if ((tmpbuf = (char *)malloc((int)dp->d_secsize)) == 0)
- err(4, "%s", xxboot);
- memcpy((void *)tmpbuf, (void *)boot, (int)dp->d_secsize);
-
- if (read(b, boot, BBSIZE) < 0)
- err(4, "%s", xxboot);
-
- /* XXX: rely on some very precise overlaps in definitions */
- dps = IS_PC98 ? sizeof(struct pc98_partition) :
- sizeof(struct dos_partition);
- for (i = DOSPARTOFF, found = 0;
- !found && i < (int)(DOSPARTOFF + NDOSPART * dps);
- i++)
- found = tmpbuf[i] != 0;
- if (found)
- memcpy((void *)&((char *)boot)[DOSPARTOFF],
- (void *)&tmpbuf[DOSPARTOFF],
- NDOSPART * dps);
- free(tmpbuf);
- }
-
- if (arch->arch == ARCH_ALPHA) {
- if (sb.st_size > BBSIZE - dp->d_secsize)
- errx(4, "%s too large", xxboot);
- /*
- * On the alpha, the primary bootstrap starts at the
- * second sector of the boot area. The first sector
- * contains the label and must be edited to contain the
- * size and location of the primary bootstrap.
- */
- n = read(b, (char *)boot + dp->d_secsize,
- BBSIZE - dp->d_secsize);
- if (n < 0)
- err(4, "%s", xxboot);
- bootinfo = (uint64_t *)((char *)boot + 480);
- bootinfo[0] = (n + dp->d_secsize - 1) / dp->d_secsize;
- bootinfo[1] = 1; /* start at sector 1 */
- bootinfo[2] = 0; /* flags (must be zero) */
- }
-
- (void)close(b);
- /*
- * Make sure no part of the bootstrap is written in the area
- * reserved for the label.
- */
- for (p = (char *)lp; p < (char *)lp + sizeof(struct disklabel); p++)
- if (*p)
- errx(2, "bootstrap doesn't leave room for disk label");
- return (lp);
-}
-
-void
-display(FILE *f, const struct disklabel *lp)
-{
- int i, j;
- const struct partition *pp;
-
- fprintf(f, "# %s:\n", specname);
- if (lp->d_type < DKMAXTYPES)
- fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
- else
- fprintf(f, "type: %u\n", lp->d_type);
- fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename),
- lp->d_typename);
- fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname),
- lp->d_packname);
- fprintf(f, "flags:");
- if (lp->d_flags & D_REMOVABLE)
- fprintf(f, " removeable");
- if (lp->d_flags & D_ECC)
- fprintf(f, " ecc");
- if (lp->d_flags & D_BADSECT)
- fprintf(f, " badsect");
- fprintf(f, "\n");
- fprintf(f, "bytes/sector: %lu\n", (u_long)lp->d_secsize);
- fprintf(f, "sectors/track: %lu\n", (u_long)lp->d_nsectors);
- fprintf(f, "tracks/cylinder: %lu\n", (u_long)lp->d_ntracks);
- fprintf(f, "sectors/cylinder: %lu\n", (u_long)lp->d_secpercyl);
- fprintf(f, "cylinders: %lu\n", (u_long)lp->d_ncylinders);
- fprintf(f, "sectors/unit: %lu\n", (u_long)lp->d_secperunit);
- fprintf(f, "rpm: %u\n", lp->d_rpm);
- fprintf(f, "interleave: %u\n", lp->d_interleave);
- fprintf(f, "trackskew: %u\n", lp->d_trackskew);
- fprintf(f, "cylinderskew: %u\n", lp->d_cylskew);
- fprintf(f, "headswitch: %lu\t\t# milliseconds\n",
- (u_long)lp->d_headswitch);
- fprintf(f, "track-to-track seek: %ld\t# milliseconds\n",
- (u_long)lp->d_trkseek);
- fprintf(f, "drivedata: ");
- for (i = NDDATA - 1; i >= 0; i--)
- if (lp->d_drivedata[i])
- break;
- if (i < 0)
- i = 0;
- for (j = 0; j <= i; j++)
- fprintf(f, "%lu ", (u_long)lp->d_drivedata[j]);
- fprintf(f, "\n\n%u partitions:\n", lp->d_npartitions);
- fprintf(f,
- "# size offset fstype [fsize bsize bps/cpg]\n");
- pp = lp->d_partitions;
- for (i = 0; i < lp->d_npartitions; i++, pp++) {
- if (pp->p_size) {
- fprintf(f, " %c: %8lu %8lu ", 'a' + i,
- (u_long)pp->p_size, (u_long)pp->p_offset);
- if (pp->p_fstype < FSMAXTYPES)
- fprintf(f, "%8.8s", fstypenames[pp->p_fstype]);
- else
- fprintf(f, "%8d", pp->p_fstype);
- switch (pp->p_fstype) {
-
- case FS_UNUSED: /* XXX */
- fprintf(f, " %5lu %5lu %5.5s ",
- (u_long)pp->p_fsize,
- (u_long)(pp->p_fsize * pp->p_frag), "");
- break;
-
- case FS_BSDFFS:
- fprintf(f, " %5lu %5lu %5u ",
- (u_long)pp->p_fsize,
- (u_long)(pp->p_fsize * pp->p_frag),
- pp->p_cpg);
- break;
-
- case FS_BSDLFS:
- fprintf(f, " %5lu %5lu %5d",
- (u_long)pp->p_fsize,
- (u_long)(pp->p_fsize * pp->p_frag),
- pp->p_cpg);
- break;
-
- default:
- fprintf(f, "%20.20s", "");
- break;
- }
- fprintf(f, "\t# (Cyl. %4lu",
- (u_long)(pp->p_offset / lp->d_secpercyl));
- if (pp->p_offset % lp->d_secpercyl)
- putc('*', f);
- else
- putc(' ', f);
- fprintf(f, "- %lu",
- (u_long)((pp->p_offset + pp->p_size +
- lp->d_secpercyl - 1) /
- lp->d_secpercyl - 1));
- if (pp->p_size % lp->d_secpercyl)
- putc('*', f);
- fprintf(f, ")\n");
- }
- }
- fflush(f);
-}
-
-int
-edit(struct disklabel *lp, int f)
-{
- int c, fd;
- struct disklabel label;
- FILE *fp;
-
- if ((fd = mkstemp(tmpfil)) == -1 ||
- (fp = fdopen(fd, "w")) == NULL) {
- warnx("can't create %s", tmpfil);
- return (1);
- }
- display(fp, lp);
- fclose(fp);
- for (;;) {
- if (!editit())
- break;
- fp = fopen(tmpfil, "r");
- if (fp == NULL) {
- warnx("can't reopen %s for reading", tmpfil);
- break;
- }
- bzero((char *)&label, sizeof(label));
- if (getasciilabel(fp, &label)) {
- *lp = label;
- if (writelabel(f, bootarea, lp) == 0) {
- fclose(fp);
- (void) unlink(tmpfil);
- return (0);
- }
- }
- fclose(fp);
- printf("re-edit the label? [y]: "); fflush(stdout);
- c = getchar();
- if (c != EOF && c != (int)'\n')
- while (getchar() != (int)'\n')
- ;
- if (c == (int)'n')
- break;
- }
- (void) unlink(tmpfil);
- return (1);
-}
-
-int
-editit(void)
-{
- int pid, xpid;
- int locstat, omask;
- const char *ed;
-
- omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
- while ((pid = fork()) < 0) {
- if (errno == EPROCLIM) {
- warnx("you have too many processes");
- return(0);
- }
- if (errno != EAGAIN) {
- warn("fork");
- return(0);
- }
- sleep(1);
- }
- if (pid == 0) {
- sigsetmask(omask);
- setgid(getgid());
- setuid(getuid());
- if ((ed = getenv("EDITOR")) == (char *)0)
- ed = DEFEDITOR;
- execlp(ed, ed, tmpfil, (char *)0);
- err(1, "%s", ed);
- }
- while ((xpid = wait(&locstat)) >= 0)
- if (xpid == pid)
- break;
- sigsetmask(omask);
- return(!locstat);
-}
-
-char *
-skip(char *cp)
-{
-
- while (*cp != '\0' && isspace(*cp))
- cp++;
- if (*cp == '\0' || *cp == '#')
- return (NULL);
- return (cp);
-}
-
-char *
-word(char *cp)
-{
- char c;
-
- while (*cp != '\0' && !isspace(*cp) && *cp != '#')
- cp++;
- if ((c = *cp) != '\0') {
- *cp++ = '\0';
- if (c != '#')
- return (skip(cp));
- }
- return (NULL);
-}
-
-/*
- * Read an ascii label in from fd f,
- * in the same format as that put out by display(),
- * and fill in lp.
- */
-int
-getasciilabel(FILE *f, struct disklabel *lp)
-{
- char *cp;
- const char **cpp;
- u_int part;
- char *tp, line[BUFSIZ];
- u_long v;
- int lineno = 0, errors = 0;
- int i;
-
- bzero(&part_set, sizeof(part_set));
- bzero(&part_size_type, sizeof(part_size_type));
- bzero(&part_offset_type, sizeof(part_offset_type));
- lp->d_bbsize = BBSIZE; /* XXX */
- lp->d_sbsize = 0; /* XXX */
- while (fgets(line, sizeof(line) - 1, f)) {
- lineno++;
- if ((cp = index(line,'\n')) != 0)
- *cp = '\0';
- cp = skip(line);
- if (cp == NULL)
- continue;
- tp = index(cp, ':');
- if (tp == NULL) {
- fprintf(stderr, "line %d: syntax error\n", lineno);
- errors++;
- continue;
- }
- *tp++ = '\0', tp = skip(tp);
- if (streq(cp, "type")) {
- if (tp == NULL)
- tp = unknown;
- cpp = dktypenames;
- for (; cpp < &dktypenames[DKMAXTYPES]; cpp++)
- if (*cpp && streq(*cpp, tp)) {
- lp->d_type = cpp - dktypenames;
- break;
- }
- if (cpp < &dktypenames[DKMAXTYPES])
- continue;
- v = strtoul(tp, NULL, 10);
- if (v >= DKMAXTYPES)
- fprintf(stderr, "line %d:%s %lu\n", lineno,
- "Warning, unknown disk type", v);
- lp->d_type = v;
- continue;
- }
- if (streq(cp, "flags")) {
- for (v = 0; (cp = tp) && *cp != '\0';) {
- tp = word(cp);
- if (streq(cp, "removeable"))
- v |= D_REMOVABLE;
- else if (streq(cp, "ecc"))
- v |= D_ECC;
- else if (streq(cp, "badsect"))
- v |= D_BADSECT;
- else {
- fprintf(stderr,
- "line %d: %s: bad flag\n",
- lineno, cp);
- errors++;
- }
- }
- lp->d_flags = v;
- continue;
- }
- if (streq(cp, "drivedata")) {
- for (i = 0; (cp = tp) && *cp != '\0' && i < NDDATA;) {
- lp->d_drivedata[i++] = strtoul(cp, NULL, 10);
- tp = word(cp);
- }
- continue;
- }
- if (sscanf(cp, "%lu partitions", &v) == 1) {
- if (v == 0 || v > MAXPARTITIONS) {
- fprintf(stderr,
- "line %d: bad # of partitions\n", lineno);
- lp->d_npartitions = MAXPARTITIONS;
- errors++;
- } else
- lp->d_npartitions = v;
- continue;
- }
- if (tp == NULL)
- tp = blank;
- if (streq(cp, "disk")) {
- strncpy(lp->d_typename, tp, sizeof (lp->d_typename));
- continue;
- }
- if (streq(cp, "label")) {
- strncpy(lp->d_packname, tp, sizeof (lp->d_packname));
- continue;
- }
- if (streq(cp, "bytes/sector")) {
- v = strtoul(tp, NULL, 10);
- if (v == 0 || (v % DEV_BSIZE) != 0) {
- fprintf(stderr,
- "line %d: %s: bad sector size\n",
- lineno, tp);
- errors++;
- } else
- lp->d_secsize = v;
- continue;
- }
- if (streq(cp, "sectors/track")) {
- v = strtoul(tp, NULL, 10);
-#if (ULONG_MAX != 0xffffffffUL)
- if (v == 0 || v > 0xffffffff) {
-#else
- if (v == 0) {
-#endif
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_nsectors = v;
- continue;
- }
- if (streq(cp, "sectors/cylinder")) {
- v = strtoul(tp, NULL, 10);
- if (v == 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_secpercyl = v;
- continue;
- }
- if (streq(cp, "tracks/cylinder")) {
- v = strtoul(tp, NULL, 10);
- if (v == 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_ntracks = v;
- continue;
- }
- if (streq(cp, "cylinders")) {
- v = strtoul(tp, NULL, 10);
- if (v == 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_ncylinders = v;
- continue;
- }
- if (streq(cp, "sectors/unit")) {
- v = strtoul(tp, NULL, 10);
- if (v == 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_secperunit = v;
- continue;
- }
- if (streq(cp, "rpm")) {
- v = strtoul(tp, NULL, 10);
- if (v == 0 || v > USHRT_MAX) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_rpm = v;
- continue;
- }
- if (streq(cp, "interleave")) {
- v = strtoul(tp, NULL, 10);
- if (v == 0 || v > USHRT_MAX) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_interleave = v;
- continue;
- }
- if (streq(cp, "trackskew")) {
- v = strtoul(tp, NULL, 10);
- if (v > USHRT_MAX) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_trackskew = v;
- continue;
- }
- if (streq(cp, "cylinderskew")) {
- v = strtoul(tp, NULL, 10);
- if (v > USHRT_MAX) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_cylskew = v;
- continue;
- }
- if (streq(cp, "headswitch")) {
- v = strtoul(tp, NULL, 10);
- lp->d_headswitch = v;
- continue;
- }
- if (streq(cp, "track-to-track seek")) {
- v = strtoul(tp, NULL, 10);
- lp->d_trkseek = v;
- continue;
- }
- /* the ':' was removed above */
- if (*cp < 'a' || *cp > MAX_PART || cp[1] != '\0') {
- fprintf(stderr,
- "line %d: %s: Unknown disklabel field\n", lineno,
- cp);
- errors++;
- continue;
- }
-
- /* Process a partition specification line. */
- part = *cp - 'a';
- if (part >= lp->d_npartitions) {
- fprintf(stderr,
- "line %d: partition name out of range a-%c: %s\n",
- lineno, 'a' + lp->d_npartitions - 1, cp);
- errors++;
- continue;
- }
- part_set[part] = 1;
-
- if (getasciipartspec(tp, lp, part, lineno) != 0) {
- errors++;
- break;
- }
- }
- errors += checklabel(lp);
- return (errors == 0);
-}
-
-#define NXTNUM(n) do { \
- if (tp == NULL) { \
- fprintf(stderr, "line %d: too few numeric fields\n", lineno); \
- return (1); \
- } else { \
- cp = tp, tp = word(cp); \
- (n) = strtoul(cp, NULL, 10); \
- } \
-} while (0)
-
-/* retain 1 character following number */
-#define NXTWORD(w,n) do { \
- if (tp == NULL) { \
- fprintf(stderr, "line %d: too few numeric fields\n", lineno); \
- return (1); \
- } else { \
- char *tmp; \
- cp = tp, tp = word(cp); \
- (n) = strtoul(cp, &tmp, 10); \
- if (tmp) (w) = *tmp; \
- } \
-} while (0)
-
-/*
- * Read a partition line into partition `part' in the specified disklabel.
- * Return 0 on success, 1 on failure.
- */
-int
-getasciipartspec(char *tp, struct disklabel *lp, int part, int lineno)
-{
- struct partition *pp;
- char *cp;
- const char **cpp;
- u_long v;
-
- pp = &lp->d_partitions[part];
- cp = NULL;
-
- v = 0;
- NXTWORD(part_size_type[part],v);
- if (v == 0 && part_size_type[part] != '*') {
- fprintf(stderr,
- "line %d: %s: bad partition size\n", lineno, cp);
- return (1);
- }
- pp->p_size = v;
-
- v = 0;
- NXTWORD(part_offset_type[part],v);
- if (v == 0 && part_offset_type[part] != '*' &&
- part_offset_type[part] != '\0') {
- fprintf(stderr,
- "line %d: %s: bad partition offset\n", lineno, cp);
- return (1);
- }
- pp->p_offset = v;
- if (tp == NULL) {
- fprintf(stderr, "line %d: missing file system type\n", lineno);
- return (1);
- }
- cp = tp, tp = word(cp);
- for (cpp = fstypenames; cpp < &fstypenames[FSMAXTYPES]; cpp++)
- if (*cpp && streq(*cpp, cp))
- break;
- if (*cpp != NULL) {
- pp->p_fstype = cpp - fstypenames;
- } else {
- if (isdigit(*cp))
- v = strtoul(cp, NULL, 10);
- else
- v = FSMAXTYPES;
- if (v >= FSMAXTYPES) {
- fprintf(stderr,
- "line %d: Warning, unknown file system type %s\n",
- lineno, cp);
- v = FS_UNUSED;
- }
- pp->p_fstype = v;
- }
-
- switch (pp->p_fstype) {
- case FS_UNUSED:
- /*
- * allow us to accept defaults for
- * fsize/frag/cpg
- */
- if (tp) {
- NXTNUM(pp->p_fsize);
- if (pp->p_fsize == 0)
- break;
- NXTNUM(v);
- pp->p_frag = v / pp->p_fsize;
- }
- /* else default to 0's */
- break;
-
- /* These happen to be the same */
- case FS_BSDFFS:
- case FS_BSDLFS:
- if (tp) {
- NXTNUM(pp->p_fsize);
- if (pp->p_fsize == 0)
- break;
- NXTNUM(v);
- pp->p_frag = v / pp->p_fsize;
- NXTNUM(pp->p_cpg);
- } else {
- /*
- * FIX! poor attempt at adaptive
- */
- /* 1 GB */
- if (pp->p_size < 1024*1024*1024 / lp->d_secsize) {
- /*
- * FIX! These are too low, but are traditional
- */
- pp->p_fsize = DEFAULT_NEWFS_FRAG;
- pp->p_frag = DEFAULT_NEWFS_BLOCK /
- DEFAULT_NEWFS_FRAG;
- pp->p_cpg = DEFAULT_NEWFS_CPG;
- } else {
- pp->p_fsize = BIG_NEWFS_FRAG;
- pp->p_frag = BIG_NEWFS_BLOCK /
- BIG_NEWFS_FRAG;
- pp->p_cpg = BIG_NEWFS_CPG;
- }
- }
- default:
- break;
- }
- return (0);
-}
-
-/*
- * Check disklabel for errors and fill in
- * derived fields according to supplied values.
- */
-int
-checklabel(struct disklabel *lp)
-{
- struct partition *pp;
- int i, errors = 0;
- char part;
- u_long total_size, total_percent, current_offset;
- int seen_default_offset;
- int hog_part;
- int j;
- struct partition *pp2;
-
- if (lp->d_secsize == 0) {
- fprintf(stderr, "sector size 0\n");
- return (1);
- }
- if (lp->d_nsectors == 0) {
- fprintf(stderr, "sectors/track 0\n");
- return (1);
- }
- if (lp->d_ntracks == 0) {
- fprintf(stderr, "tracks/cylinder 0\n");
- return (1);
- }
- if (lp->d_ncylinders == 0) {
- fprintf(stderr, "cylinders/unit 0\n");
- errors++;
- }
- if (lp->d_rpm == 0)
- Warning("revolutions/minute 0");
- if (lp->d_secpercyl == 0)
- lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
- if (lp->d_secperunit == 0)
- lp->d_secperunit = lp->d_secpercyl * lp->d_ncylinders;
- if (lp->d_bbsize == 0) {
- fprintf(stderr, "boot block size 0\n");
- errors++;
- } else if (lp->d_bbsize % lp->d_secsize)
- Warning("boot block size %% sector-size != 0");
- if (lp->d_npartitions > MAXPARTITIONS)
- Warning("number of partitions (%lu) > MAXPARTITIONS (%d)",
- (u_long)lp->d_npartitions, MAXPARTITIONS);
-
- /* first allocate space to the partitions, then offsets */
- total_size = 0; /* in sectors */
- total_percent = 0; /* in percent */
- hog_part = -1;
- /* find all fixed partitions */
- for (i = 0; i < lp->d_npartitions; i++) {
- pp = &lp->d_partitions[i];
- if (part_set[i]) {
- if (part_size_type[i] == '*') {
- if (i == RAW_PART) {
- pp->p_size = lp->d_secperunit;
- } else {
- if (hog_part != -1)
- Warning("Too many '*' partitions (%c and %c)",
- hog_part + 'a',i + 'a');
- else
- hog_part = i;
- }
- } else {
- off_t size;
-
- size = pp->p_size;
- switch (part_size_type[i]) {
- case '%':
- total_percent += size;
- break;
- case 'k':
- case 'K':
- size *= 1024ULL;
- break;
- case 'm':
- case 'M':
- size *= 1024ULL * 1024ULL;
- break;
- case 'g':
- case 'G':
- size *= 1024ULL * 1024ULL * 1024ULL;
- break;
- case '\0':
- break;
- default:
- Warning("unknown size specifier '%c' (K/M/G are valid)",part_size_type[i]);
- break;
- }
- /* don't count %'s yet */
- if (part_size_type[i] != '%') {
- /*
- * for all not in sectors, convert to
- * sectors
- */
- if (part_size_type[i] != '\0') {
- if (size % lp->d_secsize != 0)
- Warning("partition %c not an integer number of sectors",
- i + 'a');
- size /= lp->d_secsize;
- pp->p_size = size;
- }
- /* else already in sectors */
- if (i != RAW_PART)
- total_size += size;
- }
- }
- }
- }
- /* handle % partitions - note %'s don't need to add up to 100! */
- if (total_percent != 0) {
- long free_space = lp->d_secperunit - total_size;
- if (total_percent > 100) {
- fprintf(stderr,"total percentage %lu is greater than 100\n",
- total_percent);
- errors++;
- }
-
- if (free_space > 0) {
- for (i = 0; i < lp->d_npartitions; i++) {
- pp = &lp->d_partitions[i];
- if (part_set[i] && part_size_type[i] == '%') {
- /* careful of overflows! and integer roundoff */
- pp->p_size = ((double)pp->p_size/100) * free_space;
- total_size += pp->p_size;
-
- /* FIX we can lose a sector or so due to roundoff per
- partition. A more complex algorithm could avoid that */
- }
- }
- } else {
- fprintf(stderr,
- "%ld sectors available to give to '*' and '%%' partitions\n",
- free_space);
- errors++;
- /* fix? set all % partitions to size 0? */
- }
- }
- /* give anything remaining to the hog partition */
- if (hog_part != -1) {
- lp->d_partitions[hog_part].p_size = lp->d_secperunit - total_size;
- total_size = lp->d_secperunit;
- }
-
- /* Now set the offsets for each partition */
- current_offset = 0; /* in sectors */
- seen_default_offset = 0;
- for (i = 0; i < lp->d_npartitions; i++) {
- part = 'a' + i;
- pp = &lp->d_partitions[i];
- if (part_set[i]) {
- if (part_offset_type[i] == '*') {
- if (i == RAW_PART) {
- pp->p_offset = 0;
- } else {
- pp->p_offset = current_offset;
- seen_default_offset = 1;
- }
- } else {
- /* allow them to be out of order for old-style tables */
- if (pp->p_offset < current_offset &&
- seen_default_offset && i != RAW_PART &&
- pp->p_fstype != FS_VINUM) {
- fprintf(stderr,
-"Offset %ld for partition %c overlaps previous partition which ends at %lu\n",
- (long)pp->p_offset,i+'a',current_offset);
- fprintf(stderr,
-"Labels with any *'s for offset must be in ascending order by sector\n");
- errors++;
- } else if (pp->p_offset != current_offset &&
- i != RAW_PART && seen_default_offset) {
- /*
- * this may give unneeded warnings if
- * partitions are out-of-order
- */
- Warning(
-"Offset %ld for partition %c doesn't match expected value %ld",
- (long)pp->p_offset, i + 'a', current_offset);
- }
- }
- if (i != RAW_PART)
- current_offset = pp->p_offset + pp->p_size;
- }
- }
-
- for (i = 0; i < lp->d_npartitions; i++) {
- part = 'a' + i;
- pp = &lp->d_partitions[i];
- if (pp->p_size == 0 && pp->p_offset != 0)
- Warning("partition %c: size 0, but offset %lu",
- part, (u_long)pp->p_offset);
-#ifdef notdef
- if (pp->p_size % lp->d_secpercyl)
- Warning("partition %c: size %% cylinder-size != 0",
- part);
- if (pp->p_offset % lp->d_secpercyl)
- Warning("partition %c: offset %% cylinder-size != 0",
- part);
-#endif
- if (pp->p_offset > lp->d_secperunit) {
- fprintf(stderr,
- "partition %c: offset past end of unit\n", part);
- errors++;
- }
- if (pp->p_offset + pp->p_size > lp->d_secperunit) {
- fprintf(stderr,
- "partition %c: partition extends past end of unit\n",
- part);
- errors++;
- }
- if (i == RAW_PART)
- {
- if (pp->p_fstype != FS_UNUSED)
- Warning("partition %c is not marked as unused!",part);
- if (pp->p_offset != 0)
- Warning("partition %c doesn't start at 0!",part);
- if (pp->p_size != lp->d_secperunit)
- Warning("partition %c doesn't cover the whole unit!",part);
-
- if ((pp->p_fstype != FS_UNUSED) || (pp->p_offset != 0) ||
- (pp->p_size != lp->d_secperunit)) {
- Warning("An incorrect partition %c may cause problems for "
- "standard system utilities",part);
- }
- }
-
- /* check for overlaps */
- /* this will check for all possible overlaps once and only once */
- for (j = 0; j < i; j++) {
- pp2 = &lp->d_partitions[j];
- if (j != RAW_PART && i != RAW_PART &&
- pp->p_fstype != FS_VINUM &&
- pp2->p_fstype != FS_VINUM &&
- part_set[i] && part_set[j]) {
- if (pp2->p_offset < pp->p_offset + pp->p_size &&
- (pp2->p_offset + pp2->p_size > pp->p_offset ||
- pp2->p_offset >= pp->p_offset)) {
- fprintf(stderr,"partitions %c and %c overlap!\n",
- j + 'a', i + 'a');
- errors++;
- }
- }
- }
- }
- for (; i < MAXPARTITIONS; i++) {
- part = 'a' + i;
- pp = &lp->d_partitions[i];
- if (pp->p_size || pp->p_offset)
- Warning("unused partition %c: size %d offset %lu",
- 'a' + i, pp->p_size, (u_long)pp->p_offset);
- }
- return (errors);
-}
-
-/*
- * When operating on a "virgin" disk, try getting an initial label
- * from the associated device driver. This might work for all device
- * drivers that are able to fetch some initial device parameters
- * without even having access to a (BSD) disklabel, like SCSI disks,
- * most IDE drives, or vn devices.
- *
- * The device name must be given in its "canonical" form.
- */
-struct disklabel *
-getvirginlabel(void)
-{
- static struct disklabel loclab;
- struct partition *dp;
- char lnamebuf[BBSIZE];
- int f;
- u_int secsize, u;
- off_t mediasize;
-
- if (dkname[0] == '/') {
- warnx("\"auto\" requires the usage of a canonical disk name");
- return (NULL);
- }
- (void)snprintf(lnamebuf, BBSIZE, "%s%s", _PATH_DEV, dkname);
- if ((f = open(lnamebuf, O_RDONLY)) == -1) {
- warn("cannot open %s", lnamebuf);
- return (NULL);
- }
-
- /* New world order */
- if ((ioctl(f, DIOCGMEDIASIZE, &mediasize) != 0) ||
- (ioctl(f, DIOCGSECTORSIZE, &secsize) != 0)) {
- close (f);
- return (NULL);
- }
- memset(&loclab, 0, sizeof loclab);
- loclab.d_magic = DISKMAGIC;
- loclab.d_magic2 = DISKMAGIC;
- loclab.d_secsize = secsize;
- loclab.d_secperunit = mediasize / secsize;
-
- /*
- * Nobody in these enligthened days uses the CHS geometry for
- * anything, but nontheless try to get it right. If we fail
- * to get any good ideas from the device, construct something
- * which is IBM-PC friendly.
- */
- if (ioctl(f, DIOCGFWSECTORS, &u) == 0)
- loclab.d_nsectors = u;
- else
- loclab.d_nsectors = 63;
- if (ioctl(f, DIOCGFWHEADS, &u) == 0)
- loclab.d_ntracks = u;
- else if (loclab.d_secperunit <= 63*1*1024)
- loclab.d_ntracks = 1;
- else if (loclab.d_secperunit <= 63*16*1024)
- loclab.d_ntracks = 16;
- else
- loclab.d_ntracks = 255;
- loclab.d_secpercyl = loclab.d_ntracks * loclab.d_nsectors;
- loclab.d_ncylinders = loclab.d_secperunit / loclab.d_secpercyl;
- loclab.d_npartitions = MAXPARTITIONS;
-
- /* Various (unneeded) compat stuff */
- loclab.d_rpm = 3600;
- loclab.d_bbsize = BBSIZE;
- loclab.d_interleave = 1;;
- strncpy(loclab.d_typename, "amnesiac",
- sizeof(loclab.d_typename));
-
- dp = &loclab.d_partitions[RAW_PART];
- dp->p_size = loclab.d_secperunit;
- loclab.d_checksum = dkcksum(&loclab);
- close (f);
- return (&loclab);
-}
-
-
-/*VARARGS1*/
-void
-Warning(const char *fmt, ...)
-{
- va_list ap;
-
- fprintf(stderr, "Warning, ");
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
-}
-
-void
-usage(void)
-{
-
- fprintf(stderr,
- "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- "usage: disklabel [-r] disk",
- "\t\t(to read label)",
- " disklabel -w [-nr] [-m machine] disk type [packid]",
- "\t\t(to write label with existing boot program)",
- " disklabel -e [-nr] [-m machine] disk",
- "\t\t(to edit label)",
- " disklabel -R [-nr] [-m machine] disk protofile",
- "\t\t(to restore label with existing boot program)",
- " disklabel -B [-b boot] [-m machine] disk",
- "\t\t(to install boot program with existing on-disk label)",
- " disklabel -w -B [-n] [-b boot] [-m machine] disk type [packid]",
- "\t\t(to write label and install boot program)",
- " disklabel -R -B [-n] [-b boot] [-m machine] disk protofile",
- "\t\t(to restore label and install boot program)"
- );
- exit(1);
-}
diff --git a/sbin/disklabel/pathnames.h b/sbin/disklabel/pathnames.h
deleted file mode 100644
index c09d469..0000000
--- a/sbin/disklabel/pathnames.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/5/93
- * $FreeBSD$
- */
-
-#include <paths.h>
-
-#define _PATH_BOOTDIR "/boot"
-#define PATH_TMPFILE "/tmp/EdDk.XXXXXXXXXX"
OpenPOWER on IntegriCloud