summaryrefslogtreecommitdiff
path: root/src/user/app/init
diff options
context:
space:
mode:
authordzwdz2022-07-26 20:40:29 +0200
committerdzwdz2022-07-26 20:44:29 +0200
commit599c916d4cdd06765e0869b0a4d685820384f500 (patch)
tree7355c35189a4b6e92249f59c76e6d89d5b432f29 /src/user/app/init
parent350124fb4cfefc90c8f4a60de3da3c5d7da44f01 (diff)
user: posix-compatible FILE* opening
Diffstat (limited to 'src/user/app/init')
-rw-r--r--src/user/app/init/main.c10
-rw-r--r--src/user/app/init/shell.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/src/user/app/init/main.c b/src/user/app/init/main.c
index a898844..71220af 100644
--- a/src/user/app/init/main.c
+++ b/src/user/app/init/main.c
@@ -15,7 +15,7 @@ __attribute__((section(".text.startup")))
int main(void) {
elf_selfreloc();
- file_reopen(stdout, "/kdev/com1", 0);
+ freopen("/kdev/com1", "a+", stdout);
printf("in init (stage 2), loaded at 0x%x\n", &_image_base);
MOUNT("/tmp/", tmpfs_drv());
@@ -42,11 +42,11 @@ int main(void) {
}
if (!fork()) {
- if (!file_reopen(stdout, "/kdev/com1", 0)) {
+ if (!freopen("/kdev/com1", "a+", stdout)) {
printf("couldn't open /kdev/com1\n"); // TODO borked
_syscall_exit(1);
}
- if (!file_reopen(stdin, "/kdev/com1", 0)) {
+ if (!freopen("/kdev/com1", "r", stdin)) {
printf("couldn't open /kdev/com1\n");
_syscall_exit(1);
}
@@ -57,11 +57,11 @@ int main(void) {
}
if (!fork()) {
- if (!file_reopen(stdout, "/vga_tty", 0)) {
+ if (!freopen("/vga_tty", "a+", stdout)) {
printf("couldn't open /vga_tty\n"); // TODO borked
_syscall_exit(1);
}
- if (!file_reopen(stdin, "/keyboard", 0)) {
+ if (!freopen("/keyboard", "r", stdin)) {
printf("couldn't open /keyboard\n");
_syscall_exit(1);
}
diff --git a/src/user/app/init/shell.c b/src/user/app/init/shell.c
index 0c8b9b4..795bb5e 100644
--- a/src/user/app/init/shell.c
+++ b/src/user/app/init/shell.c
@@ -45,7 +45,7 @@ static int readline(char *buf, size_t max) {
}
static void cmd_cat_ls(const char *args, bool ls) {
- libc_file *file;
+ FILE *file;
static char buf[512];
int len; // first used for strlen(args), then length of buffer
@@ -60,9 +60,9 @@ static void cmd_cat_ls(const char *args, bool ls) {
}
}
- file = file_open(buf, 0);
+ file = fopen(buf, "r");
} else if (ls) { /* ls default argument */
- file = file_open("/", 0);
+ file = fopen("/", "r");
} else { /* cat default argument */
file = file_clone(stdin);
}
@@ -153,7 +153,7 @@ void shell_loop(void) {
}
if (!fork()) {
- if (redir && !file_reopen(stdout, redir, OPEN_CREATE)) {
+ if (redir && !freopen(redir, "w", stdout)) {
// TODO stderr
_syscall_exit(0);
}
@@ -161,7 +161,7 @@ void shell_loop(void) {
if (!strcmp(cmd, "echo")) {
printf("%s\n", args);
} else if (!strcmp(cmd, "exec")) {
- libc_file *file = file_open(args, 0);
+ FILE *file = fopen(args, "r");
if (!file) {
printf("couldn't open file\n");
} else {