diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/init/main.c | 20 | ||||
-rw-r--r-- | src/kernel/proc.c | 3 | ||||
-rw-r--r-- | src/kernel/vfs/mount.c | 15 | ||||
-rw-r--r-- | src/kernel/vfs/mount.h | 3 |
4 files changed, 35 insertions, 6 deletions
diff --git a/src/init/main.c b/src/init/main.c index b0e31ae..c08cf21 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -18,17 +18,27 @@ const char *multipageify(const char *str) { #define mount(fd, path) _syscall_fd_mount(fd, path, sizeof(path)-1) int main(void) { - mount(0, "/"); + int fd; + mount(0, "/some/where"); mount(0, "/some"); - _syscall_fs_open( + _syscall_fs_open( // should fail multipageify("/some/where/file"), sizeof("/some/where/file") - 1); - _syscall_fd_write(FD_STDOUT, "fd test ", 8); - _syscall_fd_close(FD_STDOUT); - _syscall_fd_write(FD_STDOUT, "fd test ", 8); // should fail + fd = _syscall_fs_open( + multipageify("/tty"), + sizeof("/tty") - 1); + + if (fd < 0) { + _syscall_exit("couldn't open tty", + sizeof("couldn't open tty") - 1); + } + + _syscall_fd_write(fd, "fd test ", 8); + _syscall_fd_close(fd); + _syscall_fd_write(fd, "fd test ", 8); // should fail _syscall_exit("bye from init! ", sizeof("bye from init! ") - 1); diff --git a/src/kernel/proc.c b/src/kernel/proc.c index c7963f0..022de79 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -3,6 +3,7 @@ #include <kernel/panic.h> #include <kernel/proc.h> #include <kernel/util.h> +#include <kernel/vfs/mount.h> #include <shared/magic.h> #include <stdint.h> @@ -17,7 +18,7 @@ struct process *process_seed(void) { proc->sibling = NULL; proc->child = NULL; proc->parent = NULL; - proc->mount = NULL; + proc->mount = vfs_mount_seed(); proc->id = next_pid++; process_first = proc; diff --git a/src/kernel/vfs/mount.c b/src/kernel/vfs/mount.c new file mode 100644 index 0000000..be33b6b --- /dev/null +++ b/src/kernel/vfs/mount.c @@ -0,0 +1,15 @@ +#include <kernel/mem.h> +#include <kernel/vfs/mount.h> + +struct vfs_mount *vfs_mount_seed(void) { + struct vfs_mount *mount = kmalloc(sizeof(struct vfs_mount)); + *mount = (struct vfs_mount){ + .prev = NULL, + .prefix = "/tty", + .prefix_len = 4, + .fd = { + .type = FD_SPECIAL_TTY, + }, + }; + return mount; +} diff --git a/src/kernel/vfs/mount.h b/src/kernel/vfs/mount.h index 3e9d8ae..982f951 100644 --- a/src/kernel/vfs/mount.h +++ b/src/kernel/vfs/mount.h @@ -7,3 +7,6 @@ struct vfs_mount { size_t prefix_len; struct fd fd; }; + +// prepares init's filesystem view +struct vfs_mount *vfs_mount_seed(void); |