summaryrefslogtreecommitdiff
path: root/minix/lib/libsffs/main.c
blob: dccbf54e7d12e371860eb8ca150ead33dcefdeb4 (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
/* This file contains the SFFS initialization code and message loop.
 *
 * The entry points into this file are:
 *   sffs_init		initialization
 *   sffs_signal	signal handler
 *   sffs_loop		main message loop
 *
 * Created:
 *   April 2009 (D.C. van Moolenbroek)
 */

#include "inc.h"

/*===========================================================================*
 *				sffs_init				     *
 *===========================================================================*/
int sffs_init(char *name, const struct sffs_table *table,
  struct sffs_params *params)
{
/* Initialize this file server. Called at startup time.
 */
  int i;

  /* Make sure that the given path prefix doesn't end with a slash. */
  i = strlen(params->p_prefix);
  while (i > 0 && params->p_prefix[i - 1] == '/') i--;
  params->p_prefix[i] = 0;

  sffs_name = name;
  sffs_table = table;
  sffs_params = params;

  return OK;
}

/*===========================================================================*
 *				sffs_signal				     *
 *===========================================================================*/
void sffs_signal(int signo)
{

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

  dprintf(("%s: got SIGTERM\n", sffs_name));

  fsdriver_terminate();
}

/*===========================================================================*
 *				sffs_loop				     *
 *===========================================================================*/
void sffs_loop(void)
{
/* The main function of this file server. Libfsdriver does the real work.
 */

  fsdriver_task(&sffs_dtable);
}