1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

<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>.
This commit is contained in:
Florian Weimer
2019-06-12 12:04:09 +02:00
parent 4e75c2a43b
commit 5dad6ffbb2
11 changed files with 219 additions and 71 deletions

View File

@ -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;
}