From 9e8bf3a3119d2c845322a60c0652a53bbb29d129 Mon Sep 17 00:00:00 2001 From: Pedro Falcato Date: Mon, 13 Apr 2026 23:12:28 +0100 Subject: [PATCH 1/2] bootstrap-init: drop fmount ideas they were just bad. Signed-off-by: Pedro Falcato --- usystem/core/bootstrap-init/main.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/usystem/core/bootstrap-init/main.c b/usystem/core/bootstrap-init/main.c index 3942e0086..09eff69cb 100644 --- a/usystem/core/bootstrap-init/main.c +++ b/usystem/core/bootstrap-init/main.c @@ -41,13 +41,6 @@ int insmod(const char *path, const char *name) return syscall(SYS_insmod, path, name); } -int fmount(int fd, char *path) -{ - if (syscall(SYS_fmount, fd, path)) - return -1; - return 0; -} - #define MODULE_PREFIX "/usr/lib/modules/" #define MODULE_EXT ".ko" @@ -212,15 +205,6 @@ int main(int argc, char **argv) if (option_verbose) fprintf(stderr, "bootstrap-init: Mounting root filesystem %s...\n", root_blockdev); - int devfd = open("/dev", O_RDONLY | O_CLOEXEC); - int sysfsfd = open("/sys", O_RDONLY | O_CLOEXEC); - - if (devfd < 0 || sysfsfd < 0) - { - perror("Failed opening old mounts"); - return 1; - } - st = mount_autodetect(root_blockdev, "/"); free((void *) root_blockdev); @@ -233,14 +217,10 @@ int main(int argc, char **argv) } if (option_verbose) - fprintf(stderr, "bootstrap-init: root mounted, remounting dev and sysfs\n"); + fprintf(stderr, "bootstrap-init: root mounted, remounting dev\n"); - if (fmount(devfd, "/dev") < 0 || fmount(sysfsfd, "/sys") < 0) - { - perror("fmount"); - fprintf(stderr, "bootstrap-init: Mounting devfs and sysfs failed\n"); - return 1; - } + if (mount("none", "/dev", "devfs", 0, NULL) < 0) + return 2; if (option_verbose) fprintf(stderr, "bootstrap-init: root mounting done, exec'ing the new init\n"); From 2bad87f51829e848759e7939b3e5ade12606d62b Mon Sep 17 00:00:00 2001 From: Pedro Falcato Date: Mon, 13 Apr 2026 23:12:55 +0100 Subject: [PATCH 2/2] initrd: count spaces as the end of the value It turns out some tars (bsdtar!) can pad the value with spaces instead of null terminators. Signed-off-by: Pedro Falcato --- kernel/kernel/initrd.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/kernel/initrd.cpp b/kernel/kernel/initrd.cpp index d079ff6f9..964db3345 100644 --- a/kernel/kernel/initrd.cpp +++ b/kernel/kernel/initrd.cpp @@ -34,9 +34,19 @@ bool is_tar(void *initrd) return !memcmp(header->magic, "ustar ", 5); } +size_t strlen_space(const char *buf) +{ + const char *s = buf; + size_t len = 0; + + while (*s && *s != ' ') + s++, len++; + return len; +} + unsigned int parse_perms_from_tar(tar_header_t *entry) { - return parser::parse_number_from_string({entry->mode, strlen(entry->mode)}) + return parser::parse_number_from_string({entry->mode, strlen_space(entry->mode)}) .unwrap(); }