tools/llvm: Do not build with symbols
[minix3.git] / minix / fs / hgfs / hgfs.c
blob95a9bdaa71c1514fd63f828d720bf43f61450671
1 /* This file contains the implementation of the HGFS file system server.
2 * The file system side is handled by libsffs, whereas the host communication
3 * is handled by libhgfs. This file mainly contains the glue between them.
5 * The entry points into this file are:
6 * main main program function
8 * Created:
9 * April 2009 (D.C. van Moolenbroek)
12 #include <minix/drivers.h>
13 #include <minix/sffs.h>
14 #include <minix/hgfs.h>
15 #include <minix/optset.h>
17 static struct sffs_params params;
19 static struct optset optset_table[] = {
20 { "prefix", OPT_STRING, params.p_prefix, sizeof(params.p_prefix) },
21 { "uid", OPT_INT, &params.p_uid, 10 },
22 { "gid", OPT_INT, &params.p_gid, 10 },
23 { "fmask", OPT_INT, &params.p_file_mask, 8 },
24 { "dmask", OPT_INT, &params.p_dir_mask, 8 },
25 { "icase", OPT_BOOL, &params.p_case_insens, TRUE },
26 { "noicase", OPT_BOOL, &params.p_case_insens, FALSE },
27 { NULL, 0, NULL, 0 }
30 /*===========================================================================*
31 * sef_cb_init_fresh *
32 *===========================================================================*/
33 static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
35 /* Initialize this file server. Called at startup time.
37 const struct sffs_table *table;
38 int i, r;
40 /* Defaults */
41 params.p_prefix[0] = 0;
42 params.p_uid = 0;
43 params.p_gid = 0;
44 params.p_file_mask = 0755;
45 params.p_dir_mask = 0755;
46 params.p_case_insens = FALSE;
48 /* If we have been given an options string, parse options from there. */
49 for (i = 1; i < env_argc - 1; i++)
50 if (!strcmp(env_argv[i], "-o"))
51 optset_parse(optset_table, env_argv[++i]);
53 /* Initialize the HGFS library. If this fails, exit immediately. */
54 if ((r = hgfs_init(&table)) != OK) {
55 if (r == EAGAIN)
56 printf("HGFS: shared folders are disabled\n");
57 else
58 printf("HGFS: unable to initialize HGFS library (%d)\n", r);
60 return r;
63 /* Now initialize the SFFS library. */
64 if ((r = sffs_init("HGFS", table, &params)) != OK) {
65 hgfs_cleanup();
67 return r;
70 return OK;
73 /*===========================================================================*
74 * sef_local_startup *
75 *===========================================================================*/
76 static void sef_local_startup(void)
78 /* Local SEF initialization.
81 /* Register init callback. */
82 sef_setcb_init_fresh(sef_cb_init_fresh);
84 /* Register signal callback. SFFS handles this. */
85 sef_setcb_signal_handler(sffs_signal);
87 sef_startup();
90 /*===========================================================================*
91 * main *
92 *===========================================================================*/
93 int main(int argc, char **argv)
95 /* The main function of this file server.
98 env_setargs(argc, argv);
99 sef_local_startup();
101 sffs_loop();
103 hgfs_cleanup();
105 return 0;