summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Vovk <adrianvovk@gmail.com>2024-01-04 18:48:39 +0100
committerAdrian Vovk <adrianvovk@gmail.com>2024-01-04 18:49:14 +0100
commitd3c2288c9f5dfdf8ef9752f93d298d0b56bbedc0 (patch)
tree60cd27f4af894ded77fdc63630e74b331e72f0b1
parenttmpfiles: add --purge switch (diff)
downloadsystemd-d3c2288c9f5dfdf8ef9752f93d298d0b56bbedc0.tar.xz
systemd-d3c2288c9f5dfdf8ef9752f93d298d0b56bbedc0.zip
stat-util: Add statx version of timespec_load
statx_timestamp is, for all intents and purposes, the same as a struct timespec. So, we can trivially convert it and call timespec_load on it. This commit adds helper functions that do just that.
-rw-r--r--src/basic/stat-util.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/basic/stat-util.h b/src/basic/stat-util.h
index cb736c36dd..dc11a85f62 100644
--- a/src/basic/stat-util.h
+++ b/src/basic/stat-util.h
@@ -12,6 +12,7 @@
#include "macro.h"
#include "missing_stat.h"
#include "siphash24.h"
+#include "time-util.h"
int is_symlink(const char *path);
int is_dir_full(int atfd, const char *fname, bool follow);
@@ -109,6 +110,13 @@ int xstatfsat(int dir_fd, const char *path, struct statfs *ret);
} var
#endif
+static inline usec_t statx_timestamp_load(const struct statx_timestamp *ts) {
+ return timespec_load(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
+}
+static inline nsec_t statx_timestamp_load_nsec(const struct statx_timestamp *ts) {
+ return timespec_load_nsec(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
+}
+
void inode_hash_func(const struct stat *q, struct siphash *state);
int inode_compare_func(const struct stat *a, const struct stat *b);
extern const struct hash_ops inode_hash_ops;