1 /* $NetBSD: h_mdserv.c,v 1.4 2011/02/10 13:29:02 pooka Exp $ */
17 #include <rump/rump.h>
18 #include <rump/rump_syscalls.h>
20 #define MDSIZE (1024*1024)
22 #define REQUIRE(a, msg) if ((a) != 0) err(1, msg);
31 fd = rump_sys_open(arg, O_RDONLY);
33 n = rump_sys_read(fd, buf, sizeof(buf));
54 error = rump_daemonize_done(error);
55 REQUIRE(error, "rump_daemonize_done");
64 main(int argc, char *argv[])
73 md.md_addr = calloc(1, MDSIZE);
75 md.md_type = MD_UMEM_SERVER;
77 error = rump_daemonize_begin();
78 REQUIRE(error, "rump_daemonize_begin");
81 REQUIRE(error, "rump_init");
83 error = rump_init_server("unix://commsock");
84 REQUIRE(error, "init server");
86 if ((fd = rump_sys_open(argv[1], O_RDWR)) == -1)
90 * Now, configuring the md driver also causes our process
91 * to start acting as the worker for the md. Splitting it
92 * into two steps in the driver is not easy, since md is
93 * supposed to be unconfigured when the process dies
94 * (process may exit between calling ioctl1 and ioctl2).
95 * So, start a probe thread which attempts to read the md
96 * and declares the md as configured when the read is
99 error = pthread_create(&pt, NULL, prober, argv[1]);
100 REQUIRE(error, "pthread_create");
103 if (rump_sys_ioctl(fd, MD_SETCONF, &md) == -1) {
104 rump_daemonize_done(errno);