summaryrefslogtreecommitdiffstats
path: root/src/stat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stat.h')
-rw-r--r--src/stat.h41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/stat.h b/src/stat.h
index e08dd4d..68a5c13 100644
--- a/src/stat.h
+++ b/src/stat.h
@@ -13,13 +13,34 @@
#define BFS_STAT_H
#include "config.h"
+#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
+#if defined(STATX_BASIC_STATS) && (!__ANDROID__ || __ANDROID_API__ >= 30)
+# define BFS_HAS_LIBC_STATX true
+#elif __linux__
+# include <linux/stat.h>
+#endif
+
+#ifndef BFS_USE_STATX
+# ifdef STATX_BASIC_STATS
+# define BFS_USE_STATX true
+# endif
+#endif
+
#if BFS_USE_SYS_PARAM_H
# include <sys/param.h>
#endif
+#ifdef DEV_BSIZE
+# define BFS_STAT_BLKSIZE DEV_BSIZE
+#elif defined(S_BLKSIZE)
+# define BFS_STAT_BLKSIZE S_BLKSIZE
+#else
+# define BFS_STAT_BLKSIZE 512
+#endif
+
/**
* bfs_stat field bitmask.
*/
@@ -60,14 +81,6 @@ enum bfs_stat_flags {
BFS_STAT_NOSYNC = 1 << 2,
};
-#ifdef DEV_BSIZE
-# define BFS_STAT_BLKSIZE DEV_BSIZE
-#elif defined(S_BLKSIZE)
-# define BFS_STAT_BLKSIZE S_BLKSIZE
-#else
-# define BFS_STAT_BLKSIZE 512
-#endif
-
/**
* Facade over struct stat.
*/
@@ -125,6 +138,18 @@ struct bfs_stat {
int bfs_stat(int at_fd, const char *at_path, enum bfs_stat_flags flags, struct bfs_stat *buf);
/**
+ * Convert struct stat to struct bfs_stat.
+ */
+void bfs_stat_convert(struct bfs_stat *dest, const struct stat *src);
+
+#if BFS_USE_STATX
+/**
+ * Convert struct statx to struct bfs_stat.
+ */
+int bfs_statx_convert(struct bfs_stat *dest, const struct statx *src);
+#endif
+
+/**
* Get a particular time field from a bfs_stat() buffer.
*/
const struct timespec *bfs_stat_time(const struct bfs_stat *buf, enum bfs_stat_field field);