summaryrefslogtreecommitdiff
path: root/lib/e2p
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2009-03-05 19:40:20 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-03-06 01:59:23 -0500
commitb7c5b4030870b31d73019d9d9ec55d550772590b (patch)
tree0d970292f57dd4779b1241bdd8b7b4ee9ac9706c /lib/e2p
parentb2ca48f40eb33bd86b8d53d4373e7fce96bced4a (diff)
downloade2fsprogs-b7c5b4030870b31d73019d9d9ec55d550772590b.tar.gz
Add support for a new superblock field: s_kbytes_written
This field tracks the lifetime amount of writes to the filesystem. It will be updated by the kernel as well as by e2fsprogs programs which write to the filesystem. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/e2p')
-rw-r--r--lib/e2p/ls.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c
index 6d2ce70a..eb9a7721 100644
--- a/lib/e2p/ls.c
+++ b/lib/e2p/ls.c
@@ -267,6 +267,24 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
next = sb->s_lastcheck + sb->s_checkinterval;
fprintf(f, "Next check after: %s", ctime(&next));
}
+#define POW2(x) ((__u64) 1 << (x))
+ if (sb->s_kbytes_written) {
+ fprintf(f, "Lifetime writes: ");
+ if (sb->s_kbytes_written < POW2(13))
+ fprintf(f, "%llu kB\n", sb->s_kbytes_written);
+ else if (sb->s_kbytes_written < POW2(23))
+ fprintf(f, "%llu MB\n",
+ (sb->s_kbytes_written + POW2(9)) >> 10);
+ else if (sb->s_kbytes_written < POW2(33))
+ fprintf(f, "%llu GB\n",
+ (sb->s_kbytes_written + POW2(19)) >> 20);
+ else if (sb->s_kbytes_written < POW2(43))
+ fprintf(f, "%llu TB\n",
+ (sb->s_kbytes_written + POW2(29)) >> 30);
+ else
+ fprintf(f, "%llu PB\n",
+ (sb->s_kbytes_written + POW2(39)) >> 40);
+ }
fprintf(f, "Reserved blocks uid: ");
print_user(sb->s_def_resuid, f);
fprintf(f, "Reserved blocks gid: ");