From 5714e1cef2584410a7823c7ead9d2435141fb0c4 Mon Sep 17 00:00:00 2001 From: Jeremie Koenig Date: Sun, 22 Aug 2010 20:46:54 +0000 Subject: Add --stat-mode to override the perms for [pid]/stat * main.c (argp_parser, main): Add the --stat-mode option. * process.c (process_lookup_pid): Use it. --- process.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'process.c') diff --git a/process.c b/process.c index 65f0e503..f7a7a577 100644 --- a/process.c +++ b/process.c @@ -206,6 +206,7 @@ static struct procfs_dir_entry entries[] = { }, }, { + /* Beware of the hack below, which requires this to be entries[2]. */ .name = "stat", .make_node = process_file_make_node, .hook = & (struct process_file_desc) { @@ -235,6 +236,10 @@ process_lookup_pid (struct ps_context *pc, pid_t pid, struct node **np) if (err || ! (proc_stat_flags (ps) & PSTAT_OWNER_UID)) return EIO; + /* FIXME: have a separate proc_desc structure for each file, so this can be + accessed in a more robust and straightforward way. */ + ((struct process_file_desc *) entries[2].hook)->mode = opt_stat_mode; + *np = procfs_dir_make_node (entries, ps, (void (*)(void *)) _proc_stat_free); if (! *np) return ENOMEM; -- cgit v1.2.3