summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1998-10-03 22:01:47 +0000
committermillert <millert@openbsd.org>1998-10-03 22:01:47 +0000
commitfa8ace587f2db029330a50b18c7280cf10b5e88a (patch)
tree5b2dc26e2451d7c121c451bc521d518aa95885d3
parentAdd a "spoofonly" argument to readdisklabel() which will be used to (diff)
downloadwireguard-openbsd-fa8ace587f2db029330a50b18c7280cf10b5e88a.tar.xz
wireguard-openbsd-fa8ace587f2db029330a50b18c7280cf10b5e88a.zip
Add DIOCGPDINFO ioctl and use it in disklabel's new -p mode
-rw-r--r--sbin/disklabel/disklabel.c14
-rw-r--r--sys/sys/dkio.h4
2 files changed, 14 insertions, 4 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 73791eb7493..2c19bb3eb44 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.55 1998/09/11 04:02:27 millert Exp $ */
+/* $OpenBSD: disklabel.c,v 1.56 1998/10/03 22:01:47 millert Exp $ */
/* $NetBSD: disklabel.c,v 1.30 1996/03/14 19:49:24 ghudson Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char rcsid[] = "$OpenBSD: disklabel.c,v 1.55 1998/09/11 04:02:27 millert Exp $";
+static char rcsid[] = "$OpenBSD: disklabel.c,v 1.56 1998/10/03 22:01:47 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -107,6 +107,7 @@ enum {
UNSPEC, EDIT, EDITOR, READ, RESTORE, SETWRITEABLE, WRITE, WRITEBOOT
} op = UNSPEC;
+int pflag;
int rflag;
int tflag;
int nwflag;
@@ -147,7 +148,7 @@ main(argc, argv)
struct disklabel *lp;
FILE *t;
- while ((ch = getopt(argc, argv, "BENRWb:enrs:tvw")) != -1)
+ while ((ch = getopt(argc, argv, "BENRWb:enprs:tvw")) != -1)
switch (ch) {
#if NUMBOOT > 0
case 'B':
@@ -189,6 +190,9 @@ main(argc, argv)
usage();
op = EDIT;
break;
+ case 'p':
+ ++pflag;
+ break;
case 'r':
++rflag;
break;
@@ -712,6 +716,10 @@ readlabel(f)
}
warnx(msg);
return(NULL);
+ } else if (pflag) {
+ lp = &lab;
+ if (ioctl(f, DIOCGPDINFO, lp) < 0)
+ err(4, "ioctl DIOCGPDINFO");
} else {
lp = &lab;
if (ioctl(f, DIOCGDINFO, lp) < 0)
diff --git a/sys/sys/dkio.h b/sys/sys/dkio.h
index 2405f1bc627..3096a4ba9d8 100644
--- a/sys/sys/dkio.h
+++ b/sys/sys/dkio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkio.h,v 1.2 1996/03/03 12:11:35 niklas Exp $ */
+/* $OpenBSD: dkio.h,v 1.3 1998/10/03 22:01:48 millert Exp $ */
/* $NetBSD: dkio.h,v 1.1 1996/01/30 18:21:48 thorpej Exp $ */
/*
@@ -60,4 +60,6 @@
#define DIOCEJECT _IO('d', 112) /* eject removable disk */
#define DIOCLOCK _IOW('d', 113, int) /* lock/unlock pack */
+#define DIOCGPDINFO _IOR('d', 114, struct disklabel)/* get physical */
+
#endif /* _SYS_DKIO_H_ */