void mainthread(void *cmdline) { int rv, fd; rv = rump_init(); bmk_printf("rump kernel init complete, rv %d\n", rv); writestr(1, "Hello, stdout!\n"); bmk_printf("open(/notexisting): "); fd = rump_sys_open("/notexisting", 0); if (fd == -1) { int errno = *bmk_sched_geterrno(); if (errno == RUMP_ENOENT) { bmk_printf("No such file or directory. All is well.\n"); } else { bmk_printf("Something went wrong. errno = %d\n", errno); } } else { bmk_printf("Success?! fd=%d\n", fd); } rump_sys_reboot(0, NULL); }
die(int e, const char *msg) { if (msg) warnx("%s: %d", msg, e); rump_sys_reboot(0, NULL); exit(e); }
int main() { char buf[8192]; int fd; rump_init(); if (rump_sys_mkdir("/kern", 0755) == -1) die("mkdir /kern"); if (rump_sys_mount("kernfs", "/kern", 0, NULL, 0) == -1) die("mount kernfs"); if ((fd = rump_sys_open("/kern/version", 0)) == -1) die("open /kern/version"); printf("\nReading version info from /kern:\n"); if (rump_sys_read(fd, buf, sizeof(buf)) <= 0) die("read version"); printf("\n%s", buf); rump_sys_reboot(0, NULL); return 0; }
void _netbsd_fini(void) { runfini(); rump_sys_reboot(0, 0); }