aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-05-17 17:30:10 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-06-29 04:56:44 -0400
commit2638ffbac9e2f411e911ff8194dc8d69c46f9f78 (patch)
tree5437e8e490971f2d80d618d3d87849149b9b8eb6
parent46d0733801e631b9b5b65323507b06fb3809df4c (diff)
[readdir] convert adfs
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/adfs/dir.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 9cf874ce8336..ade28bb058e3 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -17,47 +17,43 @@
17static DEFINE_RWLOCK(adfs_dir_lock); 17static DEFINE_RWLOCK(adfs_dir_lock);
18 18
19static int 19static int
20adfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 20adfs_readdir(struct file *file, struct dir_context *ctx)
21{ 21{
22 struct inode *inode = file_inode(filp); 22 struct inode *inode = file_inode(file);
23 struct super_block *sb = inode->i_sb; 23 struct super_block *sb = inode->i_sb;
24 struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir; 24 struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
25 struct object_info obj; 25 struct object_info obj;
26 struct adfs_dir dir; 26 struct adfs_dir dir;
27 int ret = 0; 27 int ret = 0;
28 28
29 if (filp->f_pos >> 32) 29 if (ctx->pos >> 32)
30 goto out; 30 return 0;
31 31
32 ret = ops->read(sb, inode->i_ino, inode->i_size, &dir); 32 ret = ops->read(sb, inode->i_ino, inode->i_size, &dir);
33 if (ret) 33 if (ret)
34 goto out; 34 return ret;
35 35
36 switch ((unsigned long)filp->f_pos) { 36 if (ctx->pos == 0) {
37 case 0: 37 if (!dir_emit_dot(file, ctx))
38 if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0)
39 goto free_out; 38 goto free_out;
40 filp->f_pos += 1; 39 ctx->pos = 1;
41 40 }
42 case 1: 41 if (ctx->pos == 1) {
43 if (filldir(dirent, "..", 2, 1, dir.parent_id, DT_DIR) < 0) 42 if (!dir_emit(ctx, "..", 2, dir.parent_id, DT_DIR))
44 goto free_out; 43 goto free_out;
45 filp->f_pos += 1; 44 ctx->pos = 2;
46
47 default:
48 break;
49 } 45 }
50 46
51 read_lock(&adfs_dir_lock); 47 read_lock(&adfs_dir_lock);
52 48
53 ret = ops->setpos(&dir, filp->f_pos - 2); 49 ret = ops->setpos(&dir, ctx->pos - 2);
54 if (ret) 50 if (ret)
55 goto unlock_out; 51 goto unlock_out;
56 while (ops->getnext(&dir, &obj) == 0) { 52 while (ops->getnext(&dir, &obj) == 0) {
57 if (filldir(dirent, obj.name, obj.name_len, 53 if (!dir_emit(ctx, obj.name, obj.name_len,
58 filp->f_pos, obj.file_id, DT_UNKNOWN) < 0) 54 obj.file_id, DT_UNKNOWN))
59 goto unlock_out; 55 break;
60 filp->f_pos += 1; 56 ctx->pos++;
61 } 57 }
62 58
63unlock_out: 59unlock_out:
@@ -65,8 +61,6 @@ unlock_out:
65 61
66free_out: 62free_out:
67 ops->free(&dir); 63 ops->free(&dir);
68
69out:
70 return ret; 64 return ret;
71} 65}
72 66
@@ -192,7 +186,7 @@ out:
192const struct file_operations adfs_dir_operations = { 186const struct file_operations adfs_dir_operations = {
193 .read = generic_read_dir, 187 .read = generic_read_dir,
194 .llseek = generic_file_llseek, 188 .llseek = generic_file_llseek,
195 .readdir = adfs_readdir, 189 .iterate = adfs_readdir,
196 .fsync = generic_file_fsync, 190 .fsync = generic_file_fsync,
197}; 191};
198 192