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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/* procfs -- a translator for providing GNU/Linux compatible
proc pseudo-filesystem
bootstrap.c -- This file is functions for starting up
and initializers for the procfs translator
defined in procfs.h
Copyright (C) 2008, FSF.
Written as a Summer of Code Project
procfs is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or (at
your option) any later version.
procfs is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
#include <stddef.h>
#include <hurd/ihash.h>
#include <hurd/netfs.h>
#include "procfs.h"
struct ps_context *ps_context;
/* This function is used to initialize the whole translator, can be
effect called as bootstrapping the translator. */
error_t procfs_init ()
{
error_t err;
err = ps_context_create (getproc (), &ps_context);
return err;
}
/* Create a new procfs filesystem. */
error_t procfs_create (char *procfs_root, int fsid,
struct procfs **fs)
{
error_t err;
/* This is the enclosing directory for this filesystem's
root node */
struct procfs_dir *topmost_root_dir;
/* And also a topmost-root node, just used for locking
TOPMOST_ROOT_DIR. */
struct node *topmost_root;
/* The new node for the filesystem's root. */
struct procfs *new = malloc (sizeof (struct procfs));
if (! new)
return ENOMEM;
new->fsid = fsid;
new->next_inode = 2;
hurd_ihash_init (&new->inode_mappings,
offsetof (struct procfs_dir_entry, inode_locp));
spin_lock_init (&new->inode_mappings_lock);
topmost_root = netfs_make_node (0);
if (! topmost_root)
err = ENOMEM;
else
{
err = procfs_dir_create (new, topmost_root, procfs_root,
&topmost_root_dir);
if (! err)
{
/* ADDITIONAL BOOTSTRAPPING OF THE ROOT NODE */
err = procfs_dir_null_lookup (topmost_root_dir, &new->root);
}
}
if (err)
{
hurd_ihash_destroy (&new->inode_mappings);
free (new);
}
else
*fs = new;
return err;
}
|