diff options
| author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2013-07-27 21:08:48 +0000 |
|---|---|---|
| committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2013-07-27 21:08:48 +0000 |
| commit | 21adb5284111190057db245cfc2b54091920c373 (patch) | |
| tree | eb7f1709f14f18c7fc705be8da2e941bd07fb49b /procfs | |
| parent | bf5c437c82625cd44897faaa84ac81c470423846 (diff) | |
New upstream snapshot
Diffstat (limited to 'procfs')
| -rw-r--r-- | procfs/Makefile | 4 | ||||
| -rw-r--r-- | procfs/main.c | 22 | ||||
| -rw-r--r-- | procfs/netfs.c | 11 | ||||
| -rw-r--r-- | procfs/procfs.c | 18 | ||||
| -rw-r--r-- | procfs/procfs.h | 6 | ||||
| -rw-r--r-- | procfs/rootdir.c | 4 |
6 files changed, 60 insertions, 5 deletions
diff --git a/procfs/Makefile b/procfs/Makefile index c69cb206..5c51c1d2 100644 --- a/procfs/Makefile +++ b/procfs/Makefile @@ -1,7 +1,7 @@ TARGET = procfs OBJS = procfs.o netfs.o procfs_dir.o \ process.o proclist.o rootdir.o dircat.o main.o -LIBS = -lnetfs -lps -lfshelp +LIBS = -lnetfs -lps -lfshelp -lpthread CC = gcc CFLAGS = -Wall -g @@ -12,7 +12,7 @@ ifdef PROFILE CFLAGS= -g -pg CPPFLAGS= -DPROFILE LDFLAGS= -static -LIBS= -lnetfs -lfshelp -liohelp -lps -lports -lthreads -lihash -lshouldbeinlibc +LIBS= -lnetfs -lfshelp -liohelp -lps -lports -lpthread -lihash -lshouldbeinlibc endif CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 diff --git a/procfs/main.c b/procfs/main.c index 1b19c013..90b3e92c 100644 --- a/procfs/main.c +++ b/procfs/main.c @@ -37,6 +37,10 @@ pid_t opt_fake_self; pid_t opt_kernel_pid; uid_t opt_anon_owner; +#define NODEV_KEY -1 /* <= 0, so no short option. */ +#define NOEXEC_KEY -2 /* Likewise. */ +#define NOSUID_KEY -3 /* Likewise. */ + static error_t argp_parser (int key, char *arg, struct argp_state *state) { @@ -104,6 +108,18 @@ argp_parser (int key, char *arg, struct argp_state *state) else opt_anon_owner = v; break; + + case NODEV_KEY: + /* Ignored for compatibility with Linux' procfs. */ + ;; + + case NOEXEC_KEY: + /* Ignored for compatibility with Linux' procfs. */ + ;; + + case NOSUID_KEY: + /* Ignored for compatibility with Linux' procfs. */ + ;; } return 0; @@ -136,6 +152,12 @@ struct argp argp = { "Be aware that USER will be granted access to the environment and " "other sensitive information about the processes in question. " "(default: use uid 0)" }, + { "nodev", NODEV_KEY, NULL, 0, + "Ignored for compatibility with Linux' procfs." }, + { "noexec", NOEXEC_KEY, NULL, 0, + "Ignored for compatibility with Linux' procfs." }, + { "nosuid", NOSUID_KEY, NULL, 0, + "Ignored for compatibility with Linux' procfs." }, {} }, .parser = argp_parser, diff --git a/procfs/netfs.c b/procfs/netfs.c index c139d11a..276c57cc 100644 --- a/procfs/netfs.c +++ b/procfs/netfs.c @@ -230,6 +230,17 @@ void netfs_node_norefs (struct node *np) pthread_spin_lock (&netfs_node_refcnt_lock); } +/* The user may define this function (but should define it together + with netfs_set_translator). For locked node NODE with S_IPTRANS + set in its mode, look up the name of its translator. Store the + name into newly malloced storage, and return it in *ARGZ; set + *ARGZ_LEN to the total length. */ +error_t netfs_get_translator (struct node *np, char **argz, + size_t *argz_len) +{ + return procfs_get_translator (np, argz, argz_len); +} + /* Libnetfs callbacks managed with libfshelp. */ diff --git a/procfs/procfs.c b/procfs/procfs.c index ae5a6769..cae4a519 100644 --- a/procfs/procfs.c +++ b/procfs/procfs.c @@ -19,6 +19,7 @@ #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <fcntl.h> #include <mach.h> #include <hurd/netfs.h> @@ -76,6 +77,9 @@ struct node *procfs_make_node (const struct procfs_node_ops *ops, void *hook) else np->nn_stat.st_mode = S_IFREG | 0444; + np->nn_stat.st_uid = getuid (); + np->nn_stat.st_gid = getgid (); + return np; fail: @@ -93,7 +97,7 @@ void procfs_node_chown (struct node *np, uid_t owner) void procfs_node_chmod (struct node *np, mode_t mode) { - np->nn_stat.st_mode = (np->nn_stat.st_mode & S_IFMT) | mode; + np->nn_stat.st_mode = (np->nn_stat.st_mode & ~ALLPERMS) | mode; np->nn_translated = np->nn_stat.st_mode; } @@ -201,3 +205,15 @@ void procfs_cleanup (struct node *np) free (np->nn); } + +error_t procfs_get_translator (struct node *np, + char **argz, + size_t *argz_len) +{ + if (np->nn->ops->get_translator) + return np->nn->ops->get_translator (np->nn->hook, argz, argz_len); + + *argz = NULL; + *argz_len = 0; + return 0; +} diff --git a/procfs/procfs.h b/procfs/procfs.h index 64782ec4..d04bbad7 100644 --- a/procfs/procfs.h +++ b/procfs/procfs.h @@ -51,6 +51,9 @@ struct procfs_node_ops /* Destroy this node. */ void (*cleanup) (void *hook); + + /* Get the passive translator record. */ + error_t (*get_translator) (void *hook, char **argz, size_t *argz_len); }; /* These helper functions can be used as procfs_node_ops.cleanup_contents. */ @@ -91,3 +94,6 @@ error_t procfs_get_contents (struct node *np, char **data, ssize_t *data_len); error_t procfs_lookup (struct node *np, const char *name, struct node **npp); void procfs_cleanup (struct node *np); +/* Get the passive translator record if any. */ +error_t procfs_get_translator (struct node *np, char **argz, size_t *argz_len); + diff --git a/procfs/rootdir.c b/procfs/rootdir.c index 31e2d8c6..f234dd03 100644 --- a/procfs/rootdir.c +++ b/procfs/rootdir.c @@ -300,7 +300,7 @@ rootdir_gc_meminfo (void *hook, char **contents, ssize_t *contents_len) , (long unsigned) hbi.memory_size / 1024, (long unsigned) vmstats.free_count * PAGE_SIZE / 1024, - 0, + 0UL, (long unsigned) cache_stats.cache_count * PAGE_SIZE / 1024, (long unsigned) vmstats.active_count * PAGE_SIZE / 1024, (long unsigned) vmstats.inactive_count * PAGE_SIZE / 1024, @@ -392,7 +392,7 @@ out: } static int -rootdir_fakeself_exists () +rootdir_fakeself_exists (void *dir_hook, const void *entry_hook) { return opt_fake_self >= 0; } |
