Add section number to .Xr. Use of .Nm. Typo. Add rcsid. Remove unused

#includes. Use err(3).
This commit is contained in:
Philippe Charnier 1998-06-04 06:49:13 +00:00
parent 77027e301b
commit 6bd343a92d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=36632
6 changed files with 100 additions and 142 deletions

View File

@ -13,7 +13,7 @@
.\" 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:
.\" 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
@ -33,6 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93
.\" $Id$
.\"
.Dd June 5, 1993
.Dt DISKLABEL 5
@ -75,7 +76,7 @@ the
.Dv DIOCWLABEL
.Xr ioctl 2 ,
which is done as needed by the
.Xr disklabel
.Xr disklabel 8
program.
.Pp
A copy of the in-core label for a disk can be obtained with the
@ -99,7 +100,7 @@ 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 .
.Xr disklabel 8 .
.Pp
The format of the disk label, as specified in
.Pa <sys/disklabel.h> ,

View File

@ -13,7 +13,7 @@
.\" 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:
.\" 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
@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
.\" $Id: disklabel.8,v 1.6 1997/02/22 14:32:12 peter Exp $
.\" $Id: disklabel.8,v 1.7 1997/06/23 04:02:17 steve Exp $
.\"
.Dd April 19, 1994
.Dt DISKLABEL 8
@ -96,7 +96,7 @@ to change the drive identification,
the disk partitions on the drive,
or to replace a damaged label.
On some systems,
.Nm disklabel
.Nm
can be used to install bootstrap code as well.
There are several forms of the command that read (display), install or edit
the label on a disk.
@ -134,8 +134,8 @@ The second form of the command, with the
.Fl w
flag, is used to write a standard label on the designated drive.
The required arguments to
.Nm disklabel
are the drive to be labelled (e.g. sd0), and
.Nm
are the drive to be labeled (e.g. sd0), and
the drive type as described in the
.Xr disktab 5
file.
@ -199,7 +199,7 @@ was specified.
With the
.Fl R
flag,
.Nm disklabel
.Nm
is capable of restoring a disk label that was formatted
in a prior operation and saved in an ascii file.
The prototype file used to create the label should be in the same format
@ -216,13 +216,13 @@ is specified and will be unaffected otherwise.
The
.Fl NW
flags for
.Nm disklabel
.Nm
explicitly disallow and
allow, respectively, writing of the pack label area on the selected disk.
.Pp
The final three forms of
.Nm disklabel
are used to install boostrap code on machines where the bootstrap is part
.Nm
are used to install bootstrap code on machines where the bootstrap is part
of the label.
The bootstrap code is comprised of one or two boot programs depending on
the machine.
@ -349,7 +349,7 @@ allocated for it by some filesystems.
As a result, it may not be possible to have filesystems on some partitions
of a ``bootable'' disk.
When installing bootstrap code,
.Nm disklabel
.Nm
checks for these cases.
If the installed boot code would overlap a partition of type FS_UNUSED
it is marked as type FS_BOOT.
@ -357,11 +357,11 @@ The
.Xr newfs 8
utility will disallow creation of filesystems on FS_BOOT partitions.
Conversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
.Nm disklabel
.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 ``a'' partition on the tahoe,
the constructed device name uses the ``a'' partition on the Tahoe,
the ``c'' partition on all others.
.Pp
For the i386 architecture, the primary bootstrap sector contains

View File

@ -32,26 +32,26 @@
* 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.
*
* $Id$
*/
#ifndef lint
static char copyright[] =
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
#if 0
static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/errno.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/wait.h>
#define DKTYPENAMES
@ -121,7 +121,6 @@ char *dkname;
char *specname;
char tmpfil[] = _PATH_TMP;
extern int errno;
char namebuf[BBSIZE], *np = namebuf;
struct disklabel lab;
struct disklabel *readlabel(), *makebootarea();
@ -155,8 +154,6 @@ main(argc, argv)
int argc;
char *argv[];
{
extern char *optarg;
extern int optind;
register struct disklabel *lp;
FILE *t;
int ch, f, flag, error = 0;
@ -251,6 +248,9 @@ main(argc, argv)
switch(op) {
case UNSPEC:
break;
case EDIT:
if (argc != 1)
usage();
@ -344,10 +344,8 @@ makelabel(type, name, lp)
dp = getvirginlabel();
else
dp = getdiskbyname(type);
if (dp == NULL) {
fprintf(stderr, "%s: unknown disk type\n", type);
exit(1);
}
if (dp == NULL)
errx(1, "%s: unknown disk type", type);
*lp = *dp;
#if NUMBOOT > 0
/*
@ -419,9 +417,9 @@ writelabel(f, boot, lp)
*/
flag = 1;
if (ioctl(f, DIOCWLABEL, &flag) < 0)
perror("ioctl DIOCWLABEL");
warn("ioctl DIOCWLABEL");
if (write(f, boot, lp->d_bbsize) != lp->d_bbsize) {
perror("write");
warn("write");
return (1);
}
#if NUMBOOT > 0
@ -429,7 +427,7 @@ writelabel(f, boot, lp)
* Output the remainder of the disklabel
*/
if (bootbuf && write(f, bootbuf, bootsize) != bootsize) {
perror("write");
warn("write");
return(1);
}
#endif
@ -447,12 +445,8 @@ writelabel(f, boot, lp)
for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) {
(void)lseek(f, (off_t)((alt + i) * lp->d_secsize),
SEEK_SET);
if (write(f, boot, lp->d_secsize) < lp->d_secsize) {
int oerrno = errno;
fprintf(stderr, "alternate label %d ", i/2);
errno = oerrno;
perror("write");
}
if (write(f, boot, lp->d_secsize) < lp->d_secsize)
warn("alternate label %d write", i/2);
}
}
#endif
@ -463,35 +457,29 @@ void
l_perror(s)
char *s;
{
int saverrno = errno;
fprintf(stderr, "disklabel: %s: ", s);
switch (saverrno) {
switch (errno) {
case ESRCH:
fprintf(stderr, "No disk label on disk;\n");
fprintf(stderr,
"use \"disklabel -r\" to install initial label\n");
warnx("%s: no disk label on disk;\n"
"use \"disklabel -r\" to install initial label", s);
break;
case EINVAL:
fprintf(stderr, "Label magic number or checksum is wrong!\n");
fprintf(stderr, "(disklabel or kernel is out of date?)\n");
warnx("%s: label magic number or checksum is wrong!\n"
"(disklabel or kernel is out of date?)", s);
break;
case EBUSY:
fprintf(stderr, "Open partition would move or shrink\n");
warnx("%s: open partition would move or shrink", s);
break;
case EXDEV:
fprintf(stderr,
"Labeled partition or 'a' partition must start at beginning of disk\n");
warnx(
"%s: labeled partition or 'a' partition must start at beginning of disk", s);
break;
default:
errno = saverrno;
perror((char *)NULL);
warn((char *)NULL);
break;
}
}
@ -518,10 +506,7 @@ readlabel(f)
if (lp > (struct disklabel *)(bootarea+BBSIZE-sizeof(*lp)) ||
lp->d_magic != DISKMAGIC || lp->d_magic2 != DISKMAGIC ||
dkcksum(lp) != 0) {
fprintf(stderr,
"Bad pack magic number (label is damaged, or pack is unlabeled)\n");
/* lp = (struct disklabel *)(bootarea + LABELOFFSET); */
exit (1);
errx(1, "bad pack magic number (label is damaged, or pack is unlabeled)");
}
} else {
lp = &lab;
@ -690,11 +675,8 @@ makebootarea(boot, dp, f)
* reserved for the label.
*/
for (p = (char *)lp; p < (char *)lp + sizeof(struct disklabel); p++)
if (*p) {
fprintf(stderr,
"Bootstrap doesn't leave room for disk label\n");
exit(2);
}
if (*p)
errx(2, "bootstrap doesn't leave room for disk label");
return (lp);
}
@ -808,7 +790,7 @@ edit(lp, f)
if ((fd = mkstemp(tmpfil)) == -1 ||
(fp = fdopen(fd, "w")) == NULL) {
fprintf(stderr, "%s: Can't create\n", tmpfil);
warnx("can't create %s", tmpfil);
return (1);
}
display(fp, lp);
@ -818,8 +800,7 @@ edit(lp, f)
break;
fp = fopen(tmpfil, "r");
if (fp == NULL) {
fprintf(stderr, "%s: Can't reopen for reading\n",
tmpfil);
warnx("can't reopen %s for reading", tmpfil);
break;
}
bzero((char *)&label, sizeof(label));
@ -856,11 +837,11 @@ editit()
extern int errno;
if (errno == EPROCLIM) {
fprintf(stderr, "You have too many processes\n");
warnx("you have too many processes");
return(0);
}
if (errno != EAGAIN) {
perror("fork");
warn("fork");
return(0);
}
sleep(1);
@ -874,8 +855,7 @@ editit()
if ((ed = getenv("EDITOR")) == (char *)0)
ed = DEFEDITOR;
execlp(ed, ed, tmpfil, 0);
perror(ed);
exit(1);
err(1, "%s", ed);
}
while ((xpid = wait(&stat)) >= 0)
if (xpid == pid)
@ -1387,10 +1367,8 @@ setbootflag(lp)
}
}
}
if (errors) {
fprintf(stderr, "Cannot install boot program\n");
exit(4);
}
if (errors)
errx(4, "cannot install boot program");
}
/*VARARGS1*/

View File

@ -13,7 +13,7 @@
.\" 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:
.\" 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
@ -33,6 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93
.\" $Id$
.\"
.Dd June 5, 1993
.Dt DISKLABEL 5
@ -75,7 +76,7 @@ the
.Dv DIOCWLABEL
.Xr ioctl 2 ,
which is done as needed by the
.Xr disklabel
.Xr disklabel 8
program.
.Pp
A copy of the in-core label for a disk can be obtained with the
@ -99,7 +100,7 @@ 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 .
.Xr disklabel 8 .
.Pp
The format of the disk label, as specified in
.Pa <sys/disklabel.h> ,

View File

@ -13,7 +13,7 @@
.\" 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:
.\" 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
@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
.\" $Id: disklabel.8,v 1.6 1997/02/22 14:32:12 peter Exp $
.\" $Id: disklabel.8,v 1.7 1997/06/23 04:02:17 steve Exp $
.\"
.Dd April 19, 1994
.Dt DISKLABEL 8
@ -96,7 +96,7 @@ to change the drive identification,
the disk partitions on the drive,
or to replace a damaged label.
On some systems,
.Nm disklabel
.Nm
can be used to install bootstrap code as well.
There are several forms of the command that read (display), install or edit
the label on a disk.
@ -134,8 +134,8 @@ The second form of the command, with the
.Fl w
flag, is used to write a standard label on the designated drive.
The required arguments to
.Nm disklabel
are the drive to be labelled (e.g. sd0), and
.Nm
are the drive to be labeled (e.g. sd0), and
the drive type as described in the
.Xr disktab 5
file.
@ -199,7 +199,7 @@ was specified.
With the
.Fl R
flag,
.Nm disklabel
.Nm
is capable of restoring a disk label that was formatted
in a prior operation and saved in an ascii file.
The prototype file used to create the label should be in the same format
@ -216,13 +216,13 @@ is specified and will be unaffected otherwise.
The
.Fl NW
flags for
.Nm disklabel
.Nm
explicitly disallow and
allow, respectively, writing of the pack label area on the selected disk.
.Pp
The final three forms of
.Nm disklabel
are used to install boostrap code on machines where the bootstrap is part
.Nm
are used to install bootstrap code on machines where the bootstrap is part
of the label.
The bootstrap code is comprised of one or two boot programs depending on
the machine.
@ -349,7 +349,7 @@ allocated for it by some filesystems.
As a result, it may not be possible to have filesystems on some partitions
of a ``bootable'' disk.
When installing bootstrap code,
.Nm disklabel
.Nm
checks for these cases.
If the installed boot code would overlap a partition of type FS_UNUSED
it is marked as type FS_BOOT.
@ -357,11 +357,11 @@ The
.Xr newfs 8
utility will disallow creation of filesystems on FS_BOOT partitions.
Conversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
.Nm disklabel
.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 ``a'' partition on the tahoe,
the constructed device name uses the ``a'' partition on the Tahoe,
the ``c'' partition on all others.
.Pp
For the i386 architecture, the primary bootstrap sector contains

View File

@ -32,26 +32,26 @@
* 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.
*
* $Id$
*/
#ifndef lint
static char copyright[] =
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
#if 0
static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/errno.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/wait.h>
#define DKTYPENAMES
@ -121,7 +121,6 @@ char *dkname;
char *specname;
char tmpfil[] = _PATH_TMP;
extern int errno;
char namebuf[BBSIZE], *np = namebuf;
struct disklabel lab;
struct disklabel *readlabel(), *makebootarea();
@ -155,8 +154,6 @@ main(argc, argv)
int argc;
char *argv[];
{
extern char *optarg;
extern int optind;
register struct disklabel *lp;
FILE *t;
int ch, f, flag, error = 0;
@ -251,6 +248,9 @@ main(argc, argv)
switch(op) {
case UNSPEC:
break;
case EDIT:
if (argc != 1)
usage();
@ -344,10 +344,8 @@ makelabel(type, name, lp)
dp = getvirginlabel();
else
dp = getdiskbyname(type);
if (dp == NULL) {
fprintf(stderr, "%s: unknown disk type\n", type);
exit(1);
}
if (dp == NULL)
errx(1, "%s: unknown disk type", type);
*lp = *dp;
#if NUMBOOT > 0
/*
@ -419,9 +417,9 @@ writelabel(f, boot, lp)
*/
flag = 1;
if (ioctl(f, DIOCWLABEL, &flag) < 0)
perror("ioctl DIOCWLABEL");
warn("ioctl DIOCWLABEL");
if (write(f, boot, lp->d_bbsize) != lp->d_bbsize) {
perror("write");
warn("write");
return (1);
}
#if NUMBOOT > 0
@ -429,7 +427,7 @@ writelabel(f, boot, lp)
* Output the remainder of the disklabel
*/
if (bootbuf && write(f, bootbuf, bootsize) != bootsize) {
perror("write");
warn("write");
return(1);
}
#endif
@ -447,12 +445,8 @@ writelabel(f, boot, lp)
for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) {
(void)lseek(f, (off_t)((alt + i) * lp->d_secsize),
SEEK_SET);
if (write(f, boot, lp->d_secsize) < lp->d_secsize) {
int oerrno = errno;
fprintf(stderr, "alternate label %d ", i/2);
errno = oerrno;
perror("write");
}
if (write(f, boot, lp->d_secsize) < lp->d_secsize)
warn("alternate label %d write", i/2);
}
}
#endif
@ -463,35 +457,29 @@ void
l_perror(s)
char *s;
{
int saverrno = errno;
fprintf(stderr, "disklabel: %s: ", s);
switch (saverrno) {
switch (errno) {
case ESRCH:
fprintf(stderr, "No disk label on disk;\n");
fprintf(stderr,
"use \"disklabel -r\" to install initial label\n");
warnx("%s: no disk label on disk;\n"
"use \"disklabel -r\" to install initial label", s);
break;
case EINVAL:
fprintf(stderr, "Label magic number or checksum is wrong!\n");
fprintf(stderr, "(disklabel or kernel is out of date?)\n");
warnx("%s: label magic number or checksum is wrong!\n"
"(disklabel or kernel is out of date?)", s);
break;
case EBUSY:
fprintf(stderr, "Open partition would move or shrink\n");
warnx("%s: open partition would move or shrink", s);
break;
case EXDEV:
fprintf(stderr,
"Labeled partition or 'a' partition must start at beginning of disk\n");
warnx(
"%s: labeled partition or 'a' partition must start at beginning of disk", s);
break;
default:
errno = saverrno;
perror((char *)NULL);
warn((char *)NULL);
break;
}
}
@ -518,10 +506,7 @@ readlabel(f)
if (lp > (struct disklabel *)(bootarea+BBSIZE-sizeof(*lp)) ||
lp->d_magic != DISKMAGIC || lp->d_magic2 != DISKMAGIC ||
dkcksum(lp) != 0) {
fprintf(stderr,
"Bad pack magic number (label is damaged, or pack is unlabeled)\n");
/* lp = (struct disklabel *)(bootarea + LABELOFFSET); */
exit (1);
errx(1, "bad pack magic number (label is damaged, or pack is unlabeled)");
}
} else {
lp = &lab;
@ -690,11 +675,8 @@ makebootarea(boot, dp, f)
* reserved for the label.
*/
for (p = (char *)lp; p < (char *)lp + sizeof(struct disklabel); p++)
if (*p) {
fprintf(stderr,
"Bootstrap doesn't leave room for disk label\n");
exit(2);
}
if (*p)
errx(2, "bootstrap doesn't leave room for disk label");
return (lp);
}
@ -808,7 +790,7 @@ edit(lp, f)
if ((fd = mkstemp(tmpfil)) == -1 ||
(fp = fdopen(fd, "w")) == NULL) {
fprintf(stderr, "%s: Can't create\n", tmpfil);
warnx("can't create %s", tmpfil);
return (1);
}
display(fp, lp);
@ -818,8 +800,7 @@ edit(lp, f)
break;
fp = fopen(tmpfil, "r");
if (fp == NULL) {
fprintf(stderr, "%s: Can't reopen for reading\n",
tmpfil);
warnx("can't reopen %s for reading", tmpfil);
break;
}
bzero((char *)&label, sizeof(label));
@ -856,11 +837,11 @@ editit()
extern int errno;
if (errno == EPROCLIM) {
fprintf(stderr, "You have too many processes\n");
warnx("you have too many processes");
return(0);
}
if (errno != EAGAIN) {
perror("fork");
warn("fork");
return(0);
}
sleep(1);
@ -874,8 +855,7 @@ editit()
if ((ed = getenv("EDITOR")) == (char *)0)
ed = DEFEDITOR;
execlp(ed, ed, tmpfil, 0);
perror(ed);
exit(1);
err(1, "%s", ed);
}
while ((xpid = wait(&stat)) >= 0)
if (xpid == pid)
@ -1387,10 +1367,8 @@ setbootflag(lp)
}
}
}
if (errors) {
fprintf(stderr, "Cannot install boot program\n");
exit(4);
}
if (errors)
errx(4, "cannot install boot program");
}
/*VARARGS1*/