From andyf@hewey.af.speednet.com.au  Wed Nov 12 08:06:23 2003
Return-Path: <andyf@hewey.af.speednet.com.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3086016A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 12 Nov 2003 08:06:23 -0800 (PST)
Received: from franky.speednet.com.au (franky.speednet.com.au [203.57.65.5])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D057843FB1
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 12 Nov 2003 08:06:21 -0800 (PST)
	(envelope-from andyf@hewey.af.speednet.com.au)
Received: from hewey.af.speednet.com.au (udsl-3-062.QLD.dft.com.au [202.168.108.62])
	by franky.speednet.com.au (8.12.8p2/8.12.8) with ESMTP id hACG6JdK030485
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Nov 2003 03:06:19 +1100 (EST)
	(envelope-from andyf@hewey.af.speednet.com.au)
Received: from hewey.af.speednet.com.au (localhost [127.0.0.1])
	by hewey.af.speednet.com.au (8.12.9p2/8.12.9) with ESMTP id hACG6IUQ083534
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Nov 2003 02:06:18 +1000 (EST)
	(envelope-from andyf@hewey.af.speednet.com.au)
Received: (from andyf@localhost)
	by hewey.af.speednet.com.au (8.12.9p2/8.12.9/Submit) id hACG6IXb083533;
	Thu, 13 Nov 2003 02:06:18 +1000 (EST)
	(envelope-from andyf)
Message-Id: <200311121606.hACG6IXb083533@hewey.af.speednet.com.au>
Date: Thu, 13 Nov 2003 02:06:18 +1000 (EST)
From: Andy Farkas <andyf@speednet.com.au>
Reply-To: Andy Farkas <andyf@speednet.com.au>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: systat(1) device select (:only) broken
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         59220
>Category:       bin
>Synopsis:       [patch] systat(1) device select (:only) broken
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    obrien
>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:  Fri Oct  5 22:00:25 UTC 2012
>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:
Responsible-Changed-From-To: freebsd-bugs->obrien 
Responsible-Changed-By: obrien 
Responsible-Changed-When: Mon Dec 1 19:15:25 PST 2003 
Responsible-Changed-Why:  
I'll take this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=59220 

From: Michael Gmelin <freebsd@grem.de>
To: bug-followup@FreeBSD.org, andyf@speednet.com.au
Cc:  
Subject: Re: bin/59220: [patch] systat(1) device select (:only) broken
Date: Fri, 5 Oct 2012 23:51:47 +0200

 *cough* this still hasn't been fixed, could somebody test and apply the
 patch? (I would volunteer to test it, but only if there is any
 indication that this is not completely abandoned - 9 years *cough*)
 
 -- 
 Michael Gmelin
>Unformatted:
