diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-11-08 23:22:27 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-11-08 23:22:27 +0000 |
commit | 08f0be3b9161ed0e33d43893aff9b10ee6ecf07b (patch) | |
tree | a887aa9f2696b1e1400120cd389007a737f0f61b /sbin/fdisk | |
parent | 9531f4ad38bdd9fac9f312c6f010c8ff3f21cf25 (diff) |
add a -y flag, for non-interactive use
Diffstat (limited to 'sbin/fdisk')
-rw-r--r-- | sbin/fdisk/fdisk.8 | 6 | ||||
-rw-r--r-- | sbin/fdisk/fdisk.c | 12 | ||||
-rw-r--r-- | sbin/fdisk/misc.c | 6 |
3 files changed, 18 insertions, 6 deletions
diff --git a/sbin/fdisk/fdisk.8 b/sbin/fdisk/fdisk.8 index 083ceb09cae..7f1c1db63ee 100644 --- a/sbin/fdisk/fdisk.8 +++ b/sbin/fdisk/fdisk.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fdisk.8,v 1.52 2006/10/20 03:54:24 dhill Exp $ +.\" $OpenBSD: fdisk.8,v 1.53 2006/11/08 23:22:26 deraadt Exp $ .\" .\" Copyright (c) 1997 Tobias Weingartner .\" All rights reserved. @@ -31,7 +31,7 @@ .Nd MBR partition maintenance program .Sh SYNOPSIS .Nm fdisk -.Op Fl ieu +.Op Fl ieuy .Oo .Fl c Ar cylinders .Fl h Ar heads @@ -227,6 +227,8 @@ This is useful for writing new MBR bootcode onto an existing drive, and is equivalent to the DOS command .Dq FDISK /MBR . Note that this option will overwrite the NT disk signature, if present. +.It Fl y +Avoid asking yes/no questions when not desireable. .El .Sh COMMAND MODE The 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(); } diff --git a/sbin/fdisk/misc.c b/sbin/fdisk/misc.c index 3c9be4c0e2c..7909aaef717 100644 --- a/sbin/fdisk/misc.c +++ b/sbin/fdisk/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.17 2006/10/24 17:30:45 moritz Exp $ */ +/* $OpenBSD: misc.c,v 1.18 2006/11/08 23:22:26 deraadt Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -139,6 +139,10 @@ int ask_yn(const char *str) { int ch, first; + extern int y_flag; + + if (y_flag) + return (1); printf("%s [n] ", str); fflush(stdout); |