summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2010-05-25 19:01:32 +0000
committerderaadt <deraadt@openbsd.org>2010-05-25 19:01:32 +0000
commit7fa76d5cdae000deeacd03b50f827ef443c0277c (patch)
tree8ebbf1b611df4acbbc3fa4d9401decf3c5c104b9
parentmatch usage to the manual page, and borrow the description of 'disk' (diff)
downloadwireguard-openbsd-7fa76d5cdae000deeacd03b50f827ef443c0277c.tar.xz
wireguard-openbsd-7fa76d5cdae000deeacd03b50f827ef443c0277c.zip
use opendev(), as requested in 6373. document this using text borrowed from
disklabel(8), and while at it, fix the usage code to not be utterly distasteful ok drahn
-rw-r--r--sbin/pdisk/Makefile5
-rw-r--r--sbin/pdisk/errors.c7
-rw-r--r--sbin/pdisk/file_media.c3
-rw-r--r--sbin/pdisk/pdisk.857
-rw-r--r--sbin/pdisk/pdisk.c2
5 files changed, 30 insertions, 44 deletions
diff --git a/sbin/pdisk/Makefile b/sbin/pdisk/Makefile
index 4e88ef16bcd..234ce8b739d 100644
--- a/sbin/pdisk/Makefile
+++ b/sbin/pdisk/Makefile
@@ -1,8 +1,9 @@
-# $Id: Makefile,v 1.8 2006/05/11 17:20:40 martin Exp $
+# $Id: Makefile,v 1.9 2010/05/25 19:01:32 deraadt Exp $
.if ${MACHINE} == "macppc" || ${MACHINE} == "mac68k"
PROG= pdisk
-
+LDADD= -lutil
+DPADD= ${LIBUTIL}
CFLAGS+=-Wall
SRCS= bitfield.c convert.c deblock_media.c dump.c errors.c \
diff --git a/sbin/pdisk/errors.c b/sbin/pdisk/errors.c
index 12e2d84a40c..163f1180527 100644
--- a/sbin/pdisk/errors.c
+++ b/sbin/pdisk/errors.c
@@ -83,12 +83,7 @@ init_program_name(char **argv)
void
do_help()
{
- printf("\t%s [-h]\n", program_name);
- printf("\t%s [-v]\n", program_name);
- printf("\t%s [-l] name [...]\n", program_name);
- printf("\t%s [-r] name ...\n", program_name);
- printf("\t%s [-i]\n", program_name);
- printf("\t%s name [...]\n", program_name);
+ printf("usage: %s [-hilrv] disk\n", program_name);
/*
{"debug", no_argument, 0, 'd'},
{"abbr", no_argument, 0, 'a'},
diff --git a/sbin/pdisk/file_media.c b/sbin/pdisk/file_media.c
index 96c71ca4a36..321d7aabe1c 100644
--- a/sbin/pdisk/file_media.c
+++ b/sbin/pdisk/file_media.c
@@ -40,6 +40,7 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
+#include <util.h>
#include "file_media.h"
#include "errors.h"
@@ -193,7 +194,7 @@ open_file_as_media(char *file, int oflag)
}
a = 0;
- fd = open(file, oflag);
+ fd = opendev(file, oflag, OPENDEV_PART, NULL);
if (fd >= 0) {
a = new_file_media();
if (a != 0) {
diff --git a/sbin/pdisk/pdisk.8 b/sbin/pdisk/pdisk.8
index 49d33dfd96e..b845b3afa13 100644
--- a/sbin/pdisk/pdisk.8
+++ b/sbin/pdisk/pdisk.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pdisk.8,v 1.14 2007/05/31 19:19:46 jmc Exp $
+.\" $OpenBSD: pdisk.8,v 1.15 2010/05/25 19:01:32 deraadt Exp $
.\"
.\" Copyright 1996,1997,1998 by Apple Computer, Inc.
.\" All Rights Reserved
@@ -19,7 +19,7 @@
.\" NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
.\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: May 25 2010 $
.Dt PDISK 8
.Os
.Sh NAME
@@ -27,33 +27,14 @@
.Nd HFS(DPME) partition maintenance program
.Sh SYNOPSIS
.Nm pdisk
-.Op Fl h
-.Op Fl i
-.Op Fl l
-.Op Fl r
-.Op Fl v
-.Ar device
+.Op Fl hilrv
+.Ar disk
.Sh DESCRIPTION
.Nm
is a menu driven program which partitions disks using the standard Apple
disk partitioning scheme described in "Inside Macintosh: Devices".
It does not support the Intel/DOS partitioning scheme supported by
.Em fdisk .
-The
-.Ar device
-is usually one of the following:
-.Pp
-.Pa /dev/sd0c
-.Pa /dev/sd1c
-.Pa /dev/sd2c
-.Pa /dev/sd3c
-.Pa /dev/sd4c
-.Pa /dev/sd5c
-.Pa /dev/sd6c
-.Pa /dev/wd0c
-.Pa /dev/wd1c
-.Pa /dev/wd2c
-.Pa /dev/wd3c
.Pp
The options are as follows:
.Bl -tag -width Ds
@@ -67,20 +48,30 @@ Causes
to go into an interactive mode similar to the Mac OS version of the program.
.It Fl l
List the partition tables for the specified
-.Ar devices .
+.Ar disk .
.It Fl r
Prevents
.Nm
-from writing to the device.
+from writing to the disk.
.It Fl v
Prints version number of the program.
+.It Ar disk
+Specify the
+.Ar disk
+to operate on.
+It can be specified either by its full pathname or an abbreviated disk form.
+In its abbreviated form, the path to the device, the
+.Sq r
+denoting
+.Qq raw device ,
+and the partition letter, can all be omitted.
+For example, the first IDE disk can be specified as either
+.Pa /dev/rwd0c ,
+.Pa /dev/wd0c ,
+or
+.Ar wd0 .
.El
.Pp
-An argument which is simply the name of a
-.Ar device
-indicates that
-.Nm
-should edit the partition table of that device.
.Sh COMMAND MODE
The list of commands and their explanations are given below.
.Bl -tag -width "update"
@@ -181,9 +172,9 @@ Examples of valid partition types are: Apple_Free, Apple_HFS, and
.Pp
The
.Em i
-(initialize) command prompts for the size of the device.
+(initialize) command prompts for the size of the disk.
This was done to get around a bug in the kernel where it reports the wrong
-size for the device.
+size for the disk.
.Pp
The
.Em w
@@ -192,7 +183,7 @@ but there is currently a bug in the interaction between the
disk and the kernel where
.Nm disklabel
.Fl c
-.Ar device
+.Ar disk
must be issued to cause the kernel to reinterpret the new label.
.Sh SEE ALSO
.Xr disklabel 8 ,
diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c
index 2c16d5704ca..3c594c08ab0 100644
--- a/sbin/pdisk/pdisk.c
+++ b/sbin/pdisk/pdisk.c
@@ -172,7 +172,6 @@ main(int argc, char **argv)
dump(argv[name_index++]);
}
} else {
- usage("no device argument");
do_help();
}
} else if (name_index < argc) {
@@ -180,7 +179,6 @@ main(int argc, char **argv)
edit(argv[name_index++], 0);
}
} else if (!vflag) {
- usage("no device argument");
do_help();
}
return 0;