xref: /minix3/minix/lib/libsffs/main.c (revision a99c939dee4822394c21dbd4cb89e9451b901e7d)
1433d6423SLionel Sambuc /* This file contains the SFFS initialization code and message loop.
2433d6423SLionel Sambuc  *
3433d6423SLionel Sambuc  * The entry points into this file are:
4433d6423SLionel Sambuc  *   sffs_init		initialization
5433d6423SLionel Sambuc  *   sffs_signal	signal handler
6433d6423SLionel Sambuc  *   sffs_loop		main message loop
7433d6423SLionel Sambuc  *
8433d6423SLionel Sambuc  * Created:
9433d6423SLionel Sambuc  *   April 2009 (D.C. van Moolenbroek)
10433d6423SLionel Sambuc  */
11433d6423SLionel Sambuc 
12433d6423SLionel Sambuc #include "inc.h"
13433d6423SLionel Sambuc 
14433d6423SLionel Sambuc /*===========================================================================*
15433d6423SLionel Sambuc  *				sffs_init				     *
16433d6423SLionel Sambuc  *===========================================================================*/
sffs_init(char * name,const struct sffs_table * table,struct sffs_params * params)17433d6423SLionel Sambuc int sffs_init(char *name, const struct sffs_table *table,
18433d6423SLionel Sambuc   struct sffs_params *params)
19433d6423SLionel Sambuc {
20433d6423SLionel Sambuc /* Initialize this file server. Called at startup time.
21433d6423SLionel Sambuc  */
22433d6423SLionel Sambuc   int i;
23433d6423SLionel Sambuc 
24433d6423SLionel Sambuc   /* Make sure that the given path prefix doesn't end with a slash. */
25433d6423SLionel Sambuc   i = strlen(params->p_prefix);
26433d6423SLionel Sambuc   while (i > 0 && params->p_prefix[i - 1] == '/') i--;
27433d6423SLionel Sambuc   params->p_prefix[i] = 0;
28433d6423SLionel Sambuc 
29433d6423SLionel Sambuc   sffs_name = name;
30433d6423SLionel Sambuc   sffs_table = table;
31433d6423SLionel Sambuc   sffs_params = params;
32433d6423SLionel Sambuc 
33433d6423SLionel Sambuc   return OK;
34433d6423SLionel Sambuc }
35433d6423SLionel Sambuc 
36433d6423SLionel Sambuc /*===========================================================================*
37433d6423SLionel Sambuc  *				sffs_signal				     *
38433d6423SLionel Sambuc  *===========================================================================*/
sffs_signal(int signo)39433d6423SLionel Sambuc void sffs_signal(int signo)
40433d6423SLionel Sambuc {
41433d6423SLionel Sambuc 
42433d6423SLionel Sambuc   /* Only check for termination signal, ignore anything else. */
43433d6423SLionel Sambuc   if (signo != SIGTERM) return;
44433d6423SLionel Sambuc 
45*a99c939dSDavid van Moolenbroek   dprintf(("%s: got SIGTERM\n", sffs_name));
46433d6423SLionel Sambuc 
47*a99c939dSDavid van Moolenbroek   fsdriver_terminate();
48433d6423SLionel Sambuc }
49433d6423SLionel Sambuc 
50433d6423SLionel Sambuc /*===========================================================================*
51433d6423SLionel Sambuc  *				sffs_loop				     *
52433d6423SLionel Sambuc  *===========================================================================*/
sffs_loop(void)53433d6423SLionel Sambuc void sffs_loop(void)
54433d6423SLionel Sambuc {
55*a99c939dSDavid van Moolenbroek /* The main function of this file server. Libfsdriver does the real work.
56433d6423SLionel Sambuc  */
57433d6423SLionel Sambuc 
58*a99c939dSDavid van Moolenbroek   fsdriver_task(&sffs_dtable);
59433d6423SLionel Sambuc }
60