diff options
author | Florian Weimer <fweimer@redhat.com> | 2019-06-12 12:04:09 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2019-06-12 13:04:43 +0200 |
commit | 5dad6ffbb2b76215cfcd38c3001778536ada8e8a (patch) | |
tree | 3e4e55117be3039d516c14243beddb9041469d5b /io/statx_generic.c | |
parent | 4e75c2a43bb3208f32556a2b19c939cfe1f54ba6 (diff) | |
download | glibc-5dad6ffbb2b76215cfcd38c3001778536ada8e8a.tar.gz glibc-5dad6ffbb2b76215cfcd38c3001778536ada8e8a.tar.xz glibc-5dad6ffbb2b76215cfcd38c3001778536ada8e8a.zip |
<sys/stat.h>: Use Linux UAPI header for statx if available and useful
This will automatically import new STATX_* constants. It also avoids a conflict between <sys/stat.h> and <linux/stat.h>.
Diffstat (limited to 'io/statx_generic.c')
-rw-r--r-- | io/statx_generic.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/io/statx_generic.c b/io/statx_generic.c index 10225ef5cb..ddc4097249 100644 --- a/io/statx_generic.c +++ b/io/statx_generic.c @@ -18,9 +18,16 @@ #include <errno.h> #include <fcntl.h> +#include <string.h> #include <sys/stat.h> #include <sys/sysmacros.h> +/* Obtain the original definition of struct statx. */ +#undef __statx_defined +#define statx original_statx +#include <bits/types/struct_statx.h> +#undef statx + static inline struct statx_timestamp statx_convert_timestamp (struct timespec tv) { @@ -57,7 +64,7 @@ statx_generic (int fd, const char *path, int flags, /* The interface is defined in such a way that unused (padding) fields have to be cleared. STATX_BASIC_STATS corresponds to the data which is available via fstatat64. */ - *buf = (struct statx) + struct original_statx obuf = { .stx_mask = STATX_BASIC_STATS, .stx_blksize = st.st_blksize, @@ -76,6 +83,8 @@ statx_generic (int fd, const char *path, int flags, .stx_dev_major = major (st.st_dev), .stx_dev_minor = minor (st.st_dev), }; + _Static_assert (sizeof (*buf) >= sizeof (obuf), "struct statx size"); + memcpy (buf, &obuf, sizeof (obuf)); return 0; } |