patch-2.2.0-pre8 linux/fs/proc/root.c

Next file: linux/fs/select.c
Previous file: linux/fs/proc/array.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.0-pre7/linux/fs/proc/root.c linux/fs/proc/root.c
@@ -348,6 +348,32 @@
 	return 0;
 }
 
+/*
+ * Kill an inode that got unregistered..
+ */
+static void proc_kill_inodes(int ino)
+{
+	struct file *filp;
+
+	/* inuse_filps is protected by the single kernel lock */
+	for (filp = inuse_filps; filp; filp = filp->f_next) {
+		struct dentry * dentry;
+		struct inode * inode;
+
+		dentry = filp->f_dentry;
+		if (!dentry)
+			continue;
+		if (dentry->d_op != &proc_dentry_operations)
+			continue;
+		inode = dentry->d_inode;
+		if (!inode)
+			continue;
+		if (inode->i_ino != ino)
+			continue;
+		filp->f_op = NULL;
+	}
+}
+
 int proc_unregister(struct proc_dir_entry * dir, int ino)
 {
 	struct proc_dir_entry **p = &dir->subdir, *dp;
@@ -362,6 +388,7 @@
 			    ino < PROC_DYNAMIC_FIRST+PROC_NDYNAMIC)
 				clear_bit(ino-PROC_DYNAMIC_FIRST, 
 					  (void *) proc_alloc_map);
+			proc_kill_inodes(ino);
 			return 0;
 		}
 		p = &dp->next;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov