Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363247
b: refs/heads/master
c: f7db5e7
h: refs/heads/master
i:
  363245: ec19cb9
  363243: 4f4e81d
  363239: 0e2a2de
  363231: 818bae2
v: v3
  • Loading branch information
Ming Lei authored and Greg Kroah-Hartman committed Apr 3, 2013
1 parent 24a110c commit f76142a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 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: 0f8b1a0204a12441cddbbf5be31e6338e0b8da1c
refs/heads/master: f7db5e7660b122142410dcf36ba903c73d473250
15 changes: 11 additions & 4 deletions trunk/fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
enum kobj_ns_type type;
const void *ns;
ino_t ino;
loff_t off;

type = sysfs_ns_type(parent_sd);
ns = sysfs_info(dentry->d_sb)->ns[type];
Expand All @@ -1021,6 +1022,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
return 0;
}
mutex_lock(&sysfs_mutex);
off = filp->f_pos;
for (pos = sysfs_dir_pos(ns, parent_sd, filp->f_pos, pos);
pos;
pos = sysfs_dir_next_pos(ns, parent_sd, filp->f_pos, pos)) {
Expand All @@ -1032,19 +1034,24 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
len = strlen(name);
ino = pos->s_ino;
type = dt_type(pos);
filp->f_pos = pos->s_hash;
off = filp->f_pos = pos->s_hash;
filp->private_data = sysfs_get(pos);

mutex_unlock(&sysfs_mutex);
ret = filldir(dirent, name, len, filp->f_pos, ino, type);
ret = filldir(dirent, name, len, off, ino, type);
mutex_lock(&sysfs_mutex);
if (ret < 0)
break;
}
mutex_unlock(&sysfs_mutex);
if ((filp->f_pos > 1) && !pos) { /* EOF */
filp->f_pos = INT_MAX;

/* don't reference last entry if its refcount is dropped */
if (!pos) {
filp->private_data = NULL;

/* EOF and not changed as 0 or 1 in read/write path */
if (off == filp->f_pos && off > 1)
filp->f_pos = INT_MAX;
}
return 0;
}
Expand Down

0 comments on commit f76142a

Please sign in to comment.