From: Matthew Dillon Date: Fri, 1 Aug 2014 00:14:20 +0000 (-0700) Subject: hammer2 - hammer2 stat adjustments X-Git-Tag: v4.1.0~351 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/8b903fd1eacef97441cec7995222faf0ec46d265 hammer2 - hammer2 stat adjustments * Report inodes as a count rather than as 'bytes'. --- diff --git a/sbin/hammer2/cmd_stat.c b/sbin/hammer2/cmd_stat.c index 455e37962e..ab42f12f35 100644 --- a/sbin/hammer2/cmd_stat.c +++ b/sbin/hammer2/cmd_stat.c @@ -75,13 +75,13 @@ cmd_stat(int ac, const char **av) printf("%-*.*s ", w, w, av[i]); printf("%3d ", ino.ip_data.ncopies); printf("%9s ", sizetostr(ino.ip_data.data_count)); - printf("%9s ", sizetostr(ino.ip_data.inode_count)); + printf("%9s ", counttostr(ino.ip_data.inode_count)); printf("%p ", ino.kdata); printf("comp=%s ", compmodestr(ino.ip_data.comp_algo)); if (ino.ip_data.data_quota || ino.ip_data.inode_quota) { printf(" quota "); printf("%12s", sizetostr(ino.ip_data.data_quota)); - printf("/%-12s", sizetostr(ino.ip_data.inode_quota)); + printf("/%-12s", counttostr(ino.ip_data.inode_quota)); } printf("\n"); } diff --git a/sbin/hammer2/hammer2.h b/sbin/hammer2/hammer2.h index ebdef0a2ed..524438bc44 100644 --- a/sbin/hammer2/hammer2.h +++ b/sbin/hammer2/hammer2.h @@ -150,6 +150,7 @@ const char *hammer2_uuid_to_str(uuid_t *uuid, char **strp); const char *hammer2_iptype_to_str(uint8_t type); const char *hammer2_pfstype_to_str(uint8_t type); const char *sizetostr(hammer2_off_t size); +const char *counttostr(hammer2_off_t size); hammer2_key_t dirhash(const unsigned char *name, size_t len); uint32_t hammer2_icrc32(const void *buf, size_t size); diff --git a/sbin/hammer2/subs.c b/sbin/hammer2/subs.c index 431e3cac43..2713f41f57 100644 --- a/sbin/hammer2/subs.c +++ b/sbin/hammer2/subs.c @@ -243,6 +243,30 @@ sizetostr(hammer2_off_t size) return(buf); } +const char * +counttostr(hammer2_off_t size) +{ + static char buf[32]; + + if (size < 1024 / 2) { + snprintf(buf, sizeof(buf), "%jd", + (intmax_t)size); + } else if (size < 1024 * 1024 / 2) { + snprintf(buf, sizeof(buf), "%jd", + (intmax_t)size); + } else if (size < 1024 * 1024 * 1024LL / 2) { + snprintf(buf, sizeof(buf), "%6.2fM", + (double)size / (1024 * 1024)); + } else if (size < 1024 * 1024 * 1024LL * 1024LL / 2) { + snprintf(buf, sizeof(buf), "%6.2fG", + (double)(size / (1024 * 1024 * 1024LL))); + } else { + snprintf(buf, sizeof(buf), "%6.2fT", + (double)(size / (1024 * 1024 * 1024LL * 1024LL))); + } + return(buf); +} + #if 0 /* * Allocation wrappers give us shims for possible future use