diff options
Diffstat (limited to 'io/statx_generic.c')
-rw-r--r-- | io/statx_generic.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/io/statx_generic.c b/io/statx_generic.c index df327f8c52..6416bc8251 100644 --- a/io/statx_generic.c +++ b/io/statx_generic.c @@ -1,5 +1,5 @@ /* Generic implementation of statx based on fstatat64. - Copyright (C) 2018 Free Software Foundation, Inc. + Copyright (C) 2018-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,13 +14,20 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ #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; } |