Print the filesystem creation time in show-super

This commit is contained in:
Tim Schlueter 2018-11-04 21:02:51 -08:00
parent 03c79a9a25
commit 25dac4021f

View File

@ -568,15 +568,26 @@ void bch2_sb_print(struct bch_sb *sb, bool print_layout,
char user_uuid_str[40], internal_uuid_str[40]; char user_uuid_str[40], internal_uuid_str[40];
char fields_have_str[200]; char fields_have_str[200];
char label[BCH_SB_LABEL_SIZE + 1]; char label[BCH_SB_LABEL_SIZE + 1];
char time_str[64];
struct bch_sb_field *f; struct bch_sb_field *f;
u64 fields_have = 0; u64 fields_have = 0;
unsigned nr_devices = 0; unsigned nr_devices = 0;
time_t time_base = le64_to_cpu(sb->time_base_lo) / NSEC_PER_SEC;
memset(label, 0, sizeof(label)); memset(label, 0, sizeof(label));
memcpy(label, sb->label, sizeof(sb->label)); memcpy(label, sb->label, sizeof(sb->label));
uuid_unparse(sb->user_uuid.b, user_uuid_str); uuid_unparse(sb->user_uuid.b, user_uuid_str);
uuid_unparse(sb->uuid.b, internal_uuid_str); uuid_unparse(sb->uuid.b, internal_uuid_str);
if (time_base) {
struct tm *tm = localtime(&time_base);
size_t err = strftime(time_str, sizeof(time_str), "%c", tm);
if (!err)
strcpy(time_str, "(formatting error)");
} else {
strcpy(time_str, "(not set)");
}
mi = bch2_sb_get_members(sb); mi = bch2_sb_get_members(sb);
if (mi) { if (mi) {
struct bch_member *m; struct bch_member *m;
@ -596,6 +607,7 @@ void bch2_sb_print(struct bch_sb *sb, bool print_layout,
"Internal UUID: %s\n" "Internal UUID: %s\n"
"Label: %s\n" "Label: %s\n"
"Version: %llu\n" "Version: %llu\n"
"Created: %s\n"
"Block_size: %s\n" "Block_size: %s\n"
"Btree node size: %s\n" "Btree node size: %s\n"
"Error action: %s\n" "Error action: %s\n"
@ -624,6 +636,7 @@ void bch2_sb_print(struct bch_sb *sb, bool print_layout,
internal_uuid_str, internal_uuid_str,
label, label,
le64_to_cpu(sb->version), le64_to_cpu(sb->version),
time_str,
pr_units(le16_to_cpu(sb->block_size), units), pr_units(le16_to_cpu(sb->block_size), units),
pr_units(BCH_SB_BTREE_NODE_SIZE(sb), units), pr_units(BCH_SB_BTREE_NODE_SIZE(sb), units),