summaryrefslogtreecommitdiff
path: root/src/user/init/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/init/init.c')
-rw-r--r--src/user/init/init.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/src/user/init/init.c b/src/user/init/init.c
index e878603..fb231e0 100644
--- a/src/user/init/init.c
+++ b/src/user/init/init.c
@@ -2,19 +2,6 @@
#include <knob/file.h>
#include <knob/task.h>
-void start(const char *cmd) {
- tell_user_sz("[init] Starting ");
- tell_user_sz(cmd);
- tell_user_sz(": ");
- tell_user_sz(
- run_command(cmd)
- ? "Succeded.\n"
- : "Failed.\n"
- );
- tell_user_sz("[init] Yielding.\n");
- yield_task();
-}
-
#define STARTUP_FILE_PATH "sys/startup.rc"
void main() {
@@ -26,22 +13,17 @@ void main() {
tell_user_sz("[init] Reading from " STARTUP_FILE_PATH ".\n");
- char buf[1024];
- char *bufp = buf;
- while (read_from_file(f, 1, bufp)) {
- if (*bufp == '\n') {
- if (bufp == buf)
- continue;
- *bufp = '\0';
- start(buf);
- bufp = buf;
+ char cmdbuf[128];
+ while (read_line_from_file(f, cmdbuf, 127)) {
+ tell_user_sz("[init] Starting ");
+ tell_user_sz(cmdbuf);
+ tell_user_sz(": ");
+ if (run_command(cmdbuf)) {
+ tell_user_sz("Succeded.\n");
+ yield_task();
}
else
- ++bufp;
- }
- if (bufp != buf) {
- *bufp = '\0';
- start(buf);
+ tell_user_sz("Failed.\n");
}
close_file(f);