1 /* $NetBSD: h_ffs_server.c,v 1.2 2012/08/24 20:25:50 jmmv Exp $ */
4 * rump server for advanced quota tests
7 #include "../common/h_fsmacros.h"
10 #include <semaphore.h>
11 #include <sys/types.h>
12 #include <sys/mount.h>
17 #include <ufs/ufs/ufsmount.h>
19 #include <rump/rump.h>
20 #include <rump/rump_syscalls.h>
27 fprintf(stderr
, "usage: %s [-b] [-l] diskimage bindurl\n",
33 die(const char *reason
, int error
)
36 warnx("%s: %s", reason
, strerror(error
));
38 rump_daemonize_done(error
);
51 main(int argc
, char **argv
)
54 struct ufs_args uargs
;
56 const char *serverurl
;
60 while ((ch
= getopt(argc
, argv
, "bl")) != -1) {
82 error
= rump_daemonize_begin();
84 errx(1, "rump daemonize: %s", strerror(error
));
89 die("rump init failed", error
);
91 if (rump_sys_mkdir(FSTEST_MNTNAME
, 0777) == -1)
92 die("mount point create", errno
);
93 rump_pub_etfs_register("/diskdev", filename
, RUMP_ETFS_BLK
);
94 uargs
.fspec
= __UNCONST("/diskdev");
95 if (rump_sys_mount(MOUNT_FFS
, FSTEST_MNTNAME
, (log
) ? MNT_LOG
: 0,
96 &uargs
, sizeof(uargs
)) == -1)
97 die("mount ffs", errno
);
99 error
= rump_init_server(serverurl
);
101 die("rump server init failed", error
);
103 rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS
);
105 sem_init(&sigsem
, 0, 0);
106 signal(SIGTERM
, sigreboot
);
107 signal(SIGINT
, sigreboot
);
110 rump_sys_reboot(0, NULL
);