bin/59220: systat(1) device select (:only) broken
Andy Farkas
andyf at speednet.com.au
Wed Nov 12 08:10:26 PST 2003
>Number: 59220
>Category: bin
>Synopsis: systat(1) device select (:only) broken
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Nov 12 08:10:23 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Andy Farkas
>Release: FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
File: src/usr.bin/systat/devs.c
Revision 1.6, Wed Dec 12 00:13:37 2001 UTC (23 months ago) by markm
Branch: MAIN
CVS Tags: RELENG_5_0_BP, RELENG_5_0_0_RELEASE, RELENG_5_0
Changes since 1.5: +37 -30 lines
WARNS=2 fixes with NO_WERROR set, as there are some header issues
with namelists. use __FBSDID().
>Description:
systat(1) :only option is supposed to accept multiple drives.
Its been broken for almost 2 years!
>How-To-Repeat:
systat -v
[type ":only da0 da1"]
>Fix:
This works for me, although it may be wrong:
diff -u ./devs.c-orig ./devs.c
--- ./devs.c-orig Tue Oct 21 06:13:50 2003
+++ ./devs.c Thu Nov 13 01:25:45 2003
@@ -269,23 +269,24 @@
specified_devices = (char **)malloc(sizeof(char *));
tmpstr = tmpstr1 = strdup(args);
- cp = index(tmpstr1, '\n');
+ cp = index(tmpstr, '\n');
if (cp)
*cp = '\0';
+
for (;;) {
- for (cp = tmpstr1; *cp && isspace(*cp); cp++)
+ for (cp = tmpstr; *cp && isspace(*cp); cp++)
;
- tmpstr1 = cp;
+ tmpstr = cp;
for (; *cp && !isspace(*cp); cp++)
;
if (*cp)
*cp++ = '\0';
- if (cp - args == 0)
+ if (cp - tmpstr == 0)
break;
for (i = 0; i < num_devices; i++) {
asprintf(&buffer, "%s%d", dev_select[i].device_name,
dev_select[i].unit_number);
- if (strcmp(buffer, tmpstr1) == 0) {
+ if (strcmp(tmpstr, buffer) == 0) {
num_devices_specified++;
@@ -294,7 +295,7 @@
sizeof(char *) *
num_devices_specified);
specified_devices[num_devices_specified -1]=
- strdup(tmpstr1);
+ strdup(tmpstr);
free(buffer);
break;
@@ -303,10 +304,10 @@
free(buffer);
}
if (i >= num_devices)
- error("%s: unknown drive", args);
- args = cp;
+ error("%s: unknown drive", tmpstr);
+ tmpstr = cp;
}
- free(tmpstr);
+ free(tmpstr1);
if (num_devices_specified > 0) {
last_type = DS_MATCHTYPE_SPEC;
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list