Commit 2638ffba authored by Al Viro's avatar Al Viro

[readdir] convert adfs

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 46d07338
...@@ -17,47 +17,43 @@ ...@@ -17,47 +17,43 @@
static DEFINE_RWLOCK(adfs_dir_lock); static DEFINE_RWLOCK(adfs_dir_lock);
static int static int
adfs_readdir(struct file *filp, void *dirent, filldir_t filldir) adfs_readdir(struct file *file, struct dir_context *ctx)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(file);
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir; struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
struct object_info obj; struct object_info obj;
struct adfs_dir dir; struct adfs_dir dir;
int ret = 0; int ret = 0;
if (filp->f_pos >> 32) if (ctx->pos >> 32)
goto out; return 0;
ret = ops->read(sb, inode->i_ino, inode->i_size, &dir); ret = ops->read(sb, inode->i_ino, inode->i_size, &dir);
if (ret) if (ret)
goto out; return ret;
switch ((unsigned long)filp->f_pos) { if (ctx->pos == 0) {
case 0: if (!dir_emit_dot(file, ctx))
if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
goto free_out; goto free_out;
filp->f_pos += 1; ctx->pos = 1;
}
case 1: if (ctx->pos == 1) {
if (filldir(dirent, "..", 2, 1, dir.parent_id, DT_DIR) < 0) if (!dir_emit(ctx, "..", 2, dir.parent_id, DT_DIR))
goto free_out; goto free_out;
filp->f_pos += 1; ctx->pos = 2;
default:
break;
} }
read_lock(&adfs_dir_lock); read_lock(&adfs_dir_lock);
ret = ops->setpos(&dir, filp->f_pos - 2); ret = ops->setpos(&dir, ctx->pos - 2);
if (ret) if (ret)
goto unlock_out; goto unlock_out;
while (ops->getnext(&dir, &obj) == 0) { while (ops->getnext(&dir, &obj) == 0) {
if (filldir(dirent, obj.name, obj.name_len, if (!dir_emit(ctx, obj.name, obj.name_len,
filp->f_pos, obj.file_id, DT_UNKNOWN) < 0) obj.file_id, DT_UNKNOWN))
goto unlock_out; break;
filp->f_pos += 1; ctx->pos++;
} }
unlock_out: unlock_out:
...@@ -65,8 +61,6 @@ adfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -65,8 +61,6 @@ adfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
free_out: free_out:
ops->free(&dir); ops->free(&dir);
out:
return ret; return ret;
} }
...@@ -192,7 +186,7 @@ adfs_dir_lookup_byname(struct inode *inode, struct qstr *name, struct object_inf ...@@ -192,7 +186,7 @@ adfs_dir_lookup_byname(struct inode *inode, struct qstr *name, struct object_inf
const struct file_operations adfs_dir_operations = { const struct file_operations adfs_dir_operations = {
.read = generic_read_dir, .read = generic_read_dir,
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
.readdir = adfs_readdir, .iterate = adfs_readdir,
.fsync = generic_file_fsync, .fsync = generic_file_fsync,
}; };
......
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