summaryrefslogtreecommitdiff
path: root/main.c
blob: 4350eff50c75eeefed851909e83a3f7ab4c174fe (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
#include <mach.h>
#include <hurd.h>
#include <error.h>
#include <argp.h>
#include <hurd/netfs.h>
#include "procfs.h"
#include "procfs_file.h"
#include "procfs_dir.h"
#include "proclist.h"

static struct node *make_file (void *dir_hook, void *ent_hook)
{
  return procfs_file_make_node (ent_hook, -1, NULL);
}

static struct node *make_proclist (void *dir_hook, void *ent_hook)
{
  return proclist_make_node (getproc ());
}

int main (int argc, char **argv)
{
  static const struct procfs_dir_entry entries[] = {
    { "hello",		make_file,	"Hello, World!\n" },
    { "goodbye",	make_file,	"Goodbye, cruel World!\n" },
    { "proclist",	make_proclist,	},
    { }
  };
  mach_port_t bootstrap;

  argp_parse (&netfs_std_startup_argp, argc, argv, 0, 0, 0);

  task_get_bootstrap_port (mach_task_self (), &bootstrap);
  if (bootstrap == MACH_PORT_NULL)
    error (1, 0, "Must be started as a translator");

  netfs_init ();
  netfs_root_node = procfs_dir_make_node (entries, NULL, NULL);

  netfs_startup (bootstrap, 0);
  for (;;)
    netfs_server_loop ();
}