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.
This commit is contained in:
Joerg Wunsch 2001-07-02 21:24:03 +00:00
parent 65217f13ff
commit e42ad56f1a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=79111
3 changed files with 40 additions and 26 deletions

View File

@ -1,10 +1,10 @@
# $FreeBSD$ # $FreeBSD$
PROG= fdformat .PATH: ${.CURDIR}/../fdread
# the -I's seem to be confusing, but necessery this way PROG= fdformat
# (so the right <unistd.h> will be found in /usr/include, and the SRCS= fdformat.c fdutil.c
# "../i386/isa/ic/nec765.h" included from fdreg.h is accessible, too)
CFLAGS+= -Wall CFLAGS+= -Wall -I ${.CURDIR}/../fdread
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -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. .\" All rights reserved.
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" Redistribution and use in source and binary forms, with or without
@ -24,7 +24,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd September 16, 1993 .Dd July 2, 2001
.Os .Os
.Dt FDFORMAT 1 .Dt FDFORMAT 1
.Sh NAME .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 while it's being verified, and if an error has been detected, it
will finally change to will finally change to
.Sq Em E . .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 .Pp
An exit status of 0 is returned upon successful operation. An exit status of 0 is returned upon successful operation.
Exit status Exit status

View File

@ -42,6 +42,7 @@
#include <ctype.h> #include <ctype.h>
#include <err.h> #include <err.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <paths.h> #include <paths.h>
#include <stdio.h> #include <stdio.h>
@ -51,6 +52,8 @@
#include <sys/fdcio.h> #include <sys/fdcio.h>
#include "fdutil.h"
static void static void
format_track(int fd, int cyl, int secs, int head, int rate, format_track(int fd, int cyl, int secs, int head, int rate,
int gaplen, int secsize, int fill,int interleave) 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 format = -1, cyls = -1, secs = -1, heads = -1, intleave = -1;
int rate = -1, gaplen = -1, secsize = -1, steps = -1; int rate = -1, gaplen = -1, secsize = -1, steps = -1;
int fill = 0xf6, quiet = 0, verify = 1, verify_only = 0, confirm = 0; 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; int fdopts;
const char *devname, *suffix; const char *devname, *suffix;
struct fd_type fdt; 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) while((c = getopt(argc, argv, "f:c:s:h:r:g:S:F:t:i:qyvn")) != -1)
switch(c) { switch(c) {
@ -336,8 +341,16 @@ main(int argc, char **argv)
} }
} }
if (verify) { if (verify) {
if (verify_track(fd, track, bytes_per_track) < 0) if (verify_track(fd, track, bytes_per_track) < 0) {
error = errs = 1; 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(!quiet && !((track + 1) % tracks_per_dot)) {
if (!verify_only) if (!verify_only)
putchar('\b'); putchar('\b');
@ -354,20 +367,19 @@ main(int argc, char **argv)
if(!quiet) if(!quiet)
printf(" done.\n"); 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:
*/