diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-31 23:43:47 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-05 13:12:08 -0500 |
commit | 59154f2c66ce5625bc00f3e66af7b71608e991f4 (patch) | |
tree | 3bbac65d44157543373f4fc17aef0c670671e6b4 /fs/bcachefs/util.c | |
parent | bf61dcdfc12c3890c7a062cfcd46c443883defc9 (diff) | |
download | linux-stable-59154f2c66ce5625bc00f3e66af7b71608e991f4.tar.gz linux-stable-59154f2c66ce5625bc00f3e66af7b71608e991f4.tar.bz2 linux-stable-59154f2c66ce5625bc00f3e66af7b71608e991f4.zip |
bcachefs: bch2_prt_datetime()
Improved, better named version of pr_time().
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/util.c')
-rw-r--r-- | fs/bcachefs/util.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 08bac0ba8d0b..84b142fcc3df 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -467,6 +467,24 @@ static void bch2_pr_time_units_aligned(struct printbuf *out, u64 ns) prt_printf(out, "%s", u->name); } +#ifndef __KERNEL__ +#include <time.h> +void bch2_prt_datetime(struct printbuf *out, time64_t sec) +{ + time_t t = sec; + char buf[64]; + ctime_r(&t, buf); + prt_str(out, buf); +} +#else +void bch2_prt_datetime(struct printbuf *out, time64_t sec) +{ + char buf[64]; + snprintf(buf, sizeof(buf), "%ptT", &sec); + prt_u64(out, sec); +} +#endif + #define TABSTOP_SIZE 12 static inline void pr_name_and_units(struct printbuf *out, const char *name, u64 ns) |