Skip to content
Merged

Fixes #177

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion kernel/kernel/initrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int>({entry->mode, strlen(entry->mode)})
return parser::parse_number_from_string<unsigned int>({entry->mode, strlen_space(entry->mode)})
.unwrap();
}

Expand Down
26 changes: 3 additions & 23 deletions usystem/core/bootstrap-init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand Down
Loading