sunrpc as module and bad proc/sys link count
Hello.
When sunrpc is as module, sysctl adds to proc fs proc/sys/sunrpc, adds 1 to number of proc/sys link (see later), but when it's ls-ed, there is still old count. I.e.
my proc/sys before modprobe-ing sunrpc:
# ls -la /proc/sys celkem 0 dr-xr-xr-x 9 root root 0 srp 5 12:43 . dr-xr-xr-x 114 root root 0 srp 5 2005 .. dr-xr-xr-x 2 root root 0 srp 5 14:33 debug dr-xr-xr-x 4 root root 0 srp 5 14:33 dev dr-xr-xr-x 5 root root 0 srp 5 12:43 fs drwxr-xr-x 5 root root 0 srp 5 14:33 kernel dr-xr-xr-x 7 root root 0 srp 5 14:33 net dr-xr-xr-x 2 root root 0 srp 5 14:33 proc dr-xr-xr-x 2 root root 0 srp 5 14:33 vm # stat /proc/sys File: `/proc/sys' Size: 0 Blocks: 0 IO Block: 1024 directory Device: 3h/3d Inode: -268435429 Links: 9 *[BTW This seems like bad interpretation of the un/signed number (real inode from ls out is 4026531867.]* Access: (0555/dr-xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2005-08-05 12:43:12.066160750 +0200 Modify: 2005-08-05 12:43:12.066160750 +0200 Change: 2005-08-05 12:43:12.066160750 +0200
after:
#modprobe sunrpc
#ls -la /proc/sys
celkem 0
dr-xr-xr-x 9 root root 0 srp 5 12:43 . <-- The 9 here should be now 10 dr-xr-xr-x 114 root root 0 srp 5 2005 .. dr-xr-xr-x 2 root root 0 srp 5 14:35 debug dr-xr-xr-x 4 root root 0 srp 5 14:35 dev dr-xr-xr-x 5 root root 0 srp 5 12:43 fs drwxr-xr-x 5 root root 0 srp 5 14:35 kernel dr-xr-xr-x 7 root root 0 srp 5 14:35 net dr-xr-xr-x 2 root root 0 srp 5 14:35 proc dr-xr-xr-x 2 root root 0 srp 5 14:35 sunrpc dr-xr-xr-x 2 root root 0 srp 5 14:35 vm # stat /proc/sys File: `/proc/sys' Size: 0 Blocks: 0 IO Block: 1024 directory Device: 3h/3d Inode: -268435429 Links: 9 Access: (0555/dr-xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2005-08-05 12:43:12.066160750 +0200 Modify: 2005-08-05 12:43:12.066160750 +0200 Change: 2005-08-05 12:43:12.066160750 +0200
When I add printk to proc/generic.c into create_proc_entry before and after proc_register, it prints 9 and after 10 (so the nlink is added here).
On the other side, when sunrpc is in the kernel (not as module) it works fine, and the count returned by proc fs is 10, so ok.
This appears in kernels 2.6.11.12 through 2.6.13-rc4-mm1, maybe in older kernels too.
Signature · 3 lines
Jiri Slaby www.fi.muni.cz/~xslaby ~\-/~ [email protected] ~\-/~ 241B347EC88228DE51EE A49C4A73A25004CB2A10
Quoted 3 lines
When sunrpc is as module, sysctl adds to proc fs proc/sys/sunrpc, adds 1 to number of proc/sys link (see later), but when it's ls-ed, there is still old count.
Does this patch solve it?
fs/proc/generic.c +13 -0
@@ -249,6 +249,18 @@ out: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 = { .setattr = proc_notify_change, };
@@ -475,6 +487,7 @@ static struct file_operations proc_dir_o*/ static struct inode_operations proc_dir_inode_operations = { .lookup = proc_lookup, + .getattr = proc_getattr, .setattr = proc_notify_change, };
Miklos Szeredi napsal(a):
Quoted 1 line
Does this patch solve it?
Yes, you can post.
Signature · 3 lines
Jiri Slaby www.fi.muni.cz/~xslaby ~\-/~ [email protected] ~\-/~ 241B347EC88228DE51EE A49C4A73A25004CB2A10