Commit 2c4f4f1d authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov

iopint: unhardcode units for printing device size

Signed-off-by: default avatarKonstantin Khlebnikov <koct9i@gmail.com>
parent 9172aae6
...@@ -382,6 +382,7 @@ long long now(void) ...@@ -382,6 +382,7 @@ long long now(void)
char *path = NULL; char *path = NULL;
char *fstype = ""; char *fstype = "";
char *device = ""; char *device = "";
off_t device_size = 0;
int fd; int fd;
void *buf; void *buf;
...@@ -901,13 +902,9 @@ int main (int argc, char **argv) ...@@ -901,13 +902,9 @@ int main (int argc, char **argv)
if (fd < 0) if (fd < 0)
err(2, "failed to open \"%s\"", path); err(2, "failed to open \"%s\"", path);
st.st_size = get_device_size(fd, &st); device_size = get_device_size(fd, &st);
st.st_size = device_size;
fstype = "device"; fstype = "device";
device = malloc(32);
if (!device)
err(2, "no mem");
snprintf(device, 32, "%.1f Gb", (double)st.st_size/(1ll<<30));
} else { } else {
errx(2, "unsupported destination: \"%s\"", path); errx(2, "unsupported destination: \"%s\"", path);
} }
...@@ -1008,8 +1005,10 @@ int main (int argc, char **argv) ...@@ -1008,8 +1005,10 @@ int main (int argc, char **argv)
if (!quiet) { if (!quiet) {
print_size(ret_size); print_size(ret_size);
printf(" from %s (%s %s): request=%d time=", printf(" from %s (%s %s", path, fstype, device);
path, fstype, device, request); if (device_size)
print_size(device_size);
printf("): request=%d time=", request);
print_time(this_time); print_time(this_time);
printf("\n"); printf("\n");
} }
...@@ -1079,8 +1078,10 @@ int main (int argc, char **argv) ...@@ -1079,8 +1078,10 @@ int main (int argc, char **argv)
time_min, time_avg, time_min, time_avg,
time_max, time_mdev); time_max, time_mdev);
} else if (!quiet || (!period_time && !period_request)) { } else if (!quiet || (!period_time && !period_request)) {
printf("\n--- %s (%s %s) ioping statistics ---\n", printf("\n--- %s (%s %s", path, fstype, device);
path, fstype, device); if (device_size)
print_size(device_size);
printf(") ioping statistics ---\n");
print_int(request); print_int(request);
printf(" requests completed in "); printf(" requests completed in ");
print_time(time_total); print_time(time_total);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment