Lennart Poettering
81995fbb96
mountpoint-util: add new helper name_to_handle_at_try_fid()
...
Newer kernels support a new flag for name_to_handle_at(): AT_HANDLE_FID.
This flag is supposed to return an identifier for an inode that we can
use for checking inode identity. It's supposed to be a replacement for
checking .st_ino which doesn't work anymore today because inode numbers
are no longer unique on file systems (not on overlayfs, and not on btrfs
for example). Hence, be a good citizen and add infrastructure to support
AT_HANDLE_FID. Unfortunately that doesn't work for old kernels, hence
add a fallback logic: if we can use the flag, use it. If we cannot use
name_to_handle_at() without it, which might give us a good ID too. But
of course tha tcan fail as well, which callers have to check.
2024-07-01 15:45:15 +02:00
Lennart Poettering
8da6413860
mountpoint-util: add public helper for comparing file handles
...
We already have the code, let's move it to a function of its own and
export it.
2024-07-01 15:45:15 +02:00
Lennart Poettering
a89690f719
mountpoint-util: make is_name_to_handle_at_fatal_error() an exported API
...
And while we are at it, make it use ERRNO_IS_xyz() where appropriate.
And move it up a bit, so we can use in the whole of mountpoint-util.c
(which we want to later).
2024-07-01 15:45:15 +02:00
Zbigniew Jędrzejewski-Szmek
bfd5a0687f
various: move const ptr indicator to return value
2024-06-19 16:28:28 +02:00
Mike Yuan
88873231c8
mountpoint-util: add missing assertions, make mount_fd static
2024-05-22 00:48:51 +08:00
Daan De Meyer
e3828d7103
mountpoint-util: Deal with kernel API breakage in "norecovery" mount option
...
"norecovery" was deprecated for btrfs in
74ef00185e
and removed in
a1912f7121 .
Let's drop our assumption that btrfs supports "norecovery" and first query for the
new name of the option followed by querying for the old name.
2024-05-17 14:29:09 +02:00
Luca Boccassi
d50f58d641
Merge pull request #31210 from poettering/chdir-hardening
...
WorkingDirectory= hardening
2024-02-06 12:41:43 +00:00
Lennart Poettering
0fb08bd5e3
mountpoint-util: add small helper that checks if a path is below the API VFS hierarchies
2024-02-06 11:13:28 +01:00
Mike Yuan
b409aacb0a
mountpoint-util: introduce path_is_mount_point_full
2024-02-06 15:09:28 +08:00
Luca Boccassi
f273c09c51
mountpoint-util: add bool mount_new_api_supported() helper
2023-10-02 14:02:32 +01:00
Yu Watanabe
68a4fc8b53
fd-util: do not call statx() twice when it does not provide mount ID
...
Previously, in path_is_root_at(), if statx() does not provide mount ID,
path_get_mnt_id_at() was called, but it also calls statx(). Let's avoid
the second trial.
2023-07-22 02:22:06 +09:00
Daan De Meyer
9bf8441503
mountpoint-util: Add path_get_mnt_id_at()
2023-03-15 11:51:06 +01:00
Lennart Poettering
6eda6f7e51
mountpoint-util: add new fstype_can_umask() helper
2023-03-09 21:56:42 +01:00
Lennart Poettering
034ebc47a2
mountpoint-util: move 'norecovery' detection into its own helper call
...
And let's also ask the kernel explicitly for support.
2023-03-09 21:56:42 +01:00
Lennart Poettering
117e703447
mountpoint-util: generalize mount_option_supported()
2023-03-09 21:56:42 +01:00
Lennart Poettering
7d3b157b77
mountpoint-util: add helper that checks if MS_NOSYMFOLLOW is supported
2023-03-09 16:14:29 +01:00
Yu Watanabe
edac5c4636
mountpoint-util: introduce mount_propagation_flag_is_valid()
2022-12-15 14:15:59 +09:00
Yu Watanabe
b205e59ad4
mountpoint-util: rename mount_propagation_flags_to_string() and friends as singular
2022-12-15 14:15:55 +09:00
Zbigniew Jędrzejewski-Szmek
61ef30515b
shared: add new safe_fork flag FORK_PRIVATE_TMP
...
If the flag is set, we mount /tmp/ in a way that is suitable for generators and
other quick jobs.
Unfortunately I had to move some code from shared/mount-util.c to
basic/mountpoint-util.c. The functions that are moved are very thin wrappers
around mount(2), so this doesn't actually change much in the code split between
libbasic and libshared.
Implications for the host would be weird if a private mount namespace is not
used, so assert on FORK_NEW_MOUNTNS when the flag is used.
2022-12-14 22:12:44 +01:00
Thomas Blume
d72f4a3897
basic/mountpoint-util: skip dependency on quota services for some filesystems
2022-10-14 20:57:30 +02:00
Zbigniew Jędrzejewski-Szmek
9c6535367d
basic,shared: move make_mount_point_inode_*() to shared/
...
Those pull in selinux for labelling, and we should avoid selinux in basic/.
2021-06-23 10:34:58 +02:00
Luca Boccassi
8bab802910
basic: add make_mount_point_inode helper
...
Creates a file or a directory depending on the source path, useful
for creating mount points.
2020-12-21 21:48:13 +01:00
Yu Watanabe
db9ecf0501
license: LGPL-2.1+ -> LGPL-2.1-or-later
2020-11-09 13:23:58 +09:00
YmrDtnJu
ac2474e4ff
basic: New function fstype_is_blockdev_backed for fstypes that need a blockdev
...
The function returns true if the specified filesystem requires a block device.
2020-06-08 19:36:42 +02:00
Zbigniew Jędrzejewski-Szmek
049af8ad0c
Split out part of mount-util.c into mountpoint-util.c
...
The idea is that anything which is related to actually manipulating mounts is
in mount-util.c, but functions for mountpoint introspection are moved to the
new file. Anything which requires libmount must be in mount-util.c.
This was supposed to be a preparation for further changes, with no functional
difference, but it results in a significant change in linkage:
$ ldd build/libnss_*.so.2
(before)
build/libnss_myhostname.so.2:
linux-vdso.so.1 (0x00007fff77bf5000)
librt.so.1 => /lib64/librt.so.1 (0x00007f4bbb7b2000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007f4bbb755000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4bbb734000)
libc.so.6 => /lib64/libc.so.6 (0x00007f4bbb56e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4bbb8c1000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f4bbb51b000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f4bbb512000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4bbb4e3000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f4bbb45e000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f4bbb458000)
build/libnss_mymachines.so.2:
linux-vdso.so.1 (0x00007ffc19cc0000)
librt.so.1 => /lib64/librt.so.1 (0x00007fdecb74b000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fdecb744000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007fdecb6e7000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdecb6c6000)
libc.so.6 => /lib64/libc.so.6 (0x00007fdecb500000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdecb8a9000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fdecb4ad000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fdecb4a2000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fdecb475000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fdecb3f0000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fdecb3ea000)
build/libnss_resolve.so.2:
linux-vdso.so.1 (0x00007ffe8ef8e000)
librt.so.1 => /lib64/librt.so.1 (0x00007fcf314bd000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fcf314b6000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007fcf31459000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcf31438000)
libc.so.6 => /lib64/libc.so.6 (0x00007fcf31272000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcf31615000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fcf3121f000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fcf31214000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fcf311e7000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fcf31162000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fcf3115c000)
build/libnss_systemd.so.2:
linux-vdso.so.1 (0x00007ffda6d17000)
librt.so.1 => /lib64/librt.so.1 (0x00007f610b83c000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007f610b835000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007f610b7d8000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f610b7b7000)
libc.so.6 => /lib64/libc.so.6 (0x00007f610b5f1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f610b995000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f610b59e000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f610b593000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f610b566000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f610b4e1000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f610b4db000)
(after)
build/libnss_myhostname.so.2:
linux-vdso.so.1 (0x00007fff0b5e2000)
librt.so.1 => /lib64/librt.so.1 (0x00007fde0c328000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fde0c307000)
libc.so.6 => /lib64/libc.so.6 (0x00007fde0c141000)
/lib64/ld-linux-x86-64.so.2 (0x00007fde0c435000)
build/libnss_mymachines.so.2:
linux-vdso.so.1 (0x00007ffdc30a7000)
librt.so.1 => /lib64/librt.so.1 (0x00007f06ecabb000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007f06ecab4000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f06eca93000)
libc.so.6 => /lib64/libc.so.6 (0x00007f06ec8cd000)
/lib64/ld-linux-x86-64.so.2 (0x00007f06ecc15000)
build/libnss_resolve.so.2:
linux-vdso.so.1 (0x00007ffe95747000)
librt.so.1 => /lib64/librt.so.1 (0x00007fa56a80f000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fa56a808000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa56a7e7000)
libc.so.6 => /lib64/libc.so.6 (0x00007fa56a621000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa56a964000)
build/libnss_systemd.so.2:
linux-vdso.so.1 (0x00007ffe67b51000)
librt.so.1 => /lib64/librt.so.1 (0x00007ffb32113000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007ffb3210c000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffb320eb000)
libc.so.6 => /lib64/libc.so.6 (0x00007ffb31f25000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffb3226a000)
I don't quite understand what is going on here, but let's not be too picky.
2018-11-29 21:03:44 +01:00