Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 264851
b: refs/heads/master
c: 7f9838f
h: refs/heads/master
i:
  264849: fb5a3a2
  264847: c10889c
v: v3
  • Loading branch information
Mikulas Patocka authored and Greg Kroah-Hartman committed Aug 23, 2011
1 parent 7952e14 commit a097538
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 86028619b9f653a30f5aa0d331fdedd899a1eea5
refs/heads/master: 7f9838fd01833ffb30177d964983076924344c9e
6 changes: 6 additions & 0 deletions trunk/fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ static void sysfs_link_sibling(struct sysfs_dirent *sd)

BUG_ON(sd->s_sibling);

if (sysfs_type(sd) == SYSFS_DIR)
parent_sd->s_dir.subdirs++;

/* Store directory entries in order by ino. This allows
* readdir to properly restart without having to add a
* cursor into the s_dir.children list.
Expand All @@ -73,6 +76,9 @@ static void sysfs_unlink_sibling(struct sysfs_dirent *sd)
{
struct sysfs_dirent **pos;

if (sysfs_type(sd) == SYSFS_DIR)
sd->s_parent->s_dir.subdirs--;

for (pos = &sd->s_parent->s_dir.children; *pos;
pos = &(*pos)->s_sibling) {
if (*pos == sd) {
Expand Down
14 changes: 1 addition & 13 deletions trunk/fs/sysfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,6 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
inode->i_ctime = iattr->ia_ctime;
}

static int sysfs_count_nlink(struct sysfs_dirent *sd)
{
struct sysfs_dirent *child;
int nr = 0;

for (child = sd->s_dir.children; child; child = child->s_sibling)
if (sysfs_type(child) == SYSFS_DIR)
nr++;

return nr + 2;
}

static void sysfs_refresh_inode(struct sysfs_dirent *sd, struct inode *inode)
{
struct sysfs_inode_attrs *iattrs = sd->s_iattr;
Expand All @@ -230,7 +218,7 @@ static void sysfs_refresh_inode(struct sysfs_dirent *sd, struct inode *inode)
}

if (sysfs_type(sd) == SYSFS_DIR)
inode->i_nlink = sysfs_count_nlink(sd);
inode->i_nlink = sd->s_dir.subdirs + 2;
}

int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/sysfs/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct sysfs_elem_dir {
struct kobject *kobj;
/* children list starts here and goes through sd->s_sibling */
struct sysfs_dirent *children;

unsigned long subdirs;
};

struct sysfs_elem_symlink {
Expand Down

0 comments on commit a097538

Please sign in to comment.