Add linux-next specific files for 20110831
[linux-2.6/next.git] / tools / kvm / guest / init.c
blob837acfb18c2876a224cc079249145a302147f15e
1 /*
2 * This is a simple init for shared rootfs guests. It brings up critical
3 * mountpoints and then launches /bin/sh.
4 */
5 #include <sys/mount.h>
6 #include <string.h>
7 #include <unistd.h>
8 #include <stdio.h>
9 #include <errno.h>
11 static int run_process(char *filename)
13 char *new_argv[] = { filename, NULL };
14 char *new_env[] = { NULL };
16 return execve(filename, new_argv, new_env);
19 static void do_mounts(void)
21 mount("hostfs", "/host", "9p", MS_RDONLY, "trans=virtio,version=9p2000.L");
22 mount("", "/sys", "sysfs", 0, NULL);
23 mount("proc", "/proc", "proc", 0, NULL);
24 mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
27 int main(int argc, char *argv[])
29 puts("Mounting...");
31 do_mounts();
33 puts("Starting '/bin/sh'...");
35 run_process("/bin/sh");
37 printf("Init failed: %s\n", strerror(errno));
39 return 0;