summaryrefslogtreecommitdiff
path: root/minix/fs/isofs/main.c
blob: 39d40362e4989f8b62e94af2c50209ecd29027f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * This file contains the main function for the server. It waits for a request
 * and then send a response.
 */

#include "inc.h"
#include <minix/optset.h>

static struct optset optset_table[] = {
	{ "norock",	OPT_BOOL,   &opt.norock,	TRUE	},
	{ NULL,		0,	    NULL,		0	}
};

static int sef_cb_init_fresh(int __unused type,
	sef_init_info_t * __unused info)
{
	/* Initialize the iso9660fs server. */
	int i;

	/* Defaults */
	opt.norock = FALSE;

	/* If we have been given an options string, parse options here. */
	for (i = 1; i < env_argc - 1; i++)
		if (!strcmp(env_argv[i], "-o"))
			optset_parse(optset_table, env_argv[++i]);

	setenv("TZ","",1);              /* Used to calculate the time */

	lmfs_buf_pool(NR_BUFS);

	return OK;
}

static void sef_cb_signal_handler(int signo)
{
	/* Only check for termination signal, ignore anything else. */
	if (signo != SIGTERM) return;

	fsdriver_terminate();
}

static void sef_local_startup(void)
{
	/* Register init callbacks. */
	sef_setcb_init_fresh(sef_cb_init_fresh);
	sef_setcb_init_restart(SEF_CB_INIT_RESTART_STATEFUL);

	/* Register signal callbacks. */
	sef_setcb_signal_handler(sef_cb_signal_handler);

	/* Let SEF perform startup. */
	sef_startup();
}

int main(int argc, char *argv[])
{
	/* SEF local startup. */
	env_setargs(argc, argv);
	sef_local_startup();

	fsdriver_task(&isofs_table);

	return 0;
}