Skip to content

Commit

Permalink
[PATCH] proc: link count fix
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
szmi authored and Linus Torvalds committed Sep 7, 2005
1 parent 230649d commit 2b579be
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fs/proc/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,18 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
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,
};
Expand Down Expand Up @@ -475,6 +487,7 @@ static struct file_operations proc_dir_operations = {
*/
static struct inode_operations proc_dir_inode_operations = {
.lookup = proc_lookup,
.getattr = proc_getattr,
.setattr = proc_notify_change,
};

Expand Down

0 comments on commit 2b579be

Please sign in to comment.