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
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
, ¶ms
.p_uid
, 10 },
22 { "gid", OPT_INT
, ¶ms
.p_gid
, 10 },
23 { "fmask", OPT_INT
, ¶ms
.p_file_mask
, 8 },
24 { "dmask", OPT_INT
, ¶ms
.p_dir_mask
, 8 },
25 { "icase", OPT_BOOL
, ¶ms
.p_case_insens
, TRUE
},
26 { "noicase", OPT_BOOL
, ¶ms
.p_case_insens
, FALSE
},
30 /*===========================================================================*
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
;
41 params
.p_prefix
[0] = 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
) {
56 printf("HGFS: shared folders are disabled\n");
58 printf("HGFS: unable to initialize HGFS library (%d)\n", r
);
63 /* Now initialize the SFFS library. */
64 if ((r
= sffs_init("HGFS", table
, ¶ms
)) != OK
) {
73 /*===========================================================================*
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
);
90 /*===========================================================================*
92 *===========================================================================*/
93 int main(int argc
, char **argv
)
95 /* The main function of this file server.
98 env_setargs(argc
, argv
);