aboutsummaryrefslogtreecommitdiff
path: root/procps/iostat.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-05-07 04:36:46 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2011-05-07 04:36:46 +0200
commitc3f8db99bf91e6fb131c8d2240fc4d5a44ed561a (patch)
treeb17ce8082c4ea7c77e01482c1f597b45b2820411 /procps/iostat.c
parent4d6059eedc665b46c274f40067af20e3aad46894 (diff)
downloadbusybox-c3f8db99bf91e6fb131c8d2240fc4d5a44ed561a.tar.gz
preparatory patch
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps/iostat.c')
-rw-r--r--procps/iostat.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/procps/iostat.c b/procps/iostat.c
index 06a33eb1d..28bf4dec2 100644
--- a/procps/iostat.c
+++ b/procps/iostat.c
@@ -128,6 +128,23 @@ static void print_timestamp(void)
printf("%s\n", buf);
}
+static cputime_t get_smp_uptime(void)
+{
+ FILE *fp;
+ char buf[sizeof(long)*3 * 2 + 4];
+ unsigned long sec, dec;
+
+ fp = xfopen_for_read("/proc/uptime");
+
+ if (fgets(buf, sizeof(buf), fp))
+ if (sscanf(buf, "%lu.%lu", &sec, &dec) != 2)
+ bb_error_msg_and_die("can't read /proc/uptime");
+
+ fclose(fp);
+
+ return (cputime_t)sec * G.clk_tck + dec * G.clk_tck / 100;
+}
+
/* Fetch CPU statistics from /proc/stat */
static void get_cpu_statistics(struct stats_cpu *sc)
{
@@ -153,23 +170,6 @@ static void get_cpu_statistics(struct stats_cpu *sc)
fclose(fp);
}
-static cputime_t get_smp_uptime(void)
-{
- FILE *fp;
- char buf[sizeof(long)*3 * 2 + 4];
- unsigned long sec, dec;
-
- fp = xfopen_for_read("/proc/uptime");
-
- if (fgets(buf, sizeof(buf), fp))
- if (sscanf(buf, "%lu.%lu", &sec, &dec) != 2)
- bb_error_msg_and_die("can't read /proc/uptime");
-
- fclose(fp);
-
- return (cputime_t)sec * G.clk_tck + dec * G.clk_tck / 100;
-}
-
/*
* Obtain current uptime in jiffies.
* Uptime is sum of individual CPUs' uptimes.
@@ -507,11 +507,12 @@ int iostat_main(int argc, char **argv)
/* Store device names into device list */
while (*argv && !isdigit(*argv[0])) {
- if (strcmp(*argv, "ALL") != 0)
+ if (strcmp(*argv, "ALL") != 0) {
/* If not ALL, save device name */
save_to_devlist(*argv);
- else
+ } else {
G.show_all = 1;
+ }
argv++;
}