Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Miklos Szeredi and committed by
Linus Torvalds
2b579bee 230649da

+13
+13
fs/proc/generic.c
··· 249 249 return error; 250 250 } 251 251 252 + static int proc_getattr(struct vfsmount *mnt, struct dentry *dentry, 253 + struct kstat *stat) 254 + { 255 + struct inode *inode = dentry->d_inode; 256 + struct proc_dir_entry *de = PROC_I(inode)->pde; 257 + if (de && de->nlink) 258 + inode->i_nlink = de->nlink; 259 + 260 + generic_fillattr(inode, stat); 261 + return 0; 262 + } 263 + 252 264 static struct inode_operations proc_file_inode_operations = { 253 265 .setattr = proc_notify_change, 254 266 }; ··· 487 475 */ 488 476 static struct inode_operations proc_dir_inode_operations = { 489 477 .lookup = proc_lookup, 478 + .getattr = proc_getattr, 490 479 .setattr = proc_notify_change, 491 480 }; 492 481