summaryrefslogtreecommitdiffstats
path: root/stat.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-12-25 18:08:43 -0500
committerTavian Barnes <tavianator@tavianator.com>2018-12-25 18:13:15 -0500
commit36cb1762dd647a6c9cbb0ab36993c83798c854f1 (patch)
tree4bc2fc1cca1400774855e0b2618b967bb9466947 /stat.c
parentb2e69d3f76270fc4051801cac923307514184055 (diff)
downloadbfs-36cb1762dd647a6c9cbb0ab36993c83798c854f1.tar.xz
stat: Provide a helper for getting human-readable field names
And fix -newerXY if the Y time doesn't exist.
Diffstat (limited to 'stat.c')
-rw-r--r--stat.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/stat.c b/stat.c
index c567873..e78e206 100644
--- a/stat.c
+++ b/stat.c
@@ -42,6 +42,42 @@
# define st_birthtim st_birthtimespec
#endif
+const char *bfs_stat_field_name(enum bfs_stat_field field) {
+ switch (field) {
+ case BFS_STAT_DEV:
+ return "device number";
+ case BFS_STAT_INO:
+ return "inode nunmber";
+ case BFS_STAT_TYPE:
+ return "type";
+ case BFS_STAT_MODE:
+ return "mode";
+ case BFS_STAT_NLINK:
+ return "link count";
+ case BFS_STAT_GID:
+ return "group ID";
+ case BFS_STAT_UID:
+ return "user ID";
+ case BFS_STAT_SIZE:
+ return "size";
+ case BFS_STAT_BLOCKS:
+ return "block count";
+ case BFS_STAT_RDEV:
+ return "underlying device";
+ case BFS_STAT_ATIME:
+ return "access time";
+ case BFS_STAT_BTIME:
+ return "birth time";
+ case BFS_STAT_CTIME:
+ return "change time";
+ case BFS_STAT_MTIME:
+ return "modification time";
+ }
+
+ assert(false);
+ return "???";
+}
+
/**
* Check if we should retry a failed stat() due to a potentially broken link.
*/