27,7 → 27,7 |
*/ |
|
/** @addtogroup init Init |
* @brief Init process for user space environment configuration. |
* @brief Init process for testing purposes. |
* @{ |
*/ |
/** |
34,86 → 34,30 |
* @file |
*/ |
|
#include "version.h" |
#include <stdio.h> |
#include <unistd.h> |
#include <ipc/ipc.h> |
#include <vfs/vfs.h> |
#include <bool.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <task.h> |
#include <malloc.h> |
#include <macros.h> |
#include "init.h" |
#include "version.h" |
|
static bool mount_fs(const char *fstype) |
static void test_console(void) |
{ |
int rc = -1; |
int c; |
|
while (rc < 0) { |
rc = mount(fstype, "/", "initrd", IPC_FLAG_BLOCKING); |
|
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; |
while ((c = getchar()) != EOF) |
putchar(c); |
} |
} |
|
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)) |
/* Add reasonable delay to avoid |
intermixed klog output */ |
usleep(10000); |
else |
printf(NAME ": Error spawning %s\n", fname); |
} |
|
int main(int argc, char *argv[]) |
{ |
info_print(); |
version_print(); |
|
if (!mount_fs(STRING(RDFMT))) { |
printf(NAME ": Exiting\n"); |
return -1; |
} |
printf("This is init\n"); |
|
// FIXME: spawn("/srv/pci"); |
spawn("/srv/fb"); |
spawn("/srv/kbd"); |
spawn("/srv/console"); |
spawn("/srv/fhc"); |
spawn("/srv/obio"); |
test_console(); |
|
console_wait(); |
version_print(); |
printf("\nBye.\n"); |
|
spawn("/app/klog"); |
spawn("/app/bdsh"); |
|
return 0; |
} |
|
/** @} |
*/ |
|