RFC: proc_unregister: call release method

Thomas Sailer (sailer@ife.ee.ethz.ch)
Mon, 30 Aug 1999 18:32:11 +0200


This is a multi-part message in MIME format.
--------------08314F3014F4EC8A025EFA67
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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
--------------08314F3014F4EC8A025EFA67
Content-Type: text/plain; charset=us-ascii;
name="proc.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="proc.diff"

--- 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, sailer@ife.ee.ethz.ch
+ * 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();
}

--------------08314F3014F4EC8A025EFA67--

-
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/