blob: 390b73136abdde82dcaadafee0b2f24369ac1611 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <knob/user.h>
#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(
try_run_command(cmd)
? "Succeded.\n"
: "Failed.\n"
);
tell_user_sz("[init] Yielding.\n");
yield_task();
}
#define STARTUP_FILE_PATH "sys/startup.rc"
void main() {
struct file *f = open_file(STARTUP_FILE_PATH);
if (!f) {
tell_user_sz("Could not open " STARTUP_FILE_PATH ".\n");
return;
}
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;
}
else
++bufp;
}
if (bufp != buf) {
*bufp = '\0';
start(buf);
}
close_file(f);
tell_user_sz("[init] Done starting programs.\n");
}
|