Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4054 → Rev 4055

/branches/dd/uspace/app/init/init.c
27,37 → 27,93
*/
 
/** @addtogroup init Init
* @brief Init process for testing purposes.
* @brief Init process for user space environment configuration.
* @{
*/
*/
/**
* @file
*/
 
#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"
#include <stdio.h>
 
static void test_console(void)
static bool mount_fs(const char *fstype)
{
int c;
int rc = -1;
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;
}
}
return true;
}
 
while ((c = getchar()) != EOF)
putchar(c);
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();
if (!mount_fs(STRING(RDFMT))) {
printf(NAME ": Exiting\n");
return -1;
}
// FIXME: spawn("/srv/pci");
spawn("/srv/fb");
spawn("/srv/kbd");
spawn("/srv/console");
spawn("/srv/fhc");
spawn("/srv/obio");
console_wait();
version_print();
 
printf("This is init\n");
test_console();
 
printf("\nBye.\n");
 
spawn("/app/klog");
spawn("/app/bdsh");
return 0;
}
 
/** @}
*/