[HACK][CFT] procfs without processes.

From: Alexander Viro (viro@math.psu.edu)
Date: Mon Mar 13 2000 - 16:24:10 EST


        Folks, if somebody is still interested in mounting the
process-less subset of procfs (everything except /proc/<PID>/*) - try the
patchlet below. It makes (quite arbitrary) -o nodiratime option to give
such behaviour on procfs (changing the choice of option is the matter of
s/IS_NODIRATIME/whatever_you_want/)

        Patch is against -pre2. Feedback is welcome, indeed.
                                                        Cheers,
                                                                Al

diff -urN linux-2.3.52-pre2/fs/proc/inode.c linux-bird.vfs/fs/proc/inode.c
--- linux-2.3.52-pre2/fs/proc/inode.c Sat Mar 11 01:33:10 2000
+++ linux-bird.vfs/fs/proc/inode.c Mon Mar 13 12:25:14 2000
@@ -212,12 +212,14 @@
         root_inode = proc_get_inode(s, PROC_ROOT_INO, &proc_root);
         if (!root_inode)
                 goto out_no_root;
- /*
- * Fixup the root inode's nlink value
- */
- read_lock(&tasklist_lock);
- for_each_task(p) if (p->pid) root_inode->i_nlink++;
- read_unlock(&tasklist_lock);
+ if (!IS_NODIRATIME(root_inode)) {
+ /*
+ * Fixup the root inode's nlink value
+ */
+ read_lock(&tasklist_lock);
+ for_each_task(p) if (p->pid) root_inode->i_nlink++;
+ read_unlock(&tasklist_lock);
+ }
         s->s_root = d_alloc_root(root_inode);
         if (!s->s_root)
                 goto out_no_root;
diff -urN linux-2.3.52-pre2/fs/proc/root.c linux-bird.vfs/fs/proc/root.c
--- linux-2.3.52-pre2/fs/proc/root.c Tue Mar 7 18:19:14 2000
+++ linux-bird.vfs/fs/proc/root.c Mon Mar 13 12:16:14 2000
@@ -80,6 +80,9 @@
 {
         struct task_struct *p;
 
+ if (IS_NODIRATIME(dir))
+ return proc_lookup(dir, dentry);
+
         if (dir->i_ino == PROC_ROOT_INO) { /* check for safety... */
                 extern unsigned long total_forks;
                 static int last_timestamp = 0;
@@ -123,8 +126,9 @@
                         return error;
                 filp->f_pos = FIRST_PROCESS_ENTRY;
         }
-
- return proc_pid_readdir(filp, dirent, filldir);
+ if (!IS_NODIRATIME(filp->f_dentry->d_inode))
+ return proc_pid_readdir(filp, dirent, filldir);
+ return 0;
 }
 
 /*

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 21:00:26 EST