diff options
author | joerg <joerg@FreeBSD.org> | 2001-07-02 21:24:03 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 2001-07-02 21:24:03 +0000 |
commit | bbe2a9958251b6354eb8a29574e5a32ee240e3cf (patch) | |
tree | 8b72958d10d845733b6dbab0ed3bf9ed9b1c6c3a /usr.sbin/fdformat/fdformat.c | |
parent | dae67d677c018da01825e6b75c0d0348f1cc680d (diff) | |
download | FreeBSD-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/fdformat.c')
-rw-r--r-- | usr.sbin/fdformat/fdformat.c | 50 |
1 files changed, 31 insertions, 19 deletions
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: - */ |