mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
No need to make sunlabel anymore
It was only built on sparc64. Since it wasn't a general tool on other architectures, no need to keep it around for another release. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D23524
This commit is contained in:
parent
75ababf8b5
commit
ab9848aa9b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357624
|
@ -1,4 +0,0 @@
|
|||
# $FreeBSD$
|
||||
|
||||
SUBDIR += bsdlabel
|
||||
SUBDIR += sunlabel
|
|
@ -1,20 +0,0 @@
|
|||
# $FreeBSD$
|
||||
|
||||
PROG= sunlabel
|
||||
SRCS= sunlabel.c sunlabel_enc.c
|
||||
MAN= sunlabel.8
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "sparc64"
|
||||
LINKS= ${BINDIR}/sunlabel ${BINDIR}/disklabel
|
||||
MLINKS= sunlabel.8 disklabel.8
|
||||
.endif
|
||||
|
||||
LIBADD= geom
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
test: ${PROG}
|
||||
sh ${.CURDIR}/runtest.sh
|
||||
|
||||
testx: ${PROG}
|
||||
sh -x ${.CURDIR}/runtest.sh
|
|
@ -1,16 +0,0 @@
|
|||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libgeom \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
|
@ -1,157 +0,0 @@
|
|||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
TMP=/tmp/$$.
|
||||
set -e
|
||||
MD=`mdconfig -a -t malloc -s 2m`
|
||||
trap "exec 7</dev/null; rm -f ${TMP}* ; mdconfig -d -u ${MD}" EXIT INT TERM
|
||||
|
||||
./sunlabel -r -w $MD auto
|
||||
|
||||
dd if=/dev/$MD of=${TMP}i0 count=16 > /dev/null 2>&1
|
||||
./sunlabel $MD > ${TMP}l0
|
||||
|
||||
sed '
|
||||
/ c:/{
|
||||
p
|
||||
s/c:/a:/
|
||||
s/3969/1024/
|
||||
}
|
||||
' ${TMP}l0 > ${TMP}l1
|
||||
|
||||
./sunlabel -R $MD ${TMP}l1
|
||||
if [ -c /dev/${MD}a ] ; then
|
||||
echo "PASS: Created a: partition" 1>&2
|
||||
else
|
||||
echo "FAIL: Did not create a: partition" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Spoil and rediscover
|
||||
|
||||
true > /dev/${MD}
|
||||
if [ -c /dev/${MD}a ] ; then
|
||||
echo "PASS: Recreated a: partition after spoilage" 1>&2
|
||||
else
|
||||
echo "FAIL: Did not recreate a: partition after spoilage" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
dd if=/dev/$MD of=${TMP}i1 count=16 > /dev/null 2>&1
|
||||
sed '
|
||||
/ c:/{
|
||||
p
|
||||
s/c:/a:/
|
||||
s/3969/2048/
|
||||
}
|
||||
' ${TMP}l0 > ${TMP}l2
|
||||
|
||||
./sunlabel -R $MD ${TMP}l2
|
||||
dd if=/dev/$MD of=${TMP}i2 count=16 > /dev/null 2>&1
|
||||
|
||||
exec 7< /dev/${MD}a
|
||||
|
||||
for t in a c
|
||||
do
|
||||
if dd if=${TMP}i2 of=/dev/${MD}$t 2>/dev/null ; then
|
||||
echo "PASS: Could rewrite same label to ...$t while ...a open" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not rewrite same label to ...$t while ...a open" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i1 of=/dev/${MD}$t 2>/dev/null ; then
|
||||
echo "FAIL: Could label with smaller ...a to ...$t while ...a open" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could not label with smaller ...a to ...$t while ...a open" 1>&2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i0 of=/dev/${MD}$t 2>/dev/null ; then
|
||||
echo "FAIL: Could write label missing ...a to ...$t while ...a open" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could not write label missing ...a to ...$t while ...a open" 1>&2
|
||||
fi
|
||||
done
|
||||
|
||||
exec 7< /dev/null
|
||||
|
||||
if dd if=${TMP}i0 of=/dev/${MD}c 2>/dev/null ; then
|
||||
echo "PASS: Could write missing ...a label to ...c" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not write missing ...a label to ...c" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i2 of=/dev/${MD}c 2>/dev/null ; then
|
||||
echo "PASS: Could write large ...a label to ...c" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not write large ...a label to ...c" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i1 of=/dev/${MD}c 2>/dev/null ; then
|
||||
echo "PASS: Could write small ...a label to ...c" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not write small ...a label to ...c" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i2 of=/dev/${MD}a 2>/dev/null ; then
|
||||
echo "PASS: Could increase size of ...a by writing to ...a" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not increase size of ...a by writing to ...a" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i1 of=/dev/${MD}a 2>/dev/null ; then
|
||||
echo "FAIL: Could decrease size of ...a by writing to ...a" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could not decrease size of ...a by writing to ...a" 1>&2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i0 of=/dev/${MD}a 2>/dev/null ; then
|
||||
echo "FAIL: Could delete ...a by writing to ...a" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could not delete ...a by writing to ...a" 1>&2
|
||||
fi
|
||||
|
||||
if ./sunlabel -B -b ${TMP}i0 ${MD} ; then
|
||||
if [ ! -c /dev/${MD}a ] ; then
|
||||
echo "FAILED: Writing bootcode killed ...a" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could write bootcode while closed" 1>&2
|
||||
fi
|
||||
else
|
||||
echo "FAILED: Could not write bootcode while closed" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
exec 7> /dev/${MD}c
|
||||
if ktrace ./sunlabel -B -b ${TMP}i0 ${MD} ; then
|
||||
if [ ! -c /dev/${MD}a ] ; then
|
||||
echo "FAILED: Writing bootcode killed ...a" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could write bootcode while open" 1>&2
|
||||
fi
|
||||
else
|
||||
echo "FAILED: Could not write bootcode while open" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
exec 7> /dev/null
|
||||
|
||||
if dd if=${TMP}i0 of=/dev/${MD}c 2>/dev/null ; then
|
||||
echo "PASS: Could delete ...a by writing to ...c" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not delete ...a by writing to ...c" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# XXX: need to add a 'b' partition and check for overlaps.
|
||||
|
||||
exit 0
|
|
@ -1,125 +0,0 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Copyright (c) 2004,2005 Joerg Wunsch
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)sun_disklabel.h 8.1 (Berkeley) 6/11/93
|
||||
* $NetBSD: disklabel.h,v 1.2 1998/08/22 14:55:28 mrg Exp $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SUN_DISKLABEL_H_
|
||||
#define _SYS_SUN_DISKLABEL_H_
|
||||
|
||||
/*
|
||||
* SunOS/Solaris disk label layout (partial).
|
||||
*
|
||||
* Suns disk label format contains a lot of historical baggage which we
|
||||
* ignore entirely. The structure below contains the relevant bits and the
|
||||
* _enc/_dec functions encode/decode only these fields.
|
||||
*/
|
||||
|
||||
#define SUN_DKMAGIC 55998
|
||||
#define SUN_NPART 8
|
||||
#define SUN_RAWPART 2
|
||||
#define SUN_SIZE 512
|
||||
#define SUN_VTOC_VERSION 1
|
||||
#define SUN_VTOC_SANE 0x600DDEEE /* SVR4-compatible VTOC is "sane". */
|
||||
#define SUN_VOLNAME_LEN 8
|
||||
/*
|
||||
* XXX: I am actually not sure if this should be "16 sectors" or "8192 bytes".
|
||||
* XXX: Considering that Sun went to the effort of getting 512 byte compatible
|
||||
* XXX: CDROM drives produced my guess is that Sun computers stand little or
|
||||
* XXX: even no chance of running, much less booting on !=512 byte media.
|
||||
* XXX: Define this is in terms of bytes since that is easier for us.
|
||||
*/
|
||||
#define SUN_BOOTSIZE 8192
|
||||
|
||||
/* partition info */
|
||||
struct sun_dkpart {
|
||||
u_int32_t sdkp_cyloffset; /* starting cylinder */
|
||||
u_int32_t sdkp_nsectors; /* number of sectors */
|
||||
};
|
||||
|
||||
struct sun_vtoc_info {
|
||||
u_int16_t svtoc_tag; /* partition tag */
|
||||
u_int16_t svtoc_flag; /* partition flags */
|
||||
};
|
||||
|
||||
/* known partition tag values */
|
||||
#define VTOC_UNASSIGNED 0x00
|
||||
#define VTOC_BOOT 0x01
|
||||
#define VTOC_ROOT 0x02
|
||||
#define VTOC_SWAP 0x03
|
||||
#define VTOC_USR 0x04
|
||||
#define VTOC_BACKUP 0x05 /* "c" partition, covers entire disk */
|
||||
#define VTOC_STAND 0x06
|
||||
#define VTOC_VAR 0x07
|
||||
#define VTOC_HOME 0x08
|
||||
#define VTOC_ALTSCTR 0x09 /* alternate sector partition */
|
||||
#define VTOC_CACHE 0x0a /* Solaris cachefs partition */
|
||||
#define VTOC_VXVM_PUB 0x0e /* VxVM public region */
|
||||
#define VTOC_VXVM_PRIV 0x0f /* VxVM private region */
|
||||
|
||||
/* VTOC partition flags */
|
||||
#define VTOC_UNMNT 0x01 /* unmountable partition */
|
||||
#define VTOC_RONLY 0x10 /* partition is read/only */
|
||||
|
||||
struct sun_disklabel {
|
||||
char sl_text[128];
|
||||
|
||||
/* SVR4 VTOC information */
|
||||
u_int32_t sl_vtoc_vers; /* == SUN_VTOC_VERSION */
|
||||
char sl_vtoc_volname[SUN_VOLNAME_LEN];
|
||||
u_int16_t sl_vtoc_nparts; /* == SUN_NPART */
|
||||
struct sun_vtoc_info sl_vtoc_map[SUN_NPART]; /* partition tag/flag */
|
||||
u_int32_t sl_vtoc_sane; /* == SUN_VTOC_SANE */
|
||||
|
||||
/* Sun label information */
|
||||
u_int16_t sl_rpm; /* rotational speed */
|
||||
u_int16_t sl_pcylinders; /* number of physical cyls */
|
||||
u_int16_t sl_sparespercyl; /* spare sectors per cylinder */
|
||||
u_int16_t sl_interleave; /* interleave factor */
|
||||
u_int16_t sl_ncylinders; /* data cylinders */
|
||||
u_int16_t sl_acylinders; /* alternate cylinders */
|
||||
u_int16_t sl_ntracks; /* tracks per cylinder */
|
||||
u_int16_t sl_nsectors; /* sectors per track */
|
||||
struct sun_dkpart sl_part[SUN_NPART]; /* partition layout */
|
||||
u_int16_t sl_magic; /* == SUN_DKMAGIC */
|
||||
};
|
||||
|
||||
int sunlabel_dec(void const *pp, struct sun_disklabel *sl);
|
||||
void sunlabel_enc(void *pp, struct sun_disklabel *sl);
|
||||
|
||||
#endif /* _SYS_SUN_DISKLABEL_H_ */
|
|
@ -1,432 +0,0 @@
|
|||
.\" Copyright (c) 2004
|
||||
.\" David E. O'Brien. All rights reserved.
|
||||
.\" Copyright (c) 2004, 2005
|
||||
.\" Joerg Wunsch. 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 30, 2005
|
||||
.Dt SUNLABEL 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm sunlabel
|
||||
.Nd read and write disk pack label suitable for Sun's OpenBoot PROM
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl r
|
||||
.Op Fl c No \&| Fl h
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl B
|
||||
.Op Fl b Ar boot1
|
||||
.Op Fl n
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl R
|
||||
.Op Fl B Op Fl b Ar boot1
|
||||
.Op Fl r
|
||||
.Op Fl n
|
||||
.Op Fl c
|
||||
.Ar disk protofile
|
||||
.Nm
|
||||
.Fl e
|
||||
.Op Fl B Op Fl b Ar boot1
|
||||
.Op Fl r
|
||||
.Op Fl n
|
||||
.Op Fl c
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl w
|
||||
.Op Fl B Op Fl b Ar boot1
|
||||
.Op Fl r
|
||||
.Op Fl n
|
||||
.Op Fl c
|
||||
.Ar disk type
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
installs, examines or modifies the
|
||||
.Em Sun OpenBoot PROM
|
||||
label on a disk.
|
||||
In addition,
|
||||
.Nm
|
||||
can install bootstrap code.
|
||||
.Ss Introduction
|
||||
The label occupies the first sector (i.e., 512 bytes) of each disk.
|
||||
It starts with a textual description which by convention also mentions
|
||||
the disk geometry in textual form (number of cylinders, alternate
|
||||
cylinders, heads, and sectors per track), optionally followed by a
|
||||
table of SVR4-compatible VTOC tags and flags per partition, followed
|
||||
by the partition table itself.
|
||||
Finally, a checksum is recorded to ensure the label has not been
|
||||
tampered with.
|
||||
.Pp
|
||||
The
|
||||
.Em Sun OpenBoot PROM
|
||||
label allows for 8 disk partitions.
|
||||
The partition table lists the starting cylinder of the partition,
|
||||
plus the size of the partition in 512-byte sectors.
|
||||
Thus, partitions in the
|
||||
.Em Sun OpenBoot PROM
|
||||
must always start at a cylinder boundary (for whatever geometry
|
||||
emulation has been chosen).
|
||||
.Pp
|
||||
The optional SVR4-compatible VTOC tag and flags table is not used
|
||||
by the
|
||||
.Fx
|
||||
kernel.
|
||||
It is maintained solely for compatibility with the
|
||||
.Tn Solaris
|
||||
operating system that might share disks with
|
||||
.Fx
|
||||
on the same hardware platform.
|
||||
.Pp
|
||||
The
|
||||
.Em Sun OpenBoot PROM
|
||||
label is natively understood by the underlying hardware, which can
|
||||
bootstrap from a single partition entry, as opposed to the very first
|
||||
block(s) of the entire disk as on many other hardware platforms.
|
||||
.Pp
|
||||
Note that the hardware platform mandates that two cylinders are set
|
||||
aside as
|
||||
.Em alternate cylinders
|
||||
which are not available to user programs (and not even through the
|
||||
.Dq Li backup
|
||||
partition).
|
||||
.Ss Options
|
||||
Options are listed in alphabetical order here.
|
||||
Note that only those option combinations listed under
|
||||
.Sx SYNOPSIS
|
||||
are allowable.
|
||||
.Bl -tag -width ".Fl b Ar bootpath"
|
||||
.It Fl b Ar bootpath
|
||||
Specify that
|
||||
.Ar bootpath
|
||||
is to be used as the boot image, rather than the default of
|
||||
.Pa /boot/boot1 .
|
||||
.It Fl B
|
||||
Install bootstrap code onto the disk.
|
||||
Note that since the underlying hardware platform bootstraps from
|
||||
partitions, not disks, this operation is only useful if there is
|
||||
a partition starting at offset 0.
|
||||
.It Fl c
|
||||
Use cylinders for partition size display rather than
|
||||
(512-byte) sectors.
|
||||
This also changes the default interpretation of the partition
|
||||
size entries when editing the label, or reading from a prototype
|
||||
file.
|
||||
Thus, prototype files are only compatible when both, obtaining
|
||||
the file and re-installing it is done using the same
|
||||
.Fl c
|
||||
option setting.
|
||||
.It Fl e
|
||||
Enter edit mode.
|
||||
See
|
||||
.Sx Edit mode
|
||||
below for a more detailed explanation.
|
||||
.It Fl h
|
||||
When displaying the label, make the partition size and offset
|
||||
values
|
||||
.Dq human readable .
|
||||
The displayed numbers will get a suffix of
|
||||
.Ql B
|
||||
for bytes,
|
||||
.Ql K
|
||||
for 1024 bytes each,
|
||||
.Ql M
|
||||
for 1048576 bytes each, or
|
||||
.Ql G
|
||||
for 1073741824 bytes each appended.
|
||||
Note that due to possible rounding errors, prototype files
|
||||
obtained using the
|
||||
.Fl h
|
||||
option are not suited for re-installing using the
|
||||
.Fl R
|
||||
option.
|
||||
.It Fl n
|
||||
No changes.
|
||||
All operations, checks etc., are performed normally, but nothing
|
||||
is written to disk.
|
||||
.It Fl r
|
||||
Obsolete option that used to indicate that the operation should
|
||||
be done directly on disk, as opposed through the respective kernel
|
||||
services.
|
||||
Ignored.
|
||||
.It Fl R
|
||||
Restore label from the prototype in
|
||||
.Ar protofile .
|
||||
A prototype file is simply the textual representation of the
|
||||
label as printed using the first form of the
|
||||
.Nm
|
||||
utility shown in the
|
||||
.Sx SYNOPSIS .
|
||||
Note that the
|
||||
.Fl c
|
||||
option used to obtain the prototype must match the option used
|
||||
when restoring the label (both present, or both absent).
|
||||
.It Fl w
|
||||
Write mode.
|
||||
Suitable to write an initial label to disk.
|
||||
The
|
||||
.Ar type
|
||||
argument used to be an entry into a table of predefined labels,
|
||||
but this functionality is not supported by
|
||||
.Nm .
|
||||
Instead, the only allowable
|
||||
.Ar type
|
||||
argument is the string
|
||||
.Dq Li auto ,
|
||||
indicating that an automatically created label should be written
|
||||
to disk.
|
||||
This automatism will try to create an initial label that fits as
|
||||
best as possible into the available disk capacity.
|
||||
.El
|
||||
.Pp
|
||||
If neither of the
|
||||
.Fl e , R ,
|
||||
or
|
||||
.Fl w
|
||||
options are present, the existing label for
|
||||
.Ar disk
|
||||
will be printed to standard output.
|
||||
.Pp
|
||||
The
|
||||
.Ar disk
|
||||
argument
|
||||
must be given as a plain disk name, without any leading
|
||||
.Pa /dev/ .
|
||||
.Ss Edit mode
|
||||
In edit mode, the existing label from
|
||||
.Ar disk
|
||||
will be read, and put into a template file.
|
||||
The command referenced by the
|
||||
.Ev EDITOR
|
||||
environmental variable will be started to allow the user
|
||||
to edit the label.
|
||||
The label is then checked and examined for any errors.
|
||||
If no errors have been found, the new label is written to disk.
|
||||
If there were any errors, a message is printed to standard
|
||||
error output, and the user is given the opportunity to edit
|
||||
the template file again.
|
||||
If accepted, editing starts over.
|
||||
If declined, no changes will
|
||||
be written to disk.
|
||||
.Pp
|
||||
The label presented for editing is the same as the standard
|
||||
printout, with some added hints about the possible options to
|
||||
specify the sector size and starting cylinder.
|
||||
The following areas in the template can be edited:
|
||||
.Bl -tag -width indent
|
||||
.It Sy Textual label, geometry emulation
|
||||
The line
|
||||
.D1 Li text: Ar XXXX Li cyl Ar CC Li alt 2 hd Ar HH Li sec Ar SS
|
||||
represents the label text.
|
||||
It must be retained exactly in the form shown.
|
||||
The editable text
|
||||
.Ar XXXX
|
||||
is a simple (non-whitespace) text describing the disk.
|
||||
By convention, this text mentions the approximate size of the
|
||||
disk, as in
|
||||
.Dq Li SUN9.0G
|
||||
for a 9 GB disk shipped by Sun.
|
||||
.Pp
|
||||
The values
|
||||
.Ar CC ,
|
||||
.Ar HH ,
|
||||
and
|
||||
.Ar SS
|
||||
describe the number of cylinders, heads (tracks per
|
||||
cylinder), and sectors per track respectively.
|
||||
They might be modified to change the geometry emulation.
|
||||
Each number must be between 1 and 65535.
|
||||
The product
|
||||
.D1 Em (CC + 2) * HH * SS
|
||||
must be less than or equal to the total number of sectors of the
|
||||
disk (which is given as a hint in a comment field).
|
||||
.It Sy Volume name
|
||||
The volume name (if present) is introduced by the string
|
||||
.Dq "volume name:" .
|
||||
It can be up to 8 characters long, and might be useful to distinguish
|
||||
different disks in a system.
|
||||
Note that volume names require the VTOC elements to be present, so
|
||||
any of the VTOC constraints described below need to be obeyed as well
|
||||
if a volume name is to be set.
|
||||
Setting an empty volume name will delete it from the label.
|
||||
.It Sy Partition entries
|
||||
Partition entries start with a letter from
|
||||
.Ql a
|
||||
through
|
||||
.Ql h ,
|
||||
immediately followed by a colon, followed by the size of this
|
||||
partition, and the starting cylinder of the partition.
|
||||
The unit of the size field defaults to sectors, or to cylinders
|
||||
if the
|
||||
.Fl c
|
||||
option is in effect.
|
||||
Alternatively, a different unit may be specified by appending
|
||||
.Ql s
|
||||
for (512-byte) sectors,
|
||||
.Ql c
|
||||
for cylinders,
|
||||
.Ql k
|
||||
for kilobytes,
|
||||
.Ql m
|
||||
for megabytes, or
|
||||
.Ql g
|
||||
for gigabytes.
|
||||
The last partition entry may specify the size as
|
||||
.Ql *
|
||||
to indicate that this entry should consume the rest of disk not
|
||||
consumed by any other partition so far.
|
||||
.Pp
|
||||
The start of partition is always taken as a cylinder number (starting
|
||||
at 0) since this is what the underlying hardware uses.
|
||||
Alternatively, specifying it as
|
||||
.Ql *
|
||||
will make the computation automatically chose the nearest possible
|
||||
cylinder boundary.
|
||||
.Pp
|
||||
Partition
|
||||
.Ql c
|
||||
must always be present, must start at 0, and must cover the entire
|
||||
disk (without considering the alternate cylinders though).
|
||||
.Pp
|
||||
Optionally, each partition entry may be followed by an SVR4-compatible
|
||||
VTOC tag name, and a flag description.
|
||||
The following VTOC tag names are known:
|
||||
.Bl -column -offset indent ".Li unassigned" ".Sy value" ".Sy comment"
|
||||
.It Sy name Ta Sy value Ta Sy comment
|
||||
.It Li unassigned Ta No 0x00 Ta \&
|
||||
.It Li boot Ta No 0x01 Ta \&
|
||||
.It Li root Ta No 0x02 Ta \&
|
||||
.It Li swap Ta No 0x03 Ta \&
|
||||
.It Li usr Ta No 0x04 Ta \&
|
||||
.It Li backup Ta No 0x05 Ta c partition, entire disk
|
||||
.It Li stand Ta No 0x06 Ta \&
|
||||
.It Li var Ta No 0x07 Ta \&
|
||||
.It Li home Ta No 0x08 Ta \&
|
||||
.It Li altsctr Ta No 0x09 Ta alternate sector partition
|
||||
.It Li cache Ta No 0x0a Ta Solaris cachefs partition
|
||||
.It Li VxVM_pub Ta No 0x0e Ta VxVM public region
|
||||
.It Li VxVM_priv Ta No 0x0f Ta VxVM private region
|
||||
.El
|
||||
.Pp
|
||||
The following VTOC flags are known:
|
||||
.Bl -column -offset indent ".Sy name" ".Sy value" ".Sy comment"
|
||||
.It Sy name Ta Sy value Ta Sy comment
|
||||
.It Li wm Ta No 0x00 Ta read/write, mountable
|
||||
.It Li wu Ta No 0x01 Ta read/write, unmountable
|
||||
.It Li rm Ta No 0x10 Ta read/only, mountable
|
||||
.It Li ru Ta No 0x11 Ta read/only, unmountable
|
||||
.El
|
||||
.Pp
|
||||
Optionally, both the tag and/or the flag name may be specified
|
||||
numerically, using standard
|
||||
.Ql C
|
||||
numerical notation (prefix
|
||||
.Ql 0x
|
||||
for hexadecimal numbers,
|
||||
.Ql 0
|
||||
for octal numbers).
|
||||
If the flag field is omitted, it defaults to
|
||||
.Ql wm .
|
||||
If the tag field is also omitted, it defaults to
|
||||
.Dq Li unassigned .
|
||||
If none of the partitions lists any VTOC tag/flags, no
|
||||
SVR4-compatible VTOC elements will be written to disk.
|
||||
If VTOC-style elements are present, partition
|
||||
.Ql c
|
||||
must be marked as
|
||||
.Dq Li backup
|
||||
(and should be marked
|
||||
.Ql wu ) .
|
||||
.El
|
||||
.Pp
|
||||
When checking the label, partition
|
||||
.Ql c
|
||||
is checked for presence, and for the mentioned restrictions.
|
||||
All other partitions are checked for possible overlaps, as
|
||||
well as for not extending past the end of unit.
|
||||
If VTOC-style elements are present, overlaps of unmountable
|
||||
partitions against other partitions will be warned still but
|
||||
do not cause a rejection of the label.
|
||||
That way,
|
||||
.Em encapsulated disks
|
||||
of volume management software are acceptable as long as the
|
||||
volume management partitions are clearly marked as unmountable.
|
||||
.Pp
|
||||
Any other fields in the label template are informational only,
|
||||
and will not be parsed when reading the label.
|
||||
.Pp
|
||||
Note that when changing the geometry emulation by editing the
|
||||
textual description line, all partition entries will be
|
||||
considered based on the new geometry emulation.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width ".Ev EDITOR" -compact
|
||||
.It Ev EDITOR
|
||||
Name of the command to edit the template file in edit-mode.
|
||||
Defaults to
|
||||
.Xr vi 1 .
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".Pa /boot/boot1" -compact
|
||||
.It Pa /boot/boot1
|
||||
Default boot image.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr vi 1 ,
|
||||
.Xr geom 4 ,
|
||||
.Xr bsdlabel 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility appeared in
|
||||
.Fx 5.1 .
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Jake Burkholder ,
|
||||
modeling it after the
|
||||
.Xr bsdlabel 8
|
||||
command available on other architectures.
|
||||
.Pp
|
||||
.An -nosplit
|
||||
This man page was initially written by
|
||||
.An David O'Brien ,
|
||||
and later substantially updated by
|
||||
.An J\(:org Wunsch .
|
||||
.Sh BUGS
|
||||
Installing bootstrap code onto an entire disk is merely pointless.
|
||||
.Nm
|
||||
should rather support installing bootstrap code into a partition
|
||||
instead.
|
||||
.Pp
|
||||
The
|
||||
.Dq auto
|
||||
layout algorithm could be smarter.
|
||||
By now, it tends to emulate fairly large cylinders which due to
|
||||
the two reserved alternate cylinders causes a fair amount of
|
||||
wasted disk space.
|
File diff suppressed because it is too large
Load diff
|
@ -1,184 +0,0 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2003 Jake Burkholder
|
||||
* Copyright (c) 2003 Poul-Henning Kamp
|
||||
* Copyright (c) 2004,2005 Joerg Wunsch
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
/* Functions to encode or decode struct sun_disklabel into a bytestream
|
||||
* of correct endianness and packing.
|
||||
*
|
||||
* NB! This file must be usable both in kernel and userland.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/errno.h>
|
||||
#ifdef _KERNEL
|
||||
#include <sys/systm.h>
|
||||
#else
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "sun_disklabel.h"
|
||||
|
||||
#define SL_TEXT 0x0
|
||||
#define SL_TEXT_SIZEOF 0x80
|
||||
#define SL_VTOC_VERS 0x80
|
||||
#define SL_VTOC_VOLNAME 0x84
|
||||
#define SL_VTOC_NPART 0x8c
|
||||
#define SL_VTOC_MAP 0x8e
|
||||
#define SL_VTOC_SANITY 0xbc
|
||||
#define SL_RPM 0x1a4
|
||||
#define SL_PCYLINDERS 0x1a6
|
||||
#define SL_SPARESPERCYL 0x1a8
|
||||
#define SL_INTERLEAVE 0x1ae
|
||||
#define SL_NCYLINDERS 0x1b0
|
||||
#define SL_ACYLINDERS 0x1b2
|
||||
#define SL_NTRACKS 0x1b4
|
||||
#define SL_NSECTORS 0x1b6
|
||||
#define SL_PART 0x1bc
|
||||
#define SL_MAGIC 0x1fc
|
||||
#define SL_CKSUM 0x1fe
|
||||
|
||||
#define SDKP_CYLOFFSET 0
|
||||
#define SDKP_NSECTORS 0x4
|
||||
#define SDKP_SIZEOF 0x8 /* size of a partition entry */
|
||||
|
||||
#define SVTOC_TAG 0
|
||||
#define SVTOC_FLAG 0x2
|
||||
#define SVTOC_SIZEOF 0x4 /* size of a VTOC tag/flag entry */
|
||||
|
||||
/*
|
||||
* Decode the relevant fields of a sun disk label, and return zero if the
|
||||
* magic and checksum works out OK.
|
||||
*/
|
||||
int
|
||||
sunlabel_dec(void const *pp, struct sun_disklabel *sl)
|
||||
{
|
||||
const uint8_t *p;
|
||||
size_t i;
|
||||
u_int u;
|
||||
uint32_t vtocsane;
|
||||
uint16_t npart;
|
||||
|
||||
p = pp;
|
||||
for (i = 0; i < sizeof(sl->sl_text); i++)
|
||||
sl->sl_text[i] = p[SL_TEXT + i];
|
||||
sl->sl_rpm = be16dec(p + SL_RPM);
|
||||
sl->sl_pcylinders = be16dec(p + SL_PCYLINDERS);
|
||||
sl->sl_sparespercyl = be16dec(p + SL_SPARESPERCYL);
|
||||
sl->sl_interleave = be16dec(p + SL_INTERLEAVE);
|
||||
sl->sl_ncylinders = be16dec(p + SL_NCYLINDERS);
|
||||
sl->sl_acylinders = be16dec(p + SL_ACYLINDERS);
|
||||
sl->sl_ntracks = be16dec(p + SL_NTRACKS);
|
||||
sl->sl_nsectors = be16dec(p + SL_NSECTORS);
|
||||
for (i = 0; i < SUN_NPART; i++) {
|
||||
sl->sl_part[i].sdkp_cyloffset = be32dec(p + SL_PART +
|
||||
(i * SDKP_SIZEOF) + SDKP_CYLOFFSET);
|
||||
sl->sl_part[i].sdkp_nsectors = be32dec(p + SL_PART +
|
||||
(i * SDKP_SIZEOF) + SDKP_NSECTORS);
|
||||
}
|
||||
sl->sl_magic = be16dec(p + SL_MAGIC);
|
||||
vtocsane = be32dec(p + SL_VTOC_SANITY);
|
||||
npart = be16dec(p + SL_VTOC_NPART);
|
||||
if (vtocsane == SUN_VTOC_SANE && npart == SUN_NPART) {
|
||||
/*
|
||||
* Seems we've got SVR4-compatible VTOC information
|
||||
* as well, decode it.
|
||||
*/
|
||||
sl->sl_vtoc_sane = vtocsane;
|
||||
sl->sl_vtoc_vers = be32dec(p + SL_VTOC_VERS);
|
||||
memcpy(sl->sl_vtoc_volname, p + SL_VTOC_VOLNAME,
|
||||
SUN_VOLNAME_LEN);
|
||||
sl->sl_vtoc_nparts = SUN_NPART;
|
||||
for (i = 0; i < SUN_NPART; i++) {
|
||||
sl->sl_vtoc_map[i].svtoc_tag = be16dec(p +
|
||||
SL_VTOC_MAP + (i * SVTOC_SIZEOF) + SVTOC_TAG);
|
||||
sl->sl_vtoc_map[i].svtoc_flag = be16dec(p +
|
||||
SL_VTOC_MAP + (i * SVTOC_SIZEOF) + SVTOC_FLAG);
|
||||
}
|
||||
}
|
||||
for (i = u = 0; i < SUN_SIZE; i += 2)
|
||||
u ^= be16dec(p + i);
|
||||
if (u == 0 && sl->sl_magic == SUN_DKMAGIC)
|
||||
return (0);
|
||||
else
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode the relevant fields into a sun disklabel, compute new checksum.
|
||||
*/
|
||||
void
|
||||
sunlabel_enc(void *pp, struct sun_disklabel *sl)
|
||||
{
|
||||
uint8_t *p;
|
||||
size_t i;
|
||||
u_int u;
|
||||
|
||||
p = pp;
|
||||
for (i = 0; i < SL_TEXT_SIZEOF; i++)
|
||||
p[SL_TEXT + i] = sl->sl_text[i];
|
||||
be16enc(p + SL_RPM, sl->sl_rpm);
|
||||
be16enc(p + SL_PCYLINDERS, sl->sl_pcylinders);
|
||||
be16enc(p + SL_SPARESPERCYL, sl->sl_sparespercyl);
|
||||
be16enc(p + SL_INTERLEAVE, sl->sl_interleave);
|
||||
be16enc(p + SL_NCYLINDERS, sl->sl_ncylinders);
|
||||
be16enc(p + SL_ACYLINDERS, sl->sl_acylinders);
|
||||
be16enc(p + SL_NTRACKS, sl->sl_ntracks);
|
||||
be16enc(p + SL_NSECTORS, sl->sl_nsectors);
|
||||
for (i = 0; i < SUN_NPART; i++) {
|
||||
be32enc(p + SL_PART + (i * SDKP_SIZEOF) + SDKP_CYLOFFSET,
|
||||
sl->sl_part[i].sdkp_cyloffset);
|
||||
be32enc(p + SL_PART + (i * SDKP_SIZEOF) + SDKP_NSECTORS,
|
||||
sl->sl_part[i].sdkp_nsectors);
|
||||
}
|
||||
be16enc(p + SL_MAGIC, sl->sl_magic);
|
||||
if (sl->sl_vtoc_sane == SUN_VTOC_SANE
|
||||
&& sl->sl_vtoc_nparts == SUN_NPART) {
|
||||
/*
|
||||
* Write SVR4-compatible VTOC elements.
|
||||
*/
|
||||
be32enc(p + SL_VTOC_VERS, sl->sl_vtoc_vers);
|
||||
be32enc(p + SL_VTOC_SANITY, SUN_VTOC_SANE);
|
||||
memcpy(p + SL_VTOC_VOLNAME, sl->sl_vtoc_volname,
|
||||
SUN_VOLNAME_LEN);
|
||||
be16enc(p + SL_VTOC_NPART, SUN_NPART);
|
||||
for (i = 0; i < SUN_NPART; i++) {
|
||||
be16enc(p + SL_VTOC_MAP + (i * SVTOC_SIZEOF)
|
||||
+ SVTOC_TAG,
|
||||
sl->sl_vtoc_map[i].svtoc_tag);
|
||||
be16enc(p + SL_VTOC_MAP + (i * SVTOC_SIZEOF)
|
||||
+ SVTOC_FLAG,
|
||||
sl->sl_vtoc_map[i].svtoc_flag);
|
||||
}
|
||||
}
|
||||
for (i = u = 0; i < SUN_SIZE; i += 2)
|
||||
u ^= be16dec(p + i);
|
||||
be16enc(p + SL_CKSUM, u);
|
||||
}
|
Loading…
Reference in a new issue