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
66
67
68
69
70
|
#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"
#include "dircat.h"
static struct node *
make_file (void *dir_hook, void *ent_hook)
{
return procfs_file_make_node (ent_hook, -1, NULL);
}
error_t
root_make_node (struct node **np)
{
static const struct procfs_dir_entry static_entries[] = {
{ "hello", make_file, "Hello, World!\n" },
{ "goodbye", make_file, "Goodbye, cruel World!\n" },
};
/* We never have two root nodes alive simultaneously, so it's ok to
have this as static data. */
static struct node *root_dirs[3];
error_t err;
root_dirs[0] = procfs_dir_make_node (static_entries, NULL, NULL);
if (! root_dirs[0])
return ENOMEM;
err = proclist_create_node (getproc (), &root_dirs[1]);
if (err)
{
netfs_nrele (root_dirs[0]);
return err;
}
root_dirs[2] = NULL;
*np = dircat_make_node (root_dirs);
if (! *np)
return ENOMEM;
/* Since this one is not created through proc_lookup(), we have to affect an
inode number to it. */
(*np)->nn_stat.st_ino = * (uint32_t *) "PROC";
return 0;
}
int main (int argc, char **argv)
{
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 ();
root_make_node (&netfs_root_node);
netfs_startup (bootstrap, 0);
for (;;)
netfs_server_loop ();
}
|