Package: procps Version: 1:3.2.8-9 Severity: normal Tags: upstream patch
>From 64822112bb271a2195f3df3f9a54498d04005597 Mon Sep 17 00:00:00 2001 From: David Fries <[email protected]> Date: Sat, 2 Apr 2011 12:39:11 -0500 Subject: [PATCH 2/2] vmstat truncate so 32 bit programs get meaningful data Truncate 64 bit to 32 bit when reading /proc/vmstat in 32 bit programs. 32 bit kernels would have truncated the values already, but 64 bit kernels don't, so once a variable goes over 32 bits existing programs only get a max unsigned long value. Truncate it so they would get the same values they always used to on 32 bit kernels. 64 bit programs continue to get the full value. It was either this, modify the API to always use 64 bit values, or add another function that would pass the 64 bit values in 32 bit programs. --- proc/sysinfo.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/proc/sysinfo.c b/proc/sysinfo.c index 6b40825..744dc47 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -745,6 +745,9 @@ void vminfo(void){ {"slabs_scanned", &vm_slabs_scanned}, }; const int vm_table_count = sizeof(vm_table)/sizeof(vm_table_struct); +#if __SIZEOF_LONG__ == 4 + unsigned long long slotll; +#endif vm_pgalloc = 0; vm_pgrefill = 0; @@ -768,7 +771,15 @@ void vminfo(void){ ); head = tail+1; if(!found) goto nextline; +#if __SIZEOF_LONG__ == 4 + // A 32 bit kernel would have already truncated the value, a 64 bit kernel + // doesn't need to. Truncate here to let 32 bit programs to continue to get + // truncated values. It's that or change the API for a larger data type. + slotll = strtoull(head,&tail,10); + *(found->slot) = (unsigned long)slotll; +#else *(found->slot) = strtoul(head,&tail,10); +#endif nextline: //if(found) fprintf(stderr,"%s=%d\n",found->name,*(found->slot)); -- 1.7.2.3 >From c5a8218729754095cd6c8d9573f6e16123da190d Mon Sep 17 00:00:00 2001 From: David Fries <[email protected]> Date: Sat, 2 Apr 2011 12:05:52 -0500 Subject: [PATCH 1/2] sysinfo.c correct sscanf argument Was taking the address of the array, but should have just been the array pointer without taking the address. --- proc/sysinfo.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/proc/sysinfo.c b/proc/sysinfo.c index 65d94d7..6b40825 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -838,7 +838,7 @@ unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **parti break; } fields = sscanf(buff, " %*d %*d %15s %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %u", - &devname, &dummy); + devname, &dummy); if (fields == 2 && is_disk(devname)){ (*disks) = realloc(*disks, (cDisk+1)*sizeof(struct disk_stat)); sscanf(buff, " %*d %*d %15s %u %u %llu %u %u %u %llu %u %u %u %u", -- 1.7.2.3 -- System Information: Debian Release: 6.0 APT prefers stable APT policy: (500, 'stable') Architecture: i386 (x86_64) Kernel: Linux 2.6.36-rc7+ (SMP w/4 CPU cores) Locale: LANG=C, LC_CTYPE=en_US.ISO-8859-15 (charmap=ISO-8859-15) Shell: /bin/sh linked to /bin/dash Versions of packages procps depends on: ii initscripts 2.88dsf-13.1 scripts for initializing and shutt ii libc6 2.11.2-10 Embedded GNU C Library: Shared lib ii libncurses5 5.7+20100313-5 shared libraries for terminal hand ii libncursesw5 5.7+20100313-5 shared libraries for terminal hand ii lsb-base 3.2-23.2squeeze1 Linux Standard Base 3.2 init scrip Versions of packages procps recommends: ii psmisc 22.11-1 utilities that use the proc file s procps suggests no packages. -- no debconf information -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

