xref: /minix/minix/fs/isofs/main.c (revision 83133719)
1 /*
2  * This file contains the main function for the server. It waits for a request
3  * and then send a response.
4  */
5 
6 #include "inc.h"
7 #include <minix/optset.h>
8 
9 static struct optset optset_table[] = {
10 	{ "norock",	OPT_BOOL,   &opt.norock,	TRUE	},
11 	{ NULL,		0,	    NULL,		0	}
12 };
13 
14 static int sef_cb_init_fresh(int __unused type,
15 	sef_init_info_t * __unused info)
16 {
17 	/* Initialize the iso9660fs server. */
18 	int i;
19 
20 	/* Defaults */
21 	opt.norock = FALSE;
22 
23 	/* If we have been given an options string, parse options here. */
24 	for (i = 1; i < env_argc - 1; i++)
25 		if (!strcmp(env_argv[i], "-o"))
26 			optset_parse(optset_table, env_argv[++i]);
27 
28 	setenv("TZ","",1);              /* Used to calculate the time */
29 
30 	lmfs_buf_pool(NR_BUFS);
31 
32 	return OK;
33 }
34 
35 static void sef_cb_signal_handler(int signo)
36 {
37 	/* Only check for termination signal, ignore anything else. */
38 	if (signo != SIGTERM) return;
39 
40 	fsdriver_terminate();
41 }
42 
43 static void sef_local_startup(void)
44 {
45 	/* Register init callbacks. */
46 	sef_setcb_init_fresh(sef_cb_init_fresh);
47 	sef_setcb_init_restart(sef_cb_init_fail);
48 
49 	/* No live update support for now. */
50 
51 	/* Register signal callbacks. */
52 	sef_setcb_signal_handler(sef_cb_signal_handler);
53 
54 	/* Let SEF perform startup. */
55 	sef_startup();
56 }
57 
58 int main(int argc, char *argv[])
59 {
60 	/* SEF local startup. */
61 	env_setargs(argc, argv);
62 	sef_local_startup();
63 
64 	fsdriver_task(&isofs_table);
65 
66 	return 0;
67 }
68