]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: check for linux/mount.h
authorMarkus Mayer <mmayer@broadcom.com>
Tue, 1 Aug 2023 19:59:26 +0000 (12:59 -0700)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Aug 2023 09:27:43 +0000 (11:27 +0200)
commit396798d6b08ba762958aabd3edb84b5c76c2b8a5
tree723fb9b472084d6f0e9e04e76c3fccae41f1e95c
parent03435a7c65538f02e249ff099c3c55ca4d791301
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>
configure.ac
include/mount-api-utils.h
libmount/src/hook_idmap.c
libmount/src/hooks.c
libmount/src/version.c