]> 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>
Thu, 3 Aug 2023 10:04:12 +0000 (12:04 +0200)
commit5502e73d8f82af92975b7dec2d9641dc79170670
tree79ba559d6eee747a48e2ec039702d2642e455191
parent63c15ba865aed3eca14f64494822f4ab7c2dcf30
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