Subject: bin/1500: Error in /usr/sbin/diskpart
To: None <gnats-bugs@gnats.netbsd.org>
From: Peter Svensson <petersv@df.lth.se>
List: netbsd-bugs
Date: 09/24/1995 10:50:33
>Number: 1500
>Category: bin
>Synopsis: Several errors in diskpart.c
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Sep 25 10:50:00 1995
>Last-Modified:
>Originator: Peter Svensson
>Organization:
The Computer Society at Lund University and Lund Institute of Technology
>Release: 950915 <NetBSD-current source date>
>Environment:
System: NetBSD piau.df.lth.se 1.0A NetBSD 1.0A (PIAU.SCSI) #2: Sun Sep 17 14:51:13 MET DST 1995 root@merlin.df.lth.se:/usr/src/sys/arch/sparc/compile/PIAU.SCSI sparc
>Description:
There were several errors in the file src/usr.sbin/diskpart.c which
prevented it for functioning correctly. The errors were most apparent
when doing a "diskpart -d" with a previously unknown disk type. The "ty:"
field would be filled with random garbage due to a missed assignment.
An addition rather than a subtraction of the argc counter prevented the
-s flag from operating correctly.
Even if one didn't select SMD disk as the disk type the program would
stop to promt for the availability of bad144, but lead text would only be
produced for SMD-disks.
>How-To-Repeat:
#: diskpart -d test1
Enter correct data. The produced disktab would contain garbage in the
"ty:" field.
>Fix:
The included "diff -U 2" seems to solve the problems.
-----------------------
--- diskpart.c Tue May 30 14:53:53 1995
+++ diskpartfix.c Sun Sep 24 10:39:18 1995
@@ -138,7 +138,13 @@
if (argc > 1 && strcmp(*argv, "-s") == 0) {
totsize = atoi(argv[1]);
- argc += 2, argv += 2;
+ argc -= 2, argv += 2;
+ }
+ if (argc > 0)
+ dp = getdiskbyname(*argv);
+ else {
+ fprintf(stderr,
+ "usage: diskpart [ -p ] [ -d ] [ -s size ] disk-type\n");
+ exit(1);
}
- dp = getdiskbyname(*argv);
if (dp == NULL) {
if (isatty(0))
@@ -148,5 +154,5 @@
exit(2);
}
- } else {
+ }
if (dp->d_flags & D_REMOVABLE)
tyname = "removable";
@@ -155,5 +161,4 @@
else
tyname = "winchester";
- }
spc = dp->d_secpercyl;
/*
@@ -399,12 +404,12 @@
goto gettype;
}
- strncpy(dp->d_typename, buf, sizeof(dp->d_typename));
fprintf(stderr, "(type <cr> to get default value, if only one)\n");
- if (dp->d_type == DTYPE_SMD)
+ if (dp->d_type == DTYPE_SMD) {
fprintf(stderr, "Do %ss support bad144 bad block forwarding (yes)? ",
dp->d_typename);
- (void) gets(buf);
+ (void) gets(buf);
if (*buf != 'n')
dp->d_flags |= D_BADSECT;
+ }
for (fp = fields; fp->f_name != NULL; fp++) {
again:
--------------------
>Audit-Trail:
>Unformatted: