]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: don't prefix /sysroot/ twice
authorLennart Poettering <lennart@poettering.net>
Mon, 5 Jul 2021 12:48:16 +0000 (14:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Jul 2021 08:10:39 +0000 (10:10 +0200)
For some reason I first commited
a73b2ad041469bf20e3771725dcf70069451e116 and then
8f47e32a3eefa1a366510b5d752875dd56bd7708. But the latter makes the
former obsolete and causes us to suffix paths twice.

Let's hence revert a73b2ad041469bf20e3771725dcf70069451e116 and stick to
8f47e32a3eefa1a366510b5d752875dd56bd7708 as the latter is the ore
generic solution of the two.

src/partition/repart.c

index 589acaa49d775db0c4e8b28aa95425a0400a709f..a53d0fbe8e479cc836a2f555b0d1b916703210a9 100644 (file)
@@ -4529,49 +4529,14 @@ static int acquire_root_devno(
         if (r < 0)
                 return log_debug_errno(r, "Failed to determine canonical path for '%s': %m", p);
 
-        /* Only if we still lock at the same block device we can reuse the fd. Otherwise return an
+        /* Only if we still look at the same block device we can reuse the fd. Otherwise return an
          * invalidated fd. */
         *ret_fd = fd_devno != MODE_INVALID && fd_devno == devno ? TAKE_FD(fd) : -1;
         return 0;
 }
 
-static int find_os_prefix(const char **ret) {
-        int r;
-
-        assert(ret);
-
-        /* Searches for the right place to look for the OS root. This is relevant in the initrd: in the
-         * initrd the host OS is typically mounted to /sysroot/ — except in setups where /usr/ is a separate
-         * partition, in which case it is mounted to /sysusr/usr/ before being moved to /sysroot/usr/. */
-
-        if (!in_initrd()) {
-                *ret = NULL; /* no prefix */
-                return 0;
-        }
-
-        r = path_is_mount_point("/sysroot", NULL, 0);
-        if (r < 0 && r != -ENOENT)
-                log_debug_errno(r, "Failed to determine whether /sysroot/ is a mount point, assuming it is not: %m");
-        else if (r > 0) {
-                log_debug("/sysroot/ is a mount point, assuming it's the prefix.");
-                *ret = "/sysroot";
-                return 0;
-        }
-
-        r = path_is_mount_point("/sysusr/usr", NULL, 0);
-        if (r < 0 && r != -ENOENT)
-                log_debug_errno(r, "Failed to determine whether /sysusr/usr is a mount point, assuming it is not: %m");
-        else if (r > 0) {
-                log_debug("/sysusr/usr/ is a mount point, assuming /sysusr/ is the prefix.");
-                *ret = "/sysusr";
-                return 0;
-        }
-
-        return -ENOENT;
-}
-
 static int find_root(char **ret, int *ret_fd) {
-        const char *t, *prefix;
+        const char *p;
         int r;
 
         assert(ret);
@@ -4612,22 +4577,7 @@ static int find_root(char **ret, int *ret_fd) {
          * latter we check for cases where / is a tmpfs and only /usr is an actual persistent block device
          * (think: volatile setups) */
 
-        r = find_os_prefix(&prefix);
-        if (r < 0)
-                return log_error_errno(r, "Failed to determine OS prefix: %m");
-
-        FOREACH_STRING(t, "/", "/usr") {
-                _cleanup_free_ char *j = NULL;
-                const char *p;
-
-                if (prefix) {
-                        j = path_join(prefix, t);
-                        if (!j)
-                                return log_oom();
-
-                        p = j;
-                } else
-                        p = t;
+        FOREACH_STRING(p, "/", "/usr") {
 
                 r = acquire_root_devno(p, arg_root, O_RDONLY|O_DIRECTORY|O_CLOEXEC, ret, ret_fd);
                 if (r < 0) {