Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3424 → Rev 3425

/branches/tracing/uspace/app/init/init.c
45,10 → 45,6
#include "init.h"
#include "version.h"
 
#define BUF_SIZE 150000
 
static char *buf;
 
static void console_wait(void)
{
while (get_cons_phone() < 0)
55,13 → 51,13
usleep(50000); // FIXME
}
 
static bool mount_tmpfs(void)
static bool mount_fs(const char *fstype)
{
int rc = -1;
while (rc < 0) {
rc = mount("tmpfs", "/", "initrd");
rc = mount(fstype, "/", "initrd");
 
switch (rc) {
case EOK:
printf(NAME ": Root filesystem mounted\n");
72,6 → 68,9
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
}
82,28 → 81,16
 
static void spawn(char *fname)
{
char *argv[2];
 
printf(NAME ": Spawning %s\n", fname);
int fd = open(fname, O_RDONLY);
if (fd >= 0) {
ssize_t rd;
size_t len = 0;
// FIXME: cannot do long reads yet
do {
rd = read(fd, buf + len, 1024);
if (rd > 0)
len += rd;
} while (rd > 0);
if (len > 0) {
task_spawn(buf, len);
sleep(1); // FIXME
}
close(fd);
 
argv[0] = fname;
argv[1] = NULL;
 
if (task_spawn(fname, argv) != 0) {
/* Success */
sleep(1);
}
}
 
112,27 → 99,21
info_print();
sleep(5); // FIXME
if (!mount_tmpfs()) {
if (!mount_fs("tmpfs") && !mount_fs("fat")) {
printf(NAME ": Exiting\n");
return -1;
}
buf = malloc(BUF_SIZE);
// FIXME: spawn("/srv/pci");
spawn("/srv/fb");
spawn("/srv/kbd");
spawn("/srv/console");
// FIXME: spawn("/sbin/pci");
spawn("/sbin/fb");
spawn("/sbin/kbd");
spawn("/sbin/console");
console_wait();
version_print();
spawn("/sbin/fat");
spawn("/sbin/tetris");
// FIXME: spawn("/sbin/tester");
spawn("/sbin/klog");
spawn("/app/bdsh");
free(buf);
return 0;
}