1 /* ProcFS - main.c - by Alen Stojanov and David van Moolenbroek */
6 static void init_hook(void);
8 /* The hook functions that will be called by VTreeFS. */
9 static struct fs_hooks hooks
= {
11 NULL
, /* cleanup_hook */
16 NULL
/* message_hook */
19 /*===========================================================================*
21 *===========================================================================*/
22 static void construct_tree(struct inode
*dir
, struct file
*files
)
24 /* Construct a tree of static files from a null-terminated array of
25 * file structures, recursively creating directories which have their
26 * associated data point to child file structures.
30 struct inode_stat stat
;
32 stat
.uid
= SUPER_USER
;
33 stat
.gid
= SUPER_USER
;
37 for (file
= files
; file
->name
!= NULL
; file
++) {
38 stat
.mode
= file
->mode
;
40 node
= add_inode(dir
, file
->name
, NO_INDEX
, &stat
, (index_t
) 0,
41 (cbdata_t
) file
->data
);
45 if (S_ISDIR(file
->mode
))
46 construct_tree(node
, (struct file
*) file
->data
);
50 /*===========================================================================*
52 *===========================================================================*/
53 static void init_hook(void)
55 /* Initialization hook. Generate the static part of the tree.
57 static int first_time
= 1;
61 root
= get_root_inode();
63 construct_tree(root
, root_files
);
69 /*===========================================================================*
71 *===========================================================================*/
74 /* ProcFS entry point.
76 struct inode_stat stat
;
79 /* Initialize some state. If we are incompatible with the kernel, exit
82 if ((r
= init_tree()) != OK
)
85 /* Properties of the root directory. */
86 stat
.mode
= DIR_ALL_MODE
;
87 stat
.uid
= SUPER_USER
;
88 stat
.gid
= SUPER_USER
;
92 /* Start VTreeFS. This call does not return. */
93 start_vtreefs(&hooks
, NR_INODES
, &stat
, NR_PROCS
+ NR_TASKS
);