summaryrefslogtreecommitdiff
path: root/sbin/fdisk/fdisk.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-11-08 23:22:27 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-11-08 23:22:27 +0000
commit08f0be3b9161ed0e33d43893aff9b10ee6ecf07b (patch)
treea887aa9f2696b1e1400120cd389007a737f0f61b /sbin/fdisk/fdisk.c
parent9531f4ad38bdd9fac9f312c6f010c8ff3f21cf25 (diff)
add a -y flag, for non-interactive use
Diffstat (limited to 'sbin/fdisk/fdisk.c')
-rw-r--r--sbin/fdisk/fdisk.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index dc3d25dd8c6..460624873dd 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdisk.c,v 1.43 2006/07/27 04:53:27 ray Exp $ */
+/* $OpenBSD: fdisk.c,v 1.44 2006/11/08 23:22:26 deraadt Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -42,18 +42,21 @@ static unsigned char builtin_mbr[] = {
#include "mbrcode.h"
};
+int y_flag;
+
static void
usage(void)
{
extern char * __progname;
fprintf(stderr, "usage: %s "
- "[-ieu] [-c cylinders -h heads -s sectors] [-f mbrfile] device\n"
+ "[-ieuy] [-c cylinders -h heads -s sectors] [-f mbrfile] device\n"
"\t-i: initialize disk with virgin MBR\n"
"\t-u: update MBR code, preserve partition table\n"
"\t-e: edit MBRs on disk interactively\n"
"\t-f: specify non-standard MBR template\n"
"\t-chs: specify disk geometry\n"
+ "\t-y: do not ask questions\n"
"`disk' may be of the forms: sd0 or /dev/rsd0c.\n",
__progname);
exit(1);
@@ -76,7 +79,7 @@ main(int argc, char *argv[])
mbr_t mbr;
char mbr_buf[DEV_BSIZE];
- while ((ch = getopt(argc, argv, "ieuf:c:h:s:")) != -1) {
+ while ((ch = getopt(argc, argv, "ieuf:c:h:s:y")) != -1) {
const char *errstr;
switch(ch) {
@@ -108,6 +111,9 @@ main(int argc, char *argv[])
if (errstr)
errx(1, "Sector argument %s [1..63].", errstr);
break;
+ case 'y':
+ y_flag = 1;
+ break;
default:
usage();
}