The revoke like functionality of proc_unregister currently
does not call the release method when access is revoked.
This makes it difficult at least to have per open state
for any procfs entry.

This patch calls the release method just before f_op is
replaced by NULL, so release can be used to clean up
per open state.

On the other hand, this may lead to complex locking issues
which I might not fully understand.

Comments?

Tom
--- fs/proc/root.c      1999/08/28 12:29:08     1.1
+++ fs/proc/root.c      1999/08/28 13:04:19
@@ -381,6 +381,7 @@
                        struct file * filp = list_entry(p, struct file, f_list);
                        struct dentry * dentry;
                        struct inode * inode;
+                       int (*release)(struct inode *, struct file *) = NULL;
 
                        dentry = filp->f_dentry;
                        if (!dentry)
@@ -392,7 +393,19 @@
                                continue;
                        if (inode->i_ino != ino)
                                continue;
+                       /*
+                        * 19990828, [EMAIL PROTECTED]
+                        * call the release method for the filp now, as it is
+                        * unaccessible afterwards. Careful: if the release
+                        * method pointer is non-null, proc_unregister should
+                        * be called with the lock_kernel lock being held.
+                        * This is the case for USB, where I intend to use this.
+                        */
+                       if (filp->f_op)
+                               release = filp->f_op->release;
                        filp->f_op = NULL;
+                       if (release)
+                               release(inode, filp);
                }
                file_list_unlock();
        }

Reply via email to