Rev 4398 | Rev 4537 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4398 | Rev 4420 | ||
|---|---|---|---|
| Line 43... | Line 43... | ||
| 43 | #include <fcntl.h> |
43 | #include <fcntl.h> |
| 44 | #include <task.h> |
44 | #include <task.h> |
| 45 | #include <malloc.h> |
45 | #include <malloc.h> |
| 46 | #include <macros.h> |
46 | #include <macros.h> |
| 47 | #include <console.h> |
47 | #include <console.h> |
| - | 48 | #include <string.h> |
|
| 48 | #include "init.h" |
49 | #include "init.h" |
| 49 | #include "version.h" |
50 | #include "version.h" |
| 50 | 51 | ||
| 51 | static bool mount_fs(const char *fstype) |
52 | static bool mount_fs(const char *fstype) |
| 52 | { |
53 | { |
| 53 | int rc = -1; |
54 | int rc = -1; |
| - | 55 | char *opts = ""; |
|
| 54 | 56 | ||
| - | 57 | if (str_cmp(fstype, "tmpfs") == 0) |
|
| - | 58 | opts = "restore"; |
|
| - | 59 | ||
| 55 | while (rc < 0) { |
60 | while (rc < 0) { |
| 56 | rc = mount(fstype, "/", "initrd", IPC_FLAG_BLOCKING); |
61 | rc = mount(fstype, "/", "initrd", opts, IPC_FLAG_BLOCKING); |
| 57 | 62 | ||
| 58 | switch (rc) { |
63 | switch (rc) { |
| 59 | case EOK: |
64 | case EOK: |
| 60 | printf(NAME ": Root filesystem mounted\n"); |
65 | printf(NAME ": Root filesystem mounted\n"); |
| 61 | break; |
66 | break; |
| Line 72... | Line 77... | ||
| 72 | } |
77 | } |
| 73 | 78 | ||
| 74 | return true; |
79 | return true; |
| 75 | } |
80 | } |
| 76 | 81 | ||
| - | 82 | static bool mount_devfs(void) |
|
| - | 83 | { |
|
| - | 84 | int rc = -1; |
|
| - | 85 | ||
| - | 86 | while (rc < 0) { |
|
| - | 87 | rc = mount("devfs", "/dev", "null", "", IPC_FLAG_BLOCKING); |
|
| - | 88 | ||
| - | 89 | switch (rc) { |
|
| - | 90 | case EOK: |
|
| - | 91 | printf(NAME ": Device filesystem mounted\n"); |
|
| - | 92 | break; |
|
| - | 93 | case EBUSY: |
|
| - | 94 | printf(NAME ": Device filesystem already mounted\n"); |
|
| - | 95 | break; |
|
| - | 96 | case ELIMIT: |
|
| - | 97 | printf(NAME ": Unable to mount device filesystem\n"); |
|
| - | 98 | return false; |
|
| - | 99 | case ENOENT: |
|
| - | 100 | printf(NAME ": Unknown filesystem type (devfs)\n"); |
|
| - | 101 | return false; |
|
| - | 102 | } |
|
| - | 103 | } |
|
| - | 104 | ||
| - | 105 | return true; |
|
| - | 106 | } |
|
| - | 107 | ||
| 77 | static void spawn(char *fname) |
108 | static void spawn(char *fname) |
| 78 | { |
109 | { |
| 79 | char *argv[2]; |
110 | char *argv[2]; |
| 80 | 111 | ||
| 81 | printf(NAME ": Spawning %s\n", fname); |
112 | printf(NAME ": Spawning %s\n", fname); |
| 82 | 113 | ||
| 83 | argv[0] = fname; |
114 | argv[0] = fname; |
| 84 | argv[1] = NULL; |
115 | argv[1] = NULL; |
| 85 | 116 | ||
| 86 | if (task_spawn(fname, argv)) { |
117 | if (!task_spawn(fname, argv)) |
| 87 | /* Add reasonable delay to avoid intermixed klog output. */ |
- | |
| 88 | usleep(10000); |
- | |
| 89 | } else { |
- | |
| 90 | printf(NAME ": Error spawning %s\n", fname); |
118 | printf(NAME ": Error spawning %s\n", fname); |
| 91 | } |
- | |
| 92 | } |
119 | } |
| 93 | 120 | ||
| 94 | int main(int argc, char *argv[]) |
121 | int main(int argc, char *argv[]) |
| 95 | { |
122 | { |
| 96 | info_print(); |
123 | info_print(); |
| Line 98... | Line 125... | ||
| 98 | if (!mount_fs(STRING(RDFMT))) { |
125 | if (!mount_fs(STRING(RDFMT))) { |
| 99 | printf(NAME ": Exiting\n"); |
126 | printf(NAME ": Exiting\n"); |
| 100 | return -1; |
127 | return -1; |
| 101 | } |
128 | } |
| 102 | 129 | ||
| - | 130 | spawn("/srv/devfs"); |
|
| - | 131 | ||
| - | 132 | if (!mount_devfs()) { |
|
| - | 133 | return(NAME ": Exiting\n"); |
|
| - | 134 | return -2; |
|
| - | 135 | } |
|
| - | 136 | ||
| 103 | spawn("/srv/fb"); |
137 | spawn("/srv/fb"); |
| 104 | spawn("/srv/kbd"); |
138 | spawn("/srv/kbd"); |
| 105 | spawn("/srv/console"); |
139 | spawn("/srv/console"); |
| 106 | spawn("/srv/fhc"); |
140 | spawn("/srv/fhc"); |
| 107 | spawn("/srv/obio"); |
141 | spawn("/srv/obio"); |