mirror of git://git.suckless.org/ubase
mount: don't call realpath on root target
Musl libc realpath implementation calls readlink on a procfs path it computes via __procfdname (code at [1] & [2]). This is problematic if ubase mount is used in a PID 1 because procfs is not mounted and the kernel passes the rootfs mounted read-only, so the first step is to read-write remount the rootfs, which can't be done because procfs is not mounted. Thus we are in a dependency cycle: procfs can't be mounted because the root is read-only and so on. To break this cycle, don't call readlink on "/" (it doesn't really make sense anyway) so the rootfs can be remounted read-write, after which proc itself can be mounted and the rest of mount calls will succeed so systems running ubase + musl can succesfully boot into userspace. [1] https://git.musl-libc.org/cgit/musl/tree/src/misc/realpath.c?h=v1.1.19 [2] https://git.musl-libc.org/cgit/musl/tree/src/internal/procfdname.c?h=v1.1.19 Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
This commit is contained in:
parent
11d2d1faaf
commit
4f5837147a
8
mount.c
8
mount.c
|
@ -242,9 +242,11 @@ main(int argc, char *argv[])
|
|||
if (!target) {
|
||||
target = argv[0];
|
||||
source = NULL;
|
||||
if (!(resolvpath = realpath(target, NULL)))
|
||||
eprintf("realpath %s:", target);
|
||||
target = resolvpath;
|
||||
if (strcmp(target, "/") != 0) {
|
||||
if (!(resolvpath = realpath(target, NULL)))
|
||||
eprintf("realpath %s:", target);
|
||||
target = resolvpath;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; files[i]; i++) {
|
||||
|
|
Loading…
Reference in New Issue