diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-05-07 04:36:46 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-05-07 04:36:46 +0200 |
| commit | c3f8db99bf91e6fb131c8d2240fc4d5a44ed561a (patch) | |
| tree | b17ce8082c4ea7c77e01482c1f597b45b2820411 /procps | |
| parent | 4d6059eedc665b46c274f40067af20e3aad46894 (diff) | |
| download | busybox-w32-c3f8db99bf91e6fb131c8d2240fc4d5a44ed561a.tar.gz busybox-w32-c3f8db99bf91e6fb131c8d2240fc4d5a44ed561a.tar.bz2 busybox-w32-c3f8db99bf91e6fb131c8d2240fc4d5a44ed561a.zip | |
preparatory patch
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
| -rw-r--r-- | procps/iostat.c | 39 |
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) | |||
| 128 | printf("%s\n", buf); | 128 | printf("%s\n", buf); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | static cputime_t get_smp_uptime(void) | ||
| 132 | { | ||
| 133 | FILE *fp; | ||
| 134 | char buf[sizeof(long)*3 * 2 + 4]; | ||
| 135 | unsigned long sec, dec; | ||
| 136 | |||
| 137 | fp = xfopen_for_read("/proc/uptime"); | ||
| 138 | |||
| 139 | if (fgets(buf, sizeof(buf), fp)) | ||
| 140 | if (sscanf(buf, "%lu.%lu", &sec, &dec) != 2) | ||
| 141 | bb_error_msg_and_die("can't read /proc/uptime"); | ||
| 142 | |||
| 143 | fclose(fp); | ||
| 144 | |||
| 145 | return (cputime_t)sec * G.clk_tck + dec * G.clk_tck / 100; | ||
| 146 | } | ||
| 147 | |||
| 131 | /* Fetch CPU statistics from /proc/stat */ | 148 | /* Fetch CPU statistics from /proc/stat */ |
| 132 | static void get_cpu_statistics(struct stats_cpu *sc) | 149 | static void get_cpu_statistics(struct stats_cpu *sc) |
| 133 | { | 150 | { |
| @@ -153,23 +170,6 @@ static void get_cpu_statistics(struct stats_cpu *sc) | |||
| 153 | fclose(fp); | 170 | fclose(fp); |
| 154 | } | 171 | } |
| 155 | 172 | ||
| 156 | static cputime_t get_smp_uptime(void) | ||
| 157 | { | ||
| 158 | FILE *fp; | ||
| 159 | char buf[sizeof(long)*3 * 2 + 4]; | ||
| 160 | unsigned long sec, dec; | ||
| 161 | |||
| 162 | fp = xfopen_for_read("/proc/uptime"); | ||
| 163 | |||
| 164 | if (fgets(buf, sizeof(buf), fp)) | ||
| 165 | if (sscanf(buf, "%lu.%lu", &sec, &dec) != 2) | ||
| 166 | bb_error_msg_and_die("can't read /proc/uptime"); | ||
| 167 | |||
| 168 | fclose(fp); | ||
| 169 | |||
| 170 | return (cputime_t)sec * G.clk_tck + dec * G.clk_tck / 100; | ||
| 171 | } | ||
| 172 | |||
| 173 | /* | 173 | /* |
| 174 | * Obtain current uptime in jiffies. | 174 | * Obtain current uptime in jiffies. |
| 175 | * Uptime is sum of individual CPUs' uptimes. | 175 | * Uptime is sum of individual CPUs' uptimes. |
| @@ -507,11 +507,12 @@ int iostat_main(int argc, char **argv) | |||
| 507 | 507 | ||
| 508 | /* Store device names into device list */ | 508 | /* Store device names into device list */ |
| 509 | while (*argv && !isdigit(*argv[0])) { | 509 | while (*argv && !isdigit(*argv[0])) { |
| 510 | if (strcmp(*argv, "ALL") != 0) | 510 | if (strcmp(*argv, "ALL") != 0) { |
| 511 | /* If not ALL, save device name */ | 511 | /* If not ALL, save device name */ |
| 512 | save_to_devlist(*argv); | 512 | save_to_devlist(*argv); |
| 513 | else | 513 | } else { |
| 514 | G.show_all = 1; | 514 | G.show_all = 1; |
| 515 | } | ||
| 515 | argv++; | 516 | argv++; |
| 516 | } | 517 | } |
| 517 | 518 | ||
