1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-12 08:58:20 +03:00

test-mountpoint-util: /root might be mounted

On openSUSE with BTRFS, /root has to be mounted as dedicated subvolume to avoid
restoring it when a rollback of the system happens.

(cherry picked from commit 487ae08b85048f86e72e86d6c601d4c558b6cb8a)
This commit is contained in:
Franck Bui 2023-08-10 14:13:45 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 470be7a153
commit 5c3fa0cfee

View File

@ -276,6 +276,7 @@ TEST(path_is_mount_point) {
}
TEST(fd_is_mount_point) {
_cleanup_(rm_rf_physical_and_freep) char *tmpdir = NULL;
_cleanup_close_ int fd = -EBADF;
int r;
@ -298,11 +299,13 @@ TEST(fd_is_mount_point) {
assert_se(fd_is_mount_point(fd, "proc", 0) > 0);
assert_se(fd_is_mount_point(fd, "proc/", 0) > 0);
/* /root's entire reason for being is to be on the root file system (i.e. not in /home/ which
* might be split off), so that the user can always log in, so it cannot be a mount point unless
* the system is borked. Let's allow for it to be missing though. */
assert_se(IN_SET(fd_is_mount_point(fd, "root", 0), -ENOENT, 0));
assert_se(IN_SET(fd_is_mount_point(fd, "root/", 0), -ENOENT, 0));
safe_close(fd);
fd = open("/tmp", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
assert_se(fd >= 0);
assert_se(mkdtemp_malloc("/tmp/not-mounted-XXXXXX", &tmpdir) >= 0);
assert_se(fd_is_mount_point(fd, basename(tmpdir), 0) == 0);
assert_se(fd_is_mount_point(fd, strjoina(basename(tmpdir), "/"), 0) == 0);
safe_close(fd);
fd = open("/proc", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);