Your message dated Mon, 7 Apr 2008 09:41:00 +1000
with message-id <[EMAIL PROTECTED]>
and subject line Fixed in procps 1:3.2.7-5
has caused the Debian Bug report #408088,
regarding vmstat has.. strange option processing logic (home-grown getopt)
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [EMAIL PROTECTED]
immediately.)
--
408088: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=408088
Debian Bug Tracking System
Contact [EMAIL PROTECTED] with problems
--- Begin Message ---
Package: procps
Version: 1:3.2.7-3
Severity: minor
Tags: patch
vmstat utility in procps uses its own getopt()-like command-line option
processor, which does not work in the usual way. For example things
like `vmstat -SM', -- only `vmstat -S M' works correctly.
Patch below replaces home-grown getopt() with real getopt() call.
While we're at it, it also fixes some other minor things -- for example,
it properly initializes szDataUnit, so that `vmstat -s' actually prints
the units instead of just two spaces; It also allows to have units of
bytes. And some more trivial things like this.
I wanted to fix this annoying thing for a very long time now, but each
time ended up after looking at sourceforge pages trying to find a way
to submit a bug/enhancement report. So finally I gave up and am filing
this bug against debian package - in a hope there's some more direct way
to report this upstream... ;)
Thanks!
/mjt
--- procps-3.2.7/vmstat.c.orig 2006-06-25 10:41:48.000000000 +0400
+++ procps-3.2.7/vmstat.c 2007-01-23 15:27:00.000000000 +0300
@@ -29,14 +29,15 @@
#include "proc/sysinfo.h"
#include "proc/version.h"
-static unsigned long dataUnit=1024;
-static char szDataUnit [16];
#define UNIT_B 1
#define UNIT_k 1000
#define UNIT_K 1024
#define UNIT_m 1000000
#define UNIT_M 1048576
+static unsigned long dataUnit=UNIT_K;
+static char szDataUnit[3] = "K";
+
#define VMSTAT 0
#define DISKSTAT 0x00000001
#define VMSUMSTAT 0x00000002
@@ -582,12 +583,10 @@ static int winhi(void) {
////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[]) {
- char partition[16];
- argc=0; /* redefined as number of integer arguments */
- for (argv++;*argv;argv++) {
- if ('-' ==(**argv)) {
- switch (*(++(*argv))) {
-
+ char *partition = NULL;
+ int c;
+
+ while((c = getopt(argc, argv, "VdafmDnp:S:s")) != EOF) switch(c) {
case 'V':
display_version();
exit(0);
@@ -603,7 +602,7 @@ int main(int argc, char *argv[]) {
fork_format();
exit(0);
case 'm':
- statMode |= SLABSTAT;
+ statMode |= SLABSTAT;
break;
case 'D':
statMode |= DISKSUMSTAT;
@@ -614,53 +613,40 @@ int main(int argc, char *argv[]) {
break;
case 'p':
statMode |= PARTITIONSTAT;
- if (argv[1]){
- char *cp = *++argv;
- if(!memcmp(cp,"/dev/",5)) cp += 5;
- snprintf(partition, sizeof partition, "%s", cp);
- }else{
- fprintf(stderr, "-p requires an argument\n");
- exit(EXIT_FAILURE);
- }
+ partition = optarg;
+ if (memcmp(partition, "/dev/", 5) == 0) partition += 5;
break;
case 'S':
- if (argv[1]){
- ++argv;
- if (!strcmp(*argv, "k")) dataUnit=UNIT_k;
- else if (!strcmp(*argv, "K")) dataUnit=UNIT_K;
- else if (!strcmp(*argv, "m")) dataUnit=UNIT_m;
- else if (!strcmp(*argv, "M")) dataUnit=UNIT_M;
- else {fprintf(stderr, "-S requires k, K, m or M (default is
kb)\n");
- exit(EXIT_FAILURE);
- }
- strcpy(szDataUnit, *argv);
- }else {fprintf(stderr, "-S requires an argument\n");
- exit(EXIT_FAILURE);
- }
+ switch(optarg[0]) {
+ case 'b': case 'B': dataUnit = UNIT_B; break;
+ case 'k': dataUnit = UNIT_k; break;
+ case 'K': dataUnit = UNIT_K; break;
+ case 'm': dataUnit = UNIT_m; break;
+ case 'M': dataUnit = UNIT_M; break;
+ default:
+ fprintf(stderr, "-S requires k, K, m or M (default is kb)\n");
+ exit(EXIT_FAILURE);
+ }
+ szDataUnit[0] = optarg[0];
break;
case 's':
- statMode |= VMSUMSTAT;
+ statMode |= VMSUMSTAT;
break;
default:
/* no other aguments defined yet. */
usage();
- }
- }else{
- argc++;
- switch (argc) {
- case 1:
- if ((sleep_time = atoi(*argv)) == 0)
+ }
+
+ if (optind < argc) {
+ if ((sleep_time = atoi(argv[optind++])) == 0)
usage();
- num_updates = ULONG_MAX;
- break;
- case 2:
- num_updates = atol(*argv);
- break;
- default:
- usage();
- } /* switch */
+ num_updates = ULONG_MAX;
}
-}
+ if (optind < argc)
+ num_updates = atol(argv[optind++]);
+ if (optind < argc)
+ usage();
+
if (moreheaders) {
int tmp=winhi()-3;
height=((tmp>0)?tmp:22);
--- End Message ---
--- Begin Message ---
Package: procps
Version: 1:3.2.7-5
Hello,
For some reason this patch was applied in 3.2.7-5 but I didn't put it
in the changelog. I'm closing the bug now.
- Craig
--
Craig Small GnuPG:1C1B D893 1418 2AF4 45EE 95CB C76C E5AC 12CA DFA5
http://www.enc.com.au/ csmall at : enc.com.au
http://www.debian.org/ Debian GNU/Linux, software should be Free
--- End Message ---