aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
authorMarkus Mayer <mmayer@broadcom.com>2023-08-01 12:59:27 -0700
committerKarel Zak <kzak@redhat.com>2023-08-03 12:04:12 +0200
commit1fc3471dfb8b3dc53af47115d0579cc6188f51d8 (patch)
tree8f4fbaef627dbdc7a395886f2d2a6fbf99adb33c /libmount/src
parent5502e73d8f82af92975b7dec2d9641dc79170670 (diff)
downloadutil-linux-1fc3471dfb8b3dc53af47115d0579cc6188f51d8.tar.gz
libmount: check for struct statx
Let's ensure struct statx exists before we try to use it. Checking for the existence of linux/stat.h is not sufficient. This is because [uapi/]linux/stat.h has existed since Linux 3.7, however struct statx was only introduced with Linux 4.11. The problem arises if one happens ot be using kernel headers from within the aforementioned range, such as Linux 4.9. CC libmount/src/la-utils.lo In file included from libmount/src/utils.c:31: ./include/fileutils.h:100:33: warning: declaration of 'struct statx' will not be visible outside of this function [-Wvisibility] unsigned int mask, struct statx *stx) ^ libmount/src/utils.c:117:16: error: variable has incomplete type 'struct statx' struct statx stx = { 0 }; ^ libmount/src/utils.c:117:10: note: forward declaration of 'struct statx' struct statx stx = { 0 }; ^ libmount/src/utils.c:125:5: error: use of undeclared identifier 'STATX_TYPE' STATX_TYPE ^ libmount/src/utils.c:126:8: error: use of undeclared identifier 'STATX_MODE' | STATX_MODE ^ libmount/src/utils.c:127:8: error: use of undeclared identifier 'STATX_INO' | STATX_INO, ^ 1 warning and 4 errors generated. make[4]: *** [Makefile:11269: libmount/src/la-utils.lo] Error 1 Checking for the presence of struct statx explicitly avoids this problem. Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/utils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 410ded4aa2..1d3f4abcec 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -111,7 +111,7 @@ static int safe_stat(const char *target, struct stat *st, int nofollow)
memset(st, 0, sizeof(struct stat));
-#ifdef AT_STATX_DONT_SYNC
+#if defined(AT_STATX_DONT_SYNC) && defined (HAVE_STRUCT_STATX)
{
int rc;
struct statx stx = { 0 };