Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4580 → Rev 4581

/branches/network/uspace/app/init/init.c
44,25 → 44,31
#include <task.h>
#include <malloc.h>
#include <macros.h>
#include <console.h>
#include <string.h>
#include <devmap.h>
#include "init.h"
#include "version.h"
 
static bool mount_fs(const char *fstype)
static void info_print(void)
{
printf(NAME ": HelenOS init\n");
}
 
static bool mount_root(const char *fstype)
{
int rc = -1;
char *opts = "";
const char *root_dev = "initrd";
if (str_cmp(fstype, "tmpfs") == 0)
opts = "restore";
 
while (rc < 0) {
rc = mount(fstype, "/", "initrd", opts, IPC_FLAG_BLOCKING);
rc = mount(fstype, "/", root_dev, opts, IPC_FLAG_BLOCKING);
switch (rc) {
case EOK:
printf(NAME ": Root filesystem mounted\n");
printf(NAME ": Root filesystem mounted, %s at %s\n",
fstype, root_dev);
break;
case EBUSY:
printf(NAME ": Root filesystem already mounted\n");
79,6 → 85,32
return true;
}
 
static bool mount_devfs(void)
{
int rc = -1;
while (rc < 0) {
rc = mount("devfs", "/dev", "null", "", IPC_FLAG_BLOCKING);
switch (rc) {
case EOK:
printf(NAME ": Device filesystem mounted\n");
break;
case EBUSY:
printf(NAME ": Device filesystem already mounted\n");
break;
case ELIMIT:
printf(NAME ": Unable to mount device filesystem\n");
return false;
case ENOENT:
printf(NAME ": Unknown filesystem type (devfs)\n");
return false;
}
}
return true;
}
 
static void spawn(char *fname)
{
char *argv[2];
92,16 → 124,62
printf(NAME ": Error spawning %s\n", fname);
}
 
static void getvc(char *dev, char *app)
{
char *argv[4];
char vc[MAX_DEVICE_NAME];
int rc;
snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev);
printf(NAME ": Spawning getvc on %s\n", vc);
dev_handle_t handle;
rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
if (rc == EOK) {
argv[0] = "/app/getvc";
argv[1] = vc;
argv[2] = app;
argv[3] = NULL;
if (!task_spawn("/app/getvc", argv))
printf(NAME ": Error spawning getvc on %s\n", vc);
} else {
printf(NAME ": Error waiting on %s\n", vc);
}
}
 
void mount_data(void)
{
int rc;
 
printf("Trying to mount disk0 on /data... ");
fflush(stdout);
 
rc = mount("fat", "/data", "disk0", "wtcache", 0);
if (rc == EOK)
printf("OK\n");
else
printf("Failed\n");
}
 
int main(int argc, char *argv[])
{
info_print();
if (!mount_fs(STRING(RDFMT))) {
if (!mount_root(STRING(RDFMT))) {
printf(NAME ": Exiting\n");
return -1;
}
// FIXME: spawn("/srv/pci");
spawn("/srv/devfs");
if (!mount_devfs()) {
printf(NAME ": Exiting\n");
return -2;
}
spawn("/srv/fb");
spawn("/srv/kbd");
// spawn("/srv/netstart");
108,13 → 186,20
spawn("/srv/console");
spawn("/srv/fhc");
spawn("/srv/obio");
spawn("/srv/ata_bd");
spawn("/srv/gxe_bd");
 
usleep(250000);
mount_data();
 
getvc("vc0", "/app/bdsh");
getvc("vc1", "/app/bdsh");
getvc("vc2", "/app/bdsh");
getvc("vc3", "/app/bdsh");
getvc("vc4", "/app/bdsh");
getvc("vc5", "/app/bdsh");
getvc("vc6", "/app/klog");
console_wait();
version_print();
spawn("/app/klog");
spawn("/app/bdsh");
return 0;
}