Remove building with NOCRYPTO option
[minix3.git] / tests / fs / ffs / h_ffs_server.c
blobdd22d9faf1d8f10ae3db4fc4e43038b11dfa0424
1 /* $NetBSD: h_ffs_server.c,v 1.2 2012/08/24 20:25:50 jmmv Exp $ */
3 /*
4 * rump server for advanced quota tests
5 */
7 #include "../common/h_fsmacros.h"
9 #include <err.h>
10 #include <semaphore.h>
11 #include <sys/types.h>
12 #include <sys/mount.h>
14 #include <stdlib.h>
15 #include <unistd.h>
17 #include <ufs/ufs/ufsmount.h>
19 #include <rump/rump.h>
20 #include <rump/rump_syscalls.h>
22 int background = 0;
24 static void
25 usage(void)
27 fprintf(stderr, "usage: %s [-b] [-l] diskimage bindurl\n",
28 getprogname());
29 exit(1);
32 static void
33 die(const char *reason, int error)
36 warnx("%s: %s", reason, strerror(error));
37 if (background)
38 rump_daemonize_done(error);
39 exit(1);
42 static sem_t sigsem;
43 static void
44 sigreboot(int sig)
47 sem_post(&sigsem);
50 int
51 main(int argc, char **argv)
53 int error;
54 struct ufs_args uargs;
55 const char *filename;
56 const char *serverurl;
57 int log = 0;
58 int ch;
60 while ((ch = getopt(argc, argv, "bl")) != -1) {
61 switch(ch) {
62 case 'b':
63 background = 1;
64 break;
65 case 'l':
66 log = 1;
67 break;
68 default:
69 usage();
72 argc -= optind;
73 argv += optind;
75 if (argc != 2)
76 usage();
78 filename = argv[0];
79 serverurl = argv[1];
81 if (background) {
82 error = rump_daemonize_begin();
83 if (error)
84 errx(1, "rump daemonize: %s", strerror(error));
87 error = rump_init();
88 if (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);
100 if (error)
101 die("rump server init failed", error);
102 if (background)
103 rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS);
105 sem_init(&sigsem, 0, 0);
106 signal(SIGTERM, sigreboot);
107 signal(SIGINT, sigreboot);
108 sem_wait(&sigsem);
110 rump_sys_reboot(0, NULL);
111 /*NOTREACHED*/
112 return 0;