diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-23 09:06:01 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:29:53 +0200 |
commit | 4deaca2ce2c4ed2c5ab53f57a7747c71126a8da7 (patch) | |
tree | ecd58a1b4cd0b80ed3b7ca838c8bb94731b2f833 /main.c | |
parent | 4f40fb6fbfa95c51b6abfceffcd0e1ce80824e70 (diff) | |
download | hurd-4deaca2ce2c4ed2c5ab53f57a7747c71126a8da7.tar.gz hurd-4deaca2ce2c4ed2c5ab53f57a7747c71126a8da7.tar.bz2 hurd-4deaca2ce2c4ed2c5ab53f57a7747c71126a8da7.zip |
Use a global ps_context
* proclist.c, proclist.h (proclist_create_node): Use a
ps_context passed by the caller; errors are no longer possible, rename
to proclist_make_node and change the signature accordingly.
* rootdir.c, rootdir.h (rootdir_create_node): Likewise.
* main.c (main): Create the ps_context here and pass it to
root_make_node. (root_make_node): Pass it to proclist_make_node and
rootdir_make_node.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 35 |
1 files changed, 22 insertions, 13 deletions
@@ -4,6 +4,7 @@ #include <error.h> #include <argp.h> #include <hurd/netfs.h> +#include <ps.h> #include "procfs.h" #include "proclist.h" #include "rootdir.h" @@ -94,38 +95,42 @@ struct argp argp = { }; error_t -root_make_node (struct node **np) +root_make_node (struct ps_context *pc, struct node **np) { /* 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; - err = proclist_create_node (getproc (), &root_dirs[0]); - if (err) - return err; + root_dirs[0] = proclist_make_node (pc); + if (! root_dirs[0]) + goto nomem; - err = rootdir_create_node (&root_dirs[1]); - if (err) - { - netfs_nrele (root_dirs[0]); - return err; - } + root_dirs[1] = rootdir_make_node (pc); + if (! root_dirs[1]) + goto nomem; root_dirs[2] = NULL; *np = dircat_make_node (root_dirs); if (! *np) - return ENOMEM; + goto nomem; /* 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; + +nomem: + if (root_dirs[1]) + netfs_nrele (root_dirs[1]); + if (root_dirs[0]) + netfs_nrele (root_dirs[0]); + return ENOMEM; } int main (int argc, char **argv) { + struct ps_context *pc; mach_port_t bootstrap; error_t err; @@ -137,12 +142,16 @@ int main (int argc, char **argv) if (err) error (1, err, "Could not parse command line"); + err = ps_context_create (getproc (), &pc); + if (err) + error (1, err, "Could not create libps context"); + task_get_bootstrap_port (mach_task_self (), &bootstrap); if (bootstrap == MACH_PORT_NULL) error (1, 0, "Must be started as a translator"); netfs_init (); - err = root_make_node (&netfs_root_node); + err = root_make_node (pc, &netfs_root_node); if (err) error (1, err, "Could not create the root node"); |