test41: relax maximum timer tick rate
[minix.git] / servers / vbfs / vbfs.c
blobae12ff2b6342dfc6d28654872cfa723323b56622
1 /* This file contains the implementation of the VBFS file system server. */
2 /*
3 * The architecture of VBFS can be sketched as follows:
5 * +-------------+
6 * | VBFS | This file
7 * +-------------+
8 * |
9 * +-------------+
10 * | libsffs | Shared Folder File System library
11 * +-------------+
12 * |
13 * +-------------+
14 * | libvboxfs | VirtualBox File System library
15 * +-------------+
16 * |
17 * +-------------+
18 * | libsys/vbox | VBOX driver interfacing library
19 * +-------------+
20 * -------- | -------- (process boundary)
21 * +-------------+
22 * | VBOX driver | VirtualBox backdoor driver
23 * +-------------+
24 * ======== | ======== (system boundary)
25 * +-------------+
26 * | VirtualBox | The host system
27 * +-------------+
29 * The interfaces between the layers are defined in the following header files:
30 * minix/sffs.h: shared between VBFS, libsffs, and libvboxfs
31 * minix/vboxfs.h: shared between VBFS and libvboxfs
32 * minix/vbox.h: shared between libvboxfs and libsys/vbox
33 * minix/vboxtype.h: shared between libvboxfs, libsys/vbox, and VBOX
34 * minix/vboxif.h: shared between libsys/vbox and VBOX
37 #include <minix/drivers.h>
38 #include <minix/sffs.h>
39 #include <minix/vboxfs.h>
40 #include <minix/optset.h>
42 static char share[PATH_MAX];
43 static struct sffs_params params;
45 static struct optset optset_table[] = {
46 { "share", OPT_STRING, share, sizeof(share) },
47 { "prefix", OPT_STRING, params.p_prefix, sizeof(params.p_prefix) },
48 { "uid", OPT_INT, &params.p_uid, 10 },
49 { "gid", OPT_INT, &params.p_gid, 10 },
50 { "fmask", OPT_INT, &params.p_file_mask, 8 },
51 { "dmask", OPT_INT, &params.p_dir_mask, 8 },
52 { NULL, 0, NULL, 0 }
56 * Initialize this file server. Called at startup time.
58 static int
59 init(int UNUSED(type), sef_init_info_t *UNUSED(info))
61 const struct sffs_table *table;
62 int i, r, roflag;
64 /* Set defaults. */
65 share[0] = 0;
66 params.p_prefix[0] = 0;
67 params.p_uid = 0;
68 params.p_gid = 0;
69 params.p_file_mask = 0755;
70 params.p_dir_mask = 0755;
71 params.p_case_insens = FALSE;
73 /* We must have been given an options string. Parse the options. */
74 for (i = 1; i < env_argc - 1; i++)
75 if (!strcmp(env_argv[i], "-o"))
76 optset_parse(optset_table, env_argv[++i]);
78 /* A share name is required. */
79 if (!share[0]) {
80 printf("VBFS: no shared folder share name specified\n");
82 return EINVAL;
85 /* Initialize the VBOXFS library. If this fails, exit immediately. */
86 r = vboxfs_init(share, &table, &params.p_case_insens, &roflag);
88 if (r != OK) {
89 if (r == ENOENT)
90 printf("VBFS: the given share does not exist\n");
91 else
92 printf("VBFS: unable to initialize VBOXFS (%d)\n", r);
94 return r;
97 /* Now initialize the SFFS library. */
98 if ((r = sffs_init("VBFS", table, &params)) != OK) {
99 vboxfs_cleanup();
101 return r;
104 return OK;
108 * Local SEF initialization.
110 static void
111 sef_local_startup(void)
114 /* Register initialization callback. */
115 sef_setcb_init_fresh(init);
117 /* Register signal callback. SFFS handles this. */
118 sef_setcb_signal_handler(sffs_signal);
120 sef_startup();
124 * The main function of this file server.
127 main(int argc, char **argv)
130 /* Start up. */
131 env_setargs(argc, argv);
132 sef_local_startup();
134 /* Let SFFS do the actual work. */
135 sffs_loop();
137 /* Clean up. */
138 vboxfs_cleanup();
140 return EXIT_SUCCESS;