diff options
author | David Sterba <dsterba@suse.com> | 2016-10-31 16:00:53 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-11-09 13:47:29 +0100 |
commit | f1d4606a6d81217466716681c120c25ce62f4130 (patch) | |
tree | 635e1b787592d1f928d9c06907db081735770ba6 /print-tree.c | |
parent | 58fe71f3f76cb8d38b84f85ff63966244d2cc14f (diff) |
btrfs-progs: dump-tree: add helper to print timespec
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'print-tree.c')
-rw-r--r-- | print-tree.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/print-tree.c b/print-tree.c index 136ce562..ff68b67f 100644 --- a/print-tree.c +++ b/print-tree.c @@ -908,6 +908,25 @@ static void inode_flags_to_str(u64 flags, char *ret) strcat(ret, "none"); } +static void print_timespec(struct extent_buffer *eb, + struct btrfs_timespec *timespec, const char *prefix, + const char *suffix) +{ + struct tm tm; + u64 tmp_u64; + u32 tmp_u32; + time_t tmp_time; + char timestamp[256]; + + tmp_u64 = btrfs_timespec_sec(eb, timespec); + tmp_u32 = btrfs_timespec_nsec(eb, timespec); + tmp_time = tmp_u64; + localtime_r(&tmp_time, &tm); + strftime(timestamp, sizeof(timestamp), + "%Y-%m-%d %H:%M:%S", &tm); + printf("%s%llu.%u (%s)%s", prefix, (unsigned long long)tmp_u64, tmp_u32, + timestamp, suffix); +} static void print_inode_item(struct extent_buffer *eb, struct btrfs_item *item, struct btrfs_inode_item *ii) { |