mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
repart: don't prefix /sysroot/ twice
For some reason I first commiteda73b2ad041
and then8f47e32a3e
. But the latter makes the former obsolete and causes us to suffix paths twice. Let's hence reverta73b2ad041
and stick to8f47e32a3e
as the latter is the ore generic solution of the two.
This commit is contained in:
parent
105a4245ff
commit
6bbae9f8b3
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user