]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-mountpoint-util: /root might be mounted
authorFranck Bui <fbui@suse.com>
Thu, 10 Aug 2023 12:13:45 +0000 (14:13 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 11 Aug 2023 08:34:20 +0000 (09:34 +0100)
On openSUSE with BTRFS, /root has to be mounted as dedicated subvolume to avoid
restoring it when a rollback of the system happens.

src/test/test-mountpoint-util.c

index 6b129c2eac8ce06dbcd1e82a660e9df41d3d92fd..ff447c658218bfafad6bb42233cf6f6351952cdd 100644 (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);