aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src/hooks.c
diff options
context:
space:
mode:
authorMarkus Mayer <mmayer@broadcom.com>2023-08-01 12:59:26 -0700
committerKarel Zak <kzak@redhat.com>2023-08-03 12:04:12 +0200
commit5502e73d8f82af92975b7dec2d9641dc79170670 (patch)
tree79ba559d6eee747a48e2ec039702d2642e455191 /libmount/src/hooks.c
parent63c15ba865aed3eca14f64494822f4ab7c2dcf30 (diff)
downloadutil-linux-5502e73d8f82af92975b7dec2d9641dc79170670.tar.gz
libmount: check for linux/mount.h
Check that linux/mount.h is present before using features that rely on it. It is necessary to check for the presence of linux/mount.h explicitly. Simply relying on the presence of several syscalls (e.g. SYS_move_mount, SYS_open_tree) does not work reliably, at least not in a cross-compiling environment. The syscall definitions are provided by the C library. Meanwhile, linux/mount.h is provided by the kernel. This opens the possibility for discrepancies. A problem arises if the C library (e.g. musl-1.2.3) defines all "mount fd API" syscalls (and HAVE_MOUNTFD_API becomes true), but the kernel headers are old enough to not provide linux/mount.h. The resulting error looks as follows. This example is using an LLVM-13 cross-compiler from x86_64 to aarch64 with musl-1.2.3 as the C library. CC libmount/src/la-hooks.lo In file included from libmount/src/hooks.c:30: ./include/mount-api-utils.h:11:10: fatal error: 'linux/mount.h' file not found ^~~~~~~~~~~~~~~ 1 error generated. make[4]: *** [Makefile:11185: libmount/src/la-hooks.lo] Error 1 To prevent this condition, we add a check to configure that will test for the presence of linux/mount.h in addition to testing for the mount fd API. Only if both conditions are met can we actually use the mount fd API. Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Diffstat (limited to 'libmount/src/hooks.c')
-rw-r--r--libmount/src/hooks.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libmount/src/hooks.c b/libmount/src/hooks.c
index 2d79162605..dcfe69fa4d 100644
--- a/libmount/src/hooks.c
+++ b/libmount/src/hooks.c
@@ -46,7 +46,7 @@ static const struct libmnt_hookset *hooksets[] =
&hookset_mount,
#endif
&hookset_mount_legacy,
-#ifdef HAVE_MOUNTFD_API
+#if defined(HAVE_MOUNTFD_API) && defined(HAVE_LINUX_MOUNT_H)
&hookset_idmap,
#endif
&hookset_owner