Commit 68c61471 authored by Al Viro's avatar Al Viro

[readdir] convert openpromfs

what the hell is op_mutex for, BTW?
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 7aa123a0
...@@ -162,11 +162,11 @@ static const struct file_operations openpromfs_prop_ops = { ...@@ -162,11 +162,11 @@ static const struct file_operations openpromfs_prop_ops = {
.release = seq_release, .release = seq_release,
}; };
static int openpromfs_readdir(struct file *, void *, filldir_t); static int openpromfs_readdir(struct file *, struct dir_context *);
static const struct file_operations openprom_operations = { static const struct file_operations openprom_operations = {
.read = generic_read_dir, .read = generic_read_dir,
.readdir = openpromfs_readdir, .iterate = openpromfs_readdir,
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
}; };
...@@ -260,38 +260,31 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry ...@@ -260,38 +260,31 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry
return NULL; return NULL;
} }
static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filldir) static int openpromfs_readdir(struct file *file, struct dir_context *ctx)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(file);
struct op_inode_info *oi = OP_I(inode); struct op_inode_info *oi = OP_I(inode);
struct device_node *dp = oi->u.node; struct device_node *dp = oi->u.node;
struct device_node *child; struct device_node *child;
struct property *prop; struct property *prop;
unsigned int ino;
int i; int i;
mutex_lock(&op_mutex); mutex_lock(&op_mutex);
ino = inode->i_ino; if (ctx->pos == 0) {
i = filp->f_pos; if (!dir_emit(ctx, ".", 1, inode->i_ino, DT_DIR))
switch (i) {
case 0:
if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
goto out; goto out;
i++; ctx->pos = 1;
filp->f_pos++; }
/* fall thru */ if (ctx->pos == 1) {
case 1: if (!dir_emit(ctx, "..", 2,
if (filldir(dirent, "..", 2, i,
(dp->parent == NULL ? (dp->parent == NULL ?
OPENPROM_ROOT_INO : OPENPROM_ROOT_INO :
dp->parent->unique_id), DT_DIR) < 0) dp->parent->unique_id), DT_DIR))
goto out; goto out;
i++; ctx->pos = 2;
filp->f_pos++; }
/* fall thru */ i = ctx->pos - 2;
default:
i -= 2;
/* First, the children nodes as directories. */ /* First, the children nodes as directories. */
child = dp->child; child = dp->child;
...@@ -300,13 +293,13 @@ static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filld ...@@ -300,13 +293,13 @@ static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filld
i--; i--;
} }
while (child) { while (child) {
if (filldir(dirent, if (!dir_emit(ctx,
child->path_component_name, child->path_component_name,
strlen(child->path_component_name), strlen(child->path_component_name),
filp->f_pos, child->unique_id, DT_DIR) < 0) child->unique_id, DT_DIR))
goto out; goto out;
filp->f_pos++; ctx->pos++;
child = child->sibling; child = child->sibling;
} }
...@@ -317,14 +310,14 @@ static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filld ...@@ -317,14 +310,14 @@ static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filld
i--; i--;
} }
while (prop) { while (prop) {
if (filldir(dirent, prop->name, strlen(prop->name), if (!dir_emit(ctx, prop->name, strlen(prop->name),
filp->f_pos, prop->unique_id, DT_REG) < 0) prop->unique_id, DT_REG))
goto out; goto out;
filp->f_pos++; ctx->pos++;
prop = prop->next; prop = prop->next;
} }
}
out: out:
mutex_unlock(&op_mutex); mutex_unlock(&op_mutex);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment