Эх сурвалжийг харах

[PATCH] proc: link count fix

This patch fixes bug titled "sunrpc as module and bad proc/sys link count"
reported by Jiri Slaby.

The problem was, that only proc_dir_entry->nlink was updated and the
corresponding inode->i_nlink was not.  The fix is to implement the
inode->getattr() method, and update i_nlink (if necessary).

A quick audit of proc code shows that no other attribute changes after
creation.

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Miklos Szeredi 19 жил өмнө
parent
commit
2b579beec2
1 өөрчлөгдсөн 13 нэмэгдсэн , 0 устгасан
  1. 13 0
      fs/proc/generic.c

+ 13 - 0
fs/proc/generic.c

@@ -249,6 +249,18 @@ out:
 	return error;
 	return error;
 }
 }
 
 
+static int proc_getattr(struct vfsmount *mnt, struct dentry *dentry,
+			struct kstat *stat)
+{
+	struct inode *inode = dentry->d_inode;
+	struct proc_dir_entry *de = PROC_I(inode)->pde;
+	if (de && de->nlink)
+		inode->i_nlink = de->nlink;
+
+	generic_fillattr(inode, stat);
+	return 0;
+}
+
 static struct inode_operations proc_file_inode_operations = {
 static struct inode_operations proc_file_inode_operations = {
 	.setattr	= proc_notify_change,
 	.setattr	= proc_notify_change,
 };
 };
@@ -475,6 +487,7 @@ static struct file_operations proc_dir_operations = {
  */
  */
 static struct inode_operations proc_dir_inode_operations = {
 static struct inode_operations proc_dir_inode_operations = {
 	.lookup		= proc_lookup,
 	.lookup		= proc_lookup,
+	.getattr	= proc_getattr,
 	.setattr	= proc_notify_change,
 	.setattr	= proc_notify_change,
 };
 };