diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-17 18:08:49 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-29 04:56:47 -0400 |
commit | 0312fa7ccd7bda2ce074799f4784c2d95d03a62c (patch) | |
tree | 6b1cc852aab18c0225982bd161d39a843f5b3d4a | |
parent | 6f7f231e7b4f819b912f848a33d946b54261483d (diff) |
[readdir] convert jffs2
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/jffs2/dir.c | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index acd46a4160cb..e3aac222472e 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/time.h> | 22 | #include <linux/time.h> |
23 | #include "nodelist.h" | 23 | #include "nodelist.h" |
24 | 24 | ||
25 | static int jffs2_readdir (struct file *, void *, filldir_t); | 25 | static int jffs2_readdir (struct file *, struct dir_context *); |
26 | 26 | ||
27 | static int jffs2_create (struct inode *,struct dentry *,umode_t, | 27 | static int jffs2_create (struct inode *,struct dentry *,umode_t, |
28 | bool); | 28 | bool); |
@@ -40,7 +40,7 @@ static int jffs2_rename (struct inode *, struct dentry *, | |||
40 | const struct file_operations jffs2_dir_operations = | 40 | const struct file_operations jffs2_dir_operations = |
41 | { | 41 | { |
42 | .read = generic_read_dir, | 42 | .read = generic_read_dir, |
43 | .readdir = jffs2_readdir, | 43 | .iterate = jffs2_readdir, |
44 | .unlocked_ioctl=jffs2_ioctl, | 44 | .unlocked_ioctl=jffs2_ioctl, |
45 | .fsync = jffs2_fsync, | 45 | .fsync = jffs2_fsync, |
46 | .llseek = generic_file_llseek, | 46 | .llseek = generic_file_llseek, |
@@ -114,60 +114,40 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | |||
114 | /***********************************************************************/ | 114 | /***********************************************************************/ |
115 | 115 | ||
116 | 116 | ||
117 | static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | 117 | static int jffs2_readdir(struct file *file, struct dir_context *ctx) |
118 | { | 118 | { |
119 | struct jffs2_inode_info *f; | 119 | struct inode *inode = file_inode(file); |
120 | struct inode *inode = file_inode(filp); | 120 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); |
121 | struct jffs2_full_dirent *fd; | 121 | struct jffs2_full_dirent *fd; |
122 | unsigned long offset, curofs; | 122 | unsigned long curofs = 1; |
123 | 123 | ||
124 | jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n", | 124 | jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n", inode->i_ino); |
125 | file_inode(filp)->i_ino); | ||
126 | 125 | ||
127 | f = JFFS2_INODE_INFO(inode); | 126 | if (!dir_emit_dots(file, ctx)) |
128 | 127 | return 0; | |
129 | offset = filp->f_pos; | ||
130 | |||
131 | if (offset == 0) { | ||
132 | jffs2_dbg(1, "Dirent 0: \".\", ino #%lu\n", inode->i_ino); | ||
133 | if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) | ||
134 | goto out; | ||
135 | offset++; | ||
136 | } | ||
137 | if (offset == 1) { | ||
138 | unsigned long pino = parent_ino(filp->f_path.dentry); | ||
139 | jffs2_dbg(1, "Dirent 1: \"..\", ino #%lu\n", pino); | ||
140 | if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0) | ||
141 | goto out; | ||
142 | offset++; | ||
143 | } | ||
144 | 128 | ||
145 | curofs=1; | ||
146 | mutex_lock(&f->sem); | 129 | mutex_lock(&f->sem); |
147 | for (fd = f->dents; fd; fd = fd->next) { | 130 | for (fd = f->dents; fd; fd = fd->next) { |
148 | |||
149 | curofs++; | 131 | curofs++; |
150 | /* First loop: curofs = 2; offset = 2 */ | 132 | /* First loop: curofs = 2; pos = 2 */ |
151 | if (curofs < offset) { | 133 | if (curofs < ctx->pos) { |
152 | jffs2_dbg(2, "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", | 134 | jffs2_dbg(2, "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", |
153 | fd->name, fd->ino, fd->type, curofs, offset); | 135 | fd->name, fd->ino, fd->type, curofs, (unsigned long)ctx->pos); |
154 | continue; | 136 | continue; |
155 | } | 137 | } |
156 | if (!fd->ino) { | 138 | if (!fd->ino) { |
157 | jffs2_dbg(2, "Skipping deletion dirent \"%s\"\n", | 139 | jffs2_dbg(2, "Skipping deletion dirent \"%s\"\n", |
158 | fd->name); | 140 | fd->name); |
159 | offset++; | 141 | ctx->pos++; |
160 | continue; | 142 | continue; |
161 | } | 143 | } |
162 | jffs2_dbg(2, "Dirent %ld: \"%s\", ino #%u, type %d\n", | 144 | jffs2_dbg(2, "Dirent %ld: \"%s\", ino #%u, type %d\n", |
163 | offset, fd->name, fd->ino, fd->type); | 145 | (unsigned long)ctx->pos, fd->name, fd->ino, fd->type); |
164 | if (filldir(dirent, fd->name, strlen(fd->name), offset, fd->ino, fd->type) < 0) | 146 | if (!dir_emit(ctx, fd->name, strlen(fd->name), fd->ino, fd->type)) |
165 | break; | 147 | break; |
166 | offset++; | 148 | ctx->pos++; |
167 | } | 149 | } |
168 | mutex_unlock(&f->sem); | 150 | mutex_unlock(&f->sem); |
169 | out: | ||
170 | filp->f_pos = offset; | ||
171 | return 0; | 151 | return 0; |
172 | } | 152 | } |
173 | 153 | ||