Subject: bin/15897: fdformat badly prints a status for each track in a 80 columns terminal
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ryoh@jaist.ac.jp>
List: netbsd-bugs
Date: 03/14/2002 04:45:23
>Number: 15897
>Category: bin
>Synopsis: fdformat badly prints a status for each track in a 80 columns terminal
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Mar 13 11:46:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Ryo HAYASAKA
>Release: NetBSD 1.5ZA
>Organization:
Japan Advanced Institute of Science and Technology (JAIST)
>Environment:
System: NetBSD bonnie.jaist.ac.jp 1.5ZA NetBSD 1.5ZA (BONNIE) #209:
Sat Mar 9 14:54:02 JST 2002
ryoh@bonnie.jaist.ac.jp:/c/src/sys/arch/i386/compile/BONNIE i386
Architecture: i386
Machine: i386
fdformat.c:
$NetBSD: fdformat.c,v 1.9 2001/03/28 03:17:41 simonb Exp $
>Description:
A status for formatting each track is not good viewing in a regular
(80 columns) terminal. fdformat without verifying a track prints out
in a kterm (80 columns) like this:
# fdformat -n
Ready to format /dev/rfd0a with 80 cylinders, 2 tracks, 18 sectors of 512 bytes
(1440 KB) Yes/no [y]?
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
However, fdformat with verifying a track prints out like this:
# fdformat
Ready to format /dev/rfd0a with 80 cylinders, 2 tracks, 18 sectors of 512 bytes
(1440 KB) Yes/no [y]?
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVF
Note that the end of the line is corrupted. I think this is because
putchar('\b') at the beginning of a line is undefined in C
specification.
>How-To-Repeat:
Insert a floppy into your FDD, and type 'fdformat' in a regular (80
columns) terminal.
>Fix:
The following patch inserts '\n' at the end of each line. (I am not
sure whether this is good way or not...)
The patched fdformat will work like this:
# fdformat
Ready to format /dev/rfd0a with 80 cylinders, 2 tracks, 18 sectors of 512 bytes
(1440 KB) Yes/no [y]?
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
VV
Index: fdformat.c
===================================================================
RCS file: /usr/cvsup/basesrc/usr.bin/fdformat/fdformat.c,v
retrieving revision 1.9
diff -d -p -u -r1.9 fdformat.c
--- fdformat.c 2001/03/28 03:17:41 1.9
+++ fdformat.c 2002/03/13 19:21:54
@@ -71,6 +71,7 @@ int confirm(int);
int main __P((int, char **));
void usage __P((void));
int verify_track(int, int, int, struct fdformat_parms *, char *);
+int wincolsize __P((void));
int
confirm(int def)
@@ -125,6 +126,18 @@ usage(void)
exit(1);
}
+int
+wincolsize(void)
+{
+ int fd;
+ struct winsize win;
+
+ fd = STDIN_FILENO;
+ if (ioctl(fd, TIOCGWINSZ, &win) < 0)
+ warn("TIOCGWINSZ");
+ return win.ws_col;
+}
+
#define numarg(which, maskn) \
tmplong = strtol(optarg, &tmpcharp, 0); \
if (*tmpcharp != '\0' || tmplong <= 0 || tmplong == LONG_MIN || tmplong == LONG_MAX) \
@@ -159,6 +172,8 @@ main(int argc, char *argv[])
char *filename = _PATH_FLOPPY_DEV;
int fd;
int trk, cyl;
+ int colcnt = 0;
+ int colsize = wincolsize();
while ((ch = getopt(argc, argv, "f:t:nB:C:S:T:P:G:F:X:I:")) != -1)
switch (ch) {
@@ -281,6 +296,13 @@ main(int argc, char *argv[])
for (trk = 0; trk < parms.ntrk; trk++) {
cmd.head = trk;
if (ioctl(fd, FDIOCFORMAT_TRACK, &cmd) == 0) {
+ if (verify) {
+ colcnt++;
+ if (colcnt % colsize == 0) {
+ putchar('\n');
+ colcnt++;
+ }
+ }
putchar('F');
if (verify)
putchar('\b');
>Release-Note:
>Audit-Trail:
>Unformatted: