summaryrefslogtreecommitdiffstats
path: root/stat.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2021-03-06 13:40:24 -0500
committerTavian Barnes <tavianator@tavianator.com>2021-03-06 13:40:24 -0500
commit863b70d198f62f28581162473a521208dd67879e (patch)
tree9506283742eef1951ecaa897f4584b3941499a51 /stat.c
parent8f201b2380aef3a566316343e7e71c6fc995cf41 (diff)
downloadbfs-863b70d198f62f28581162473a521208dd67879e.tar.xz
Implement -flags, from FreeBSD find
This is the last BSD-specific primary I'm aware of. Fixes #14.
Diffstat (limited to 'stat.c')
-rw-r--r--stat.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/stat.c b/stat.c
index 7fb6b50..d1132ad 100644
--- a/stat.c
+++ b/stat.c
@@ -24,6 +24,10 @@
#include <sys/types.h>
#include <sys/stat.h>
+#if BFS_HAS_SYS_PARAM
+# include <sys/param.h>
+#endif
+
#ifdef STATX_BASIC_STATS
# define HAVE_STATX true
#elif __linux__
@@ -65,6 +69,8 @@ const char *bfs_stat_field_name(enum bfs_stat_field field) {
return "block count";
case BFS_STAT_RDEV:
return "underlying device";
+ case BFS_STAT_ATTRS:
+ return "attributes";
case BFS_STAT_ATIME:
return "access time";
case BFS_STAT_BTIME:
@@ -121,6 +127,11 @@ static void bfs_stat_convert(const struct stat *statbuf, struct bfs_stat *buf) {
buf->rdev = statbuf->st_rdev;
buf->mask |= BFS_STAT_RDEV;
+#if BSD
+ buf->attrs = statbuf->st_flags;
+ buf->mask |= BFS_STAT_ATTRS;
+#endif
+
buf->atime = statbuf->st_atim;
buf->mask |= BFS_STAT_ATIME;
@@ -244,6 +255,9 @@ static int bfs_statx_impl(int at_fd, const char *at_path, int at_flags, enum bfs
buf->rdev = bfs_makedev(xbuf.stx_rdev_major, xbuf.stx_rdev_minor);
buf->mask |= BFS_STAT_RDEV;
+ buf->attrs = xbuf.stx_attributes;
+ buf->mask |= BFS_STAT_ATTRS;
+
if (xbuf.stx_mask & STATX_ATIME) {
buf->atime.tv_sec = xbuf.stx_atime.tv_sec;
buf->atime.tv_nsec = xbuf.stx_atime.tv_nsec;