--- procfs/Makefile | 2 +- procfs/rootdir.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/procfs/Makefile b/procfs/Makefile index 13ee026c4..d32328d28 100644 --- a/procfs/Makefile +++ b/procfs/Makefile @@ -21,7 +21,7 @@ makemode := server target = procfs -SRCS = procfs.c netfs.c procfs_dir.c process.c proclist.c rootdir.c dircat.c main.c mach_debugUser.c default_pagerUser.c +SRCS = procfs.c netfs.c procfs_dir.c process.c proclist.c rootdir.c dircat.c main.c mach_debugUser.c default_pagerUser.c pfinetUser.c LCLHDRS = dircat.h main.h process.h procfs.h procfs_dir.h proclist.h rootdir.h OBJS = $(SRCS:.c=.o) diff --git a/procfs/rootdir.c b/procfs/rootdir.c index 0e7c05c00..659d079ec 100644 --- a/procfs/rootdir.c +++ b/procfs/rootdir.c @@ -39,6 +39,7 @@ #include "main.h" #include "mach_debug_U.h" +#include "pfinet_U.h" /* This implements a directory node with the static files in /proc. NB: the libps functions for host information return static storage; @@ -408,6 +409,41 @@ out: return err; } +static error_t +rootdir_gc_route (void *hook, char **contents, ssize_t *contents_len) +{ + error_t err; + mach_port_t pfinet; + unsigned int len = 0; + char *buf; + + pfinet = file_name_lookup (_SERVERS_SOCKET "/2", O_RDONLY, 0); + if (pfinet == MACH_PORT_NULL) + { + *contents_len = 0; + err = errno; + goto out; + } + + err = pfinet_getroutes (pfinet, -1, &buf, &len); + if (err) + { + *contents_len = 0; + goto out; + } + + *contents_len = len; + *contents = malloc (*contents_len); + if (! *contents) + err = ENOMEM; + else + memcpy (*contents, buf, *contents_len); + +out: + mach_port_deallocate (mach_task_self (), pfinet); + return err; +} + static struct node *rootdir_self_node; static struct node *rootdir_mounts_node; @@ -780,6 +816,13 @@ static const struct procfs_dir_entry rootdir_entries[] = { .cleanup_contents = procfs_cleanup_contents_with_free, }, }, + { + .name = "route", + .hook = & (struct procfs_node_ops) { + .get_contents = rootdir_gc_route, + .cleanup_contents = procfs_cleanup_contents_with_free, + }, + }, { .name = "mounts", .hook = ROOTDIR_DEFINE_TRANSLATED_NODE (&rootdir_mounts_node, -- 2.34.1