xattr-util: use crtime/btime if statx() is available for implementation of fd_setcrtime() and friends

The Linux kernel exposes the birth time now for files through statx()
hence make use of it where available. We keep the xattr logic in place
for this however, since only a subset of file systems on Linux currently
expose the birth time. NFS and tmpfs for example do not support it. OTOH
there are other file systems that do support the birth time but might
not support xattrs (smb…), hence make the best of the two, in particular
in order to deal with journal files copied between file system types and
to maintain compatibility with older file systems that are updated to
newer version of the file system.
This commit is contained in:
Lennart Poettering
2018-02-20 15:41:49 +01:00
parent 1133dea477
commit 4c2e1b399f
6 changed files with 161 additions and 45 deletions
+23
View File
@@ -383,3 +383,26 @@ static inline int bpf(int cmd, union bpf_attr *attr, size_t size) {
# endif
# endif
#endif
#if !HAVE_STATX
# ifndef __NR_statx
# if defined __i386__
# define __NR_bpf 383
# elif defined __x86_64__
# define __NR_bpf 332
# else
# warning "__NR_statx not defined for your architecture"
# endif
# endif
struct statx;
static inline ssize_t statx(int dfd, const char *filename, unsigned flags, unsigned int mask, struct statx *buffer) {
# ifdef __NR_statx
return syscall(__NR_statx, dfd, filename, flags, mask, buffer);
# else
errno = ENOSYS;
return -1;
# endif
}
#endif