Skip to content

Commit

Permalink
[readdir] convert procfs
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jun 29, 2013
1 parent 68c6147 commit f0c3b50
Show file tree
Hide file tree
Showing 9 changed files with 284 additions and 489 deletions.
33 changes: 14 additions & 19 deletions fs/hppfs/hppfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ static const struct file_operations hppfs_file_fops = {
};

struct hppfs_dirent {
void *vfs_dirent;
filldir_t filldir;
struct dir_context ctx;
struct dir_context *caller;
struct dentry *dentry;
};

Expand All @@ -555,34 +555,29 @@ static int hppfs_filldir(void *d, const char *name, int size,
if (file_removed(dirent->dentry, name))
return 0;

return (*dirent->filldir)(dirent->vfs_dirent, name, size, offset,
inode, type);
dirent->caller->pos = dirent->ctx.pos;
return !dir_emit(dirent->caller, name, size, inode, type);
}

static int hppfs_readdir(struct file *file, void *ent, filldir_t filldir)
static int hppfs_readdir(struct file *file, struct dir_context *ctx)
{
struct hppfs_private *data = file->private_data;
struct file *proc_file = data->proc_file;
int (*readdir)(struct file *, void *, filldir_t);
struct hppfs_dirent dirent = ((struct hppfs_dirent)
{ .vfs_dirent = ent,
.filldir = filldir,
.dentry = file->f_path.dentry
});
struct hppfs_dirent d = {
.ctx.actor = hppfs_filldir,
.caller = ctx,
.dentry = file->f_path.dentry
};
int err;

readdir = file_inode(proc_file)->i_fop->readdir;

proc_file->f_pos = file->f_pos;
err = (*readdir)(proc_file, &dirent, hppfs_filldir);
file->f_pos = proc_file->f_pos;

proc_file->f_pos = ctx->pos;
err = iterate_dir(proc_file, &d.ctx);
ctx->pos = d.ctx.pos;
return err;
}

static const struct file_operations hppfs_dir_fops = {
.owner = NULL,
.readdir = hppfs_readdir,
.iterate = hppfs_readdir,
.open = hppfs_dir_open,
.llseek = default_llseek,
.release = hppfs_release,
Expand Down
Loading

0 comments on commit f0c3b50

Please sign in to comment.