walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
4f0634d
commit 5be04020788598cb811e51c4b1342cf0796cbb65
4f0634d
Author: Jeff Layton <jlayton@redhat.com>
4f0634d
Date:   Mon Jun 23 07:21:52 2008 -0400
4f0634d
4f0634d
    The nfsstat program reads /proc/net/rpc/* files to gets info about
4f0634d
    calls. This info is output as unsigned numbers (at least on any
4f0634d
    relatively recent kernel). When nfsstat prints these numbers, they are
4f0634d
    printed as signed integers. When the call counters reach 2^31, things
4f0634d
    start being printed as negative numbers.
4f0634d
    
4f0634d
    This patch changes nfsstat to read and print all counters as unsigned
4f0634d
    integers. Tested by hacking up a kernel to initialize call counters to
4f0634d
    2^31+1.
4f0634d
    
4f0634d
    Thanks to Takafumi Miki for the initial version of this patch.
4f0634d
    
4f0634d
    Signed-off-by: Jeff Layton <jlayton@redhat.com>
4f0634d
    Signed-off-by: Steve Dickson <steved@redhat.com>
4f0634d
4f0634d
diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
4f0634d
index d2cca8d..1517414 100644
4f0634d
--- a/utils/nfsstat/nfsstat.c
4f0634d
+++ b/utils/nfsstat/nfsstat.c
4f0634d
@@ -539,7 +539,7 @@ print_numbers(const char *hdr, unsigned int *info, unsigned int nr)
4f0634d
 
4f0634d
 	fputs(hdr, stdout);
4f0634d
 	for (i = 0; i < nr; i++)
4f0634d
-		printf("%s%-8d", i? "   " : "", info[i]);
4f0634d
+		printf("%s%-8u", i? "   " : "", info[i]);
4f0634d
 	printf("\n");
4f0634d
 }
4f0634d
 
4f0634d
@@ -562,7 +562,7 @@ print_callstats(const char *hdr, const char **names,
4f0634d
 		printf("\n");
4f0634d
 		for (j = 0; j < 6 && i + j < nr; j++) {
4f0634d
 			pct = ((unsigned long long) info[i+j]*100)/total;
4f0634d
-			printf("%-8d%3llu%% ", info[i+j], pct);
4f0634d
+			printf("%-8u%3llu%% ", info[i+j], pct);
4f0634d
 		}
4f0634d
 		printf("\n");
4f0634d
 	}
4f0634d
@@ -604,7 +604,7 @@ parse_raw_statfile(const char *name, struct statinfo *statp)
4f0634d
 		for (i = 0; i < cnt; i++) {
4f0634d
 			if (!(sp = strtok(NULL, " \t")))
4f0634d
 				break;
4f0634d
-			ip->valptr[i] = atoi(sp);
4f0634d
+			ip->valptr[i] = (unsigned int) strtoul(sp, NULL, 0);
4f0634d
 			total += ip->valptr[i];
4f0634d
 		}
4f0634d
 		ip->valptr[cnt - 1] = total;
4f0634d
@@ -618,7 +618,8 @@ parse_raw_statfile(const char *name, struct statinfo *statp)
4f0634d
 static int
4f0634d
 parse_pretty_statfile(const char *filename, struct statinfo *info)
4f0634d
 {
4f0634d
-	int numvals, curindex, numconsumed, n, sum, err = 1;
4f0634d
+	int numvals, curindex, numconsumed, n, err = 1;
4f0634d
+	unsigned int sum;
4f0634d
 	char buf[4096], *bufp, *fmt, is_proc;
4f0634d
 	FILE *fp = NULL;
4f0634d
 	struct statinfo *ip;