From 5dad6ffbb2b76215cfcd38c3001778536ada8e8a Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 12 Jun 2019 12:04:09 +0200 Subject: : Use Linux UAPI header for statx if available and useful This will automatically import new STATX_* constants. It also avoids a conflict between and . --- io/statx_generic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'io/statx_generic.c') 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 #include +#include #include #include +/* Obtain the original definition of struct statx. */ +#undef __statx_defined +#define statx original_statx +#include +#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; } -- cgit v1.2.1