Revert old init

This commit is contained in:
Mark 2020-03-12 15:42:49 +02:00
parent 27fe2c9415
commit 63b64ba0ce

55
init.c
View File

@ -16,56 +16,15 @@ static int start_login(void) {
return execve(login, (char *const *) argp, NULL);
}
static void t0(void) {
//uint32_t *r = mmap(NULL, 0x1000, 0, 0, -1, 0);
//r[0] = 0x1234;
//usleep(10000);
}
static void t1(void) {
//uint32_t *r = mmap(NULL, 0x1000, 0, 0, -1, 0);
//usleep(1000000);
//printf("%04x\n", r[0]);
}
int main(int argc, char **argv) {
(void) start_login;
int c0, c1, status;
printf("Start thread 1\n");
c0 = fork();
if (c0 == 0) {
t0();
return 0;
if (getpid() != 1) {
printf("Won't work if PID is not 1\n");
return -1;
}
printf("Start thread 2\n");
c1 = fork();
mount(NULL, "/dev", "devfs", 0, NULL);
mount(NULL, "/sys", "sysfs", 0, NULL);
mount("/dev/sda1", "/mnt", NULL, 0, NULL);
if (c1 == 0) {
t1();
return 0;
}
waitpid(c1, &status);
waitpid(c0, &status);
printf("Children dead\n");
while (1) {
usleep(1000000);
}
return 0;
//if (getpid() != 1) {
// printf("Won't work if PID is not 1\n");
// return -1;
//}
//mount(NULL, "/dev", "devfs", 0, NULL);
//mount(NULL, "/sys", "sysfs", 0, NULL);
//mount("/dev/sda1", "/mnt", NULL, 0, NULL);
//return start_login();
return start_login();
}