summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kernel/syscalls.c1
-rw-r--r--src/user/app/init/init.c5
-rw-r--r--src/user/app/shell/shell.c12
-rw-r--r--src/user/app/tmpfs/tmpfs.c (renamed from src/user/app/init/driver/tmpfs.c)5
4 files changed, 16 insertions, 7 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index 07e2e36..5dca49f 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -287,6 +287,7 @@ long _syscall_close(handle_t hid) {
long _syscall_fs_wait(char __user *buf, long max_len, struct fs_wait_response __user *res) {
struct vfs_backend *backend = process_current->controlled;
+ // TODO can be used to tell if you're init
if (!backend) SYSCALL_RETURN(-1);
process_transition(process_current, PS_WAITS4REQUEST);
diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c
index 9e7ab7b..f011ca5 100644
--- a/src/user/app/init/init.c
+++ b/src/user/app/init/init.c
@@ -29,9 +29,12 @@ int main(void) {
freopen("/kdev/com1", "a+", stderr);
printf("in init (stage 2), main at 0x%x\n", &main);
- MOUNT_AT("/tmp/") { tmpfs_drv(); }
MOUNT_AT("/keyboard") { ps2_drv(); }
MOUNT_AT("/bin/") { fs_passthru("/init/bin"); }
+ MOUNT_AT("/tmp/") {
+ const char *argv[] = {"/bin/tmpfs", NULL};
+ execv(argv[0], (void*)argv);
+ }
MOUNT_AT("/vtty") {
const char *argv[] = {"/bin/vterm", NULL};
execv(argv[0], (void*)argv);
diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c
index 6083578..d96ef4c 100644
--- a/src/user/app/shell/shell.c
+++ b/src/user/app/shell/shell.c
@@ -37,9 +37,15 @@ void run_args(int argc, char **argv, struct redir *redir) {
if (!*argv) return;
/* "special" commands that can't be handled in a subprocess */
- if (!strcmp(argv[0], "shadow")) {
- // TODO process groups
- _syscall_mount(-1, argv[1], strlen(argv[1]));
+ if (!strcmp(argv[0], "mount")) {
+ if (argc < 3) {
+ eprintf("not enough arguments");
+ return;
+ }
+ MOUNT_AT(argv[1]) {
+ run_args(argc - 2, argv + 2, redir);
+ exit(1);
+ }
return;
} else if (!strcmp(argv[0], "time")) {
uint64_t time = __rdtsc();
diff --git a/src/user/app/init/driver/tmpfs.c b/src/user/app/tmpfs/tmpfs.c
index c7abf50..88a9fac 100644
--- a/src/user/app/init/driver/tmpfs.c
+++ b/src/user/app/tmpfs/tmpfs.c
@@ -54,7 +54,7 @@ static struct node *tmpfs_open(const char *path, struct fs_wait_response *res) {
return node;
}
-void tmpfs_drv(void) {
+int main(void) {
const size_t buflen = 4096;
char *buf = malloc(buflen);
struct fs_wait_response res;
@@ -127,6 +127,5 @@ void tmpfs_drv(void) {
break;
}
}
-
- exit(1);
+ return 1;
}