summaryrefslogtreecommitdiffstats
path: root/usr.sbin/fdformat
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2001-07-02 21:24:03 +0000
committerjoerg <joerg@FreeBSD.org>2001-07-02 21:24:03 +0000
commitbbe2a9958251b6354eb8a29574e5a32ee240e3cf (patch)
tree8b72958d10d845733b6dbab0ed3bf9ed9b1c6c3a /usr.sbin/fdformat
parentdae67d677c018da01825e6b75c0d0348f1cc680d (diff)
downloadFreeBSD-src-bbe2a9958251b6354eb8a29574e5a32ee240e3cf.zip
FreeBSD-src-bbe2a9958251b6354eb8a29574e5a32ee240e3cf.tar.gz
Use the printstatus() function from ${.CURDIR}/../fdread/fdutil.c to
give a bit more information about up to 10 errors encountered during formatting (unless -q has been specified, of course). While being here, removed a bitrotten comment in the Makefile, and kill the old Emacs local variable stuff at the end of fdformat.c that's no longer useful anway.
Diffstat (limited to 'usr.sbin/fdformat')
-rw-r--r--usr.sbin/fdformat/Makefile8
-rw-r--r--usr.sbin/fdformat/fdformat.16
-rw-r--r--usr.sbin/fdformat/fdformat.c50
3 files changed, 39 insertions, 25 deletions
diff --git a/usr.sbin/fdformat/Makefile b/usr.sbin/fdformat/Makefile
index 3c0d4ec..40683ea 100644
--- a/usr.sbin/fdformat/Makefile
+++ b/usr.sbin/fdformat/Makefile
@@ -1,10 +1,10 @@
# $FreeBSD$
+.PATH: ${.CURDIR}/../fdread
+
PROG= fdformat
+SRCS= fdformat.c fdutil.c
-# the -I's seem to be confusing, but necessery this way
-# (so the right <unistd.h> will be found in /usr/include, and the
-# "../i386/isa/ic/nec765.h" included from fdreg.h is accessible, too)
-CFLAGS+= -Wall
+CFLAGS+= -Wall -I ${.CURDIR}/../fdread
.include <bsd.prog.mk>
diff --git a/usr.sbin/fdformat/fdformat.1 b/usr.sbin/fdformat/fdformat.1
index bc46b30..339f0ea 100644
--- a/usr.sbin/fdformat/fdformat.1
+++ b/usr.sbin/fdformat/fdformat.1
@@ -1,4 +1,4 @@
-.\" Copyright (C) 1993, 1994, 1995 by Joerg Wunsch, Dresden
+.\" Copyright (C) 1993, 1994, 1995, 2001 by Joerg Wunsch, Dresden
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 16, 1993
+.Dd July 2, 2001
.Os
.Dt FDFORMAT 1
.Sh NAME
@@ -141,6 +141,8 @@ is printed when the track(s) is being formatted, then a
while it's being verified, and if an error has been detected, it
will finally change to
.Sq Em E .
+Detailed status information (cylinder, head and sector number, and the
+exact cause of the error) will then be printed for up to 10 errors.
.Pp
An exit status of 0 is returned upon successful operation.
Exit status
diff --git a/usr.sbin/fdformat/fdformat.c b/usr.sbin/fdformat/fdformat.c
index 178fd2a..157cb7d 100644
--- a/usr.sbin/fdformat/fdformat.c
+++ b/usr.sbin/fdformat/fdformat.c
@@ -42,6 +42,7 @@
#include <ctype.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <stdio.h>
@@ -51,6 +52,8 @@
#include <sys/fdcio.h>
+#include "fdutil.h"
+
static void
format_track(int fd, int cyl, int secs, int head, int rate,
int gaplen, int secsize, int fill,int interleave)
@@ -172,10 +175,12 @@ main(int argc, char **argv)
int format = -1, cyls = -1, secs = -1, heads = -1, intleave = -1;
int rate = -1, gaplen = -1, secsize = -1, steps = -1;
int fill = 0xf6, quiet = 0, verify = 1, verify_only = 0, confirm = 0;
- int fd, c, track, error, tracks_per_dot, bytes_per_track, errs;
+ int fd, c, i, track, error, tracks_per_dot, bytes_per_track, errs;
int fdopts;
const char *devname, *suffix;
struct fd_type fdt;
+#define MAXPRINTERRS 10
+ struct fdc_status fdcs[MAXPRINTERRS];
while((c = getopt(argc, argv, "f:c:s:h:r:g:S:F:t:i:qyvn")) != -1)
switch(c) {
@@ -336,8 +341,16 @@ main(int argc, char **argv)
}
}
if (verify) {
- if (verify_track(fd, track, bytes_per_track) < 0)
- error = errs = 1;
+ if (verify_track(fd, track, bytes_per_track) < 0) {
+ error = 1;
+ if (errs < MAXPRINTERRS && errno == EIO) {
+ if (ioctl(fd, FD_GSTAT, fdcs + errs) ==
+ -1)
+ errx(1,
+ "floppy IO error, but no FDC status");
+ errs++;
+ }
+ }
if(!quiet && !((track + 1) % tracks_per_dot)) {
if (!verify_only)
putchar('\b');
@@ -354,20 +367,19 @@ main(int argc, char **argv)
if(!quiet)
printf(" done.\n");
- return errs;
+ if (!quiet && errs) {
+ fflush(stdout);
+ fprintf(stderr, "Errors encountered:\nCyl Head Sect Error\n");
+ for (i = 0; i < errs && i < MAXPRINTERRS; i++) {
+ fprintf(stderr, " %2d %2d %2d ",
+ fdcs[i].status[3], fdcs[i].status[4],
+ fdcs[i].status[5]);
+ printstatus(fdcs + i, 1);
+ putc('\n', stderr);
+ }
+ if (errs >= MAXPRINTERRS)
+ fprintf(stderr, "(Further errors not printed.)\n");
+ }
+
+ return errs != 0;
}
-/*
- * Local Variables:
- * c-indent-level: 8
- * c-continued-statement-offset: 8
- * c-continued-brace-offset: 0
- * c-brace-offset: -8
- * c-brace-imaginary-offset: 0
- * c-argdecl-indent: 8
- * c-label-offset: -8
- * c++-hanging-braces: 1
- * c++-access-specifier-offset: -8
- * c++-empty-arglist-indent: 8
- * c++-friend-offset: 0
- * End:
- */
OpenPOWER on IntegriCloud