34,30 → 34,88 |
* @file |
*/ |
|
#include <stdio.h> |
#include <unistd.h> |
#include <vfs/vfs.h> |
#include <bool.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <task.h> |
#include <malloc.h> |
#include "init.h" |
#include "version.h" |
#include <stdio.h> |
|
static void test_console(void) |
static void console_wait(void) |
{ |
int c; |
while (get_cons_phone() < 0) |
usleep(50000); // FIXME |
} |
|
while ((c = getchar()) != EOF) |
putchar(c); |
static bool mount_fs(const char *fstype) |
{ |
int rc = -1; |
|
while (rc < 0) { |
rc = mount(fstype, "/", "initrd"); |
|
switch (rc) { |
case EOK: |
printf(NAME ": Root filesystem mounted\n"); |
break; |
case EBUSY: |
printf(NAME ": Root filesystem already mounted\n"); |
break; |
case ELIMIT: |
printf(NAME ": Unable to mount root filesystem\n"); |
return false; |
case ENOENT: |
printf(NAME ": Unknown filesystem type (%s)\n", fstype); |
return false; |
default: |
sleep(5); // FIXME |
} |
} |
|
return true; |
} |
|
static void spawn(char *fname) |
{ |
char *argv[2]; |
|
printf(NAME ": Spawning %s\n", fname); |
|
argv[0] = fname; |
argv[1] = NULL; |
|
if (task_spawn(fname, argv) != 0) { |
/* Success */ |
sleep(1); |
} |
} |
|
int main(int argc, char *argv[]) |
{ |
info_print(); |
sleep(5); // FIXME |
|
if (!mount_fs("tmpfs") && !mount_fs("fat")) { |
printf(NAME ": Exiting\n"); |
return -1; |
} |
|
// FIXME: spawn("/sbin/pci"); |
spawn("/sbin/fb"); |
spawn("/sbin/kbd"); |
spawn("/sbin/console"); |
|
console_wait(); |
version_print(); |
|
printf("This is init\n"); |
|
test_console(); |
|
printf("\nBye.\n"); |
|
spawn("/sbin/bdsh"); |
|
return 0; |
} |
|
/** @} |
*/ |
|