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:
parent
dae67d677c
commit
bbe2a99582
@ -1,10 +1,10 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= fdformat
|
||||
.PATH: ${.CURDIR}/../fdread
|
||||
|
||||
# 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
|
||||
PROG= fdformat
|
||||
SRCS= fdformat.c fdutil.c
|
||||
|
||||
CFLAGS+= -Wall -I ${.CURDIR}/../fdread
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user