diff --git a/usr.sbin/fdwrite/fdwrite.1 b/usr.sbin/fdwrite/fdwrite.1 index d445eed3de4f..53cb70e8de4c 100644 --- a/usr.sbin/fdwrite/fdwrite.1 +++ b/usr.sbin/fdwrite/fdwrite.1 @@ -6,7 +6,7 @@ .\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp .\" ---------------------------------------------------------------------------- .\" -.\" $Id: fdwrite.1,v 1.4 1997/02/22 16:05:48 peter Exp $ +.\" $Id: fdwrite.1,v 1.5 1997/05/19 16:33:27 eivind Exp $ .\" .\" .Dd September 16, 1993 @@ -17,9 +17,10 @@ .Nd format and write floppy disks .Sh SYNOPSIS .Nm fdwrite -.Bq Fl v -.Bq Fl f Ar inputfile -.Bq Fl d Ar device +.Op Fl v +.Op Fl y +.Op Fl f Ar inputfile +.Op Fl d Ar device .Sh DESCRIPTION .Nm Fdwrite formats and writes one and more floppy disks. @@ -40,7 +41,7 @@ This continues until the program is interrupted or EOF is encountered on the The options are as follows: .Bl -tag -width 10n -offset indent .It Fl v -toggles verbosity on stdout. +Toggle verbosity on stdout. Default is ``on''. After .Ar device @@ -49,6 +50,9 @@ During operation progress will be reported with the number of tracks remaining on the current floppy disk, and the letters I, Z, F, W, R and C, which indicates completion of Input, Zero-fill, Format Write, Read and Compare of current track respectively. +.It Fl y +Don't ask for presence of a floppy disk in the drive. This non-interactive flag +is useful for shell scripts. .It Fl f Ar inputfile Input file to read. If none is given, stdin is assumed. .It Fl d Ar device @@ -92,7 +96,7 @@ Some of the code was taken from .Xr fdformat 1 . .Sh AUTHOR The program has been contributed by -Poul-Henning Kamp +.An Poul-Henning Kamp Aq phk@login.dknet.dk .Sh BUGS Diagnostics are less than complete at present. diff --git a/usr.sbin/fdwrite/fdwrite.c b/usr.sbin/fdwrite/fdwrite.c index 908bb86cbc00..e0c176b59e9a 100644 --- a/usr.sbin/fdwrite/fdwrite.c +++ b/usr.sbin/fdwrite/fdwrite.c @@ -6,18 +6,18 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id$ + * $Id: fdwrite.c,v 1.6 1997/02/22 16:05:49 peter Exp $ * */ +#include +#include +#include #include #include -#include -#include #include -#include +#include -#include #include int @@ -54,9 +54,9 @@ format_track(int fd, int cyl, int secs, int head, int rate, } static void -usage () +usage() { - printf("Usage:\n\tfdwrite [-v] [-y] [-f inputfile] [-d device]\n"); + fprintf(stderr, "usage: fdwrite [-v] [-y] [-f inputfile] [-d device]\n"); exit(2); } @@ -71,7 +71,7 @@ main(int argc, char **argv) FILE *tty; setbuf(stdout,0); - while((c = getopt(argc, argv, "d:s:f:vy")) != -1) + while((c = getopt(argc, argv, "d:f:vy")) != -1) switch(c) { case 'd': /* Which drive */ device = optarg; @@ -81,10 +81,8 @@ main(int argc, char **argv) if (inputfd >= 0) close(inputfd); inputfd = open(optarg,O_RDONLY); - if (inputfd < 0) { - perror(optarg); - exit(1); - } + if (inputfd < 0) + err(1, "%s", optarg); break; case 'v': /* Toggle verbosity */ @@ -109,10 +107,8 @@ main(int argc, char **argv) usage(); tty = fopen("/dev/tty","r+"); - if(!tty) { - perror("/dev/tty"); - exit(1); - } + if(!tty) + err(1, "/dev/tty"); setbuf(tty,0); for(j=1;j > 0;) { @@ -127,24 +123,20 @@ main(int argc, char **argv) } } - if((fd = open(device, O_RDWR)) < 0) { - perror(device); - exit(1); - } + if((fd = open(device, O_RDWR)) < 0) + err(1, "%s", device); - if(ioctl(fd, FD_GTYPE, &fdt) < 0) { - fprintf(stderr, "fdformat: not a floppy disk: %s\n", device); - exit(1); - } + if(ioctl(fd, FD_GTYPE, &fdt) < 0) + errx(1, "not a floppy disk: %s", device); bpt = fdt.sectrac * (1<