summaryrefslogtreecommitdiff
path: root/procfs.c
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-21 11:21:59 +0000
committerJeremie Koenig <jk@jk.fr.eu.org>2010-08-30 14:29:49 +0200
commit75f53efdc66be8c6ffac31bd17a309f9065e273c (patch)
tree434b70dea1f585511be1f9863cdb01bfc2619465 /procfs.c
parenta45606d0036565c468b462a207575bf2b4077fd8 (diff)
Encapsulate access to node->nn_stat
* procfs.c, procfs.h (procfs_node_chown, procfs_node_chmod, procfs_node_chtype): New functions, encapsulate access to some nn_stat fields. * process.c (process_lookup_pid): Use procfs_node_chown instead of direct access.
Diffstat (limited to 'procfs.c')
-rw-r--r--procfs.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/procfs.c b/procfs.c
index 0a235a76..5396ecf7 100644
--- a/procfs.c
+++ b/procfs.c
@@ -67,6 +67,25 @@ fail:
return NULL;
}
+void procfs_node_chown (struct node *np, uid_t owner)
+{
+ np->nn_stat.st_uid = 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_translated = np->nn_stat.st_mode;
+}
+
+void procfs_node_chtype (struct node *np, mode_t type)
+{
+ np->nn_stat.st_mode = (np->nn_stat.st_mode & ~S_IFMT) | type;
+ np->nn_translated = np->nn_stat.st_mode;
+ if (type == S_IFLNK)
+ procfs_node_chmod (np, 0777);
+}
+
/* FIXME: possibly not the fastest hash function... */
ino64_t
procfs_make_ino (struct node *np, const char *filename)