From 863b70d198f62f28581162473a521208dd67879e Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 6 Mar 2021 13:40:24 -0500 Subject: Implement -flags, from FreeBSD find This is the last BSD-specific primary I'm aware of. Fixes #14. --- stat.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'stat.c') diff --git a/stat.c b/stat.c index 7fb6b50..d1132ad 100644 --- a/stat.c +++ b/stat.c @@ -24,6 +24,10 @@ #include #include +#if BFS_HAS_SYS_PARAM +# include +#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; -- cgit v1.2.3