From 855a6a7055095f3d649439cd61c7eb7055a04756 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Wed, 1 Jul 2015 22:14:30 +1000 Subject: [PATCH] library: remove getpartitions_num from library getpartitions_num was only used in vmstat and basically counted partitions in disks, this is now moved to vmstat. --- proc/libprocps.sym | 2 -- proc/sysinfo.c | 15 --------- proc/sysinfo.h | 1 - vmstat.c | 84 ++++++++-------------------------------------- 4 files changed, 14 insertions(+), 88 deletions(-) diff --git a/proc/libprocps.sym b/proc/libprocps.sym index 7d2c881a..c3d4c87b 100644 --- a/proc/libprocps.sym +++ b/proc/libprocps.sym @@ -12,9 +12,7 @@ global: get_ns_name; get_pid_digits; get_slabinfo; - getbtime; getdiskstat; - getpartitions_num; getslabinfo; look_up_our_self; lookup_wchan; diff --git a/proc/sysinfo.c b/proc/sysinfo.c index b67f7c76..01d92058 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -171,21 +171,6 @@ static void crash(const char *filename) { } -/////////////////////////////////////////////////////////////////////// -// based on Fabian Frederick's /proc/diskstats parser - - -unsigned int getpartitions_num(struct disk_stat *disks, int ndisks){ - int i=0; - int partitions=0; - - for (i=0;i 0xffffffffull) { - level++; - val64 /= 1024; - } - - val32 = val64; - - while (val32 > 999) { - level++; - oldval = val32; - val32 /= 1024; - } - - if (val32 < 10) { - unsigned fract = (oldval % 1024) * 10 / 1024; - return sprintf(dst, "%u.%u%c ", val32, fract, suffix[level]); - } - return sprintf(dst, "%3u%c ", val32, suffix[level]); -} - -/* produce: " 6 ", "123 ", "123k ", etc. */ -static int format_1000(unsigned long long val64, char *restrict dst) -{ - unsigned oldval; - const char suffix[] = " kmgtpe"; - unsigned level = 0; - unsigned val32; - - if (val64 < 1000) { - /* special case to avoid "6.0 " when plain " 6 " would do */ - val32 = val64; - return sprintf(dst, "%3u ", val32); - } - - while (val64 > 0xffffffffull) { - level++; - val64 /= 1000; - } - - val32 = val64; - - while (val32 > 999) { - level++; - oldval = val32; - val32 /= 1000; - } - - if (val32 < 10) { - unsigned fract = (oldval % 1000) / 100; - return sprintf(dst, "%u.%u%c ", val32, fract, suffix[level]); - } - return sprintf(dst, "%3u%c ", val32, suffix[level]); -} -#endif - static void new_header(void) { struct tm *tm_ptr; @@ -269,6 +199,20 @@ static void new_header(void) printf("\n"); } +/////////////////////////////////////////////////////////////////////// +// based on Fabian Frederick's /proc/diskstats parser + +static unsigned int getpartitions_num(struct disk_stat *disks, int ndisks) +{ + unsigned int i; + int partitions=0; + + for (i=0; i