xref: /minix/minix/lib/libsffs/main.c (revision 83133719)
1 /* This file contains the SFFS initialization code and message loop.
2  *
3  * The entry points into this file are:
4  *   sffs_init		initialization
5  *   sffs_signal	signal handler
6  *   sffs_loop		main message loop
7  *
8  * Created:
9  *   April 2009 (D.C. van Moolenbroek)
10  */
11 
12 #include "inc.h"
13 
14 /*===========================================================================*
15  *				sffs_init				     *
16  *===========================================================================*/
17 int sffs_init(char *name, const struct sffs_table *table,
18   struct sffs_params *params)
19 {
20 /* Initialize this file server. Called at startup time.
21  */
22   int i;
23 
24   /* Make sure that the given path prefix doesn't end with a slash. */
25   i = strlen(params->p_prefix);
26   while (i > 0 && params->p_prefix[i - 1] == '/') i--;
27   params->p_prefix[i] = 0;
28 
29   sffs_name = name;
30   sffs_table = table;
31   sffs_params = params;
32 
33   return OK;
34 }
35 
36 /*===========================================================================*
37  *				sffs_signal				     *
38  *===========================================================================*/
39 void sffs_signal(int signo)
40 {
41 
42   /* Only check for termination signal, ignore anything else. */
43   if (signo != SIGTERM) return;
44 
45   dprintf(("%s: got SIGTERM\n", sffs_name));
46 
47   fsdriver_terminate();
48 }
49 
50 /*===========================================================================*
51  *				sffs_loop				     *
52  *===========================================================================*/
53 void sffs_loop(void)
54 {
55 /* The main function of this file server. Libfsdriver does the real work.
56  */
57 
58   fsdriver_task(&sffs_dtable);
59 }
60