aboutsummaryrefslogtreecommitdiffstats
path: root/fs/freevxfs/vxfs_lookup.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/freevxfs/vxfs_lookup.c')
-rw-r--r--fs/freevxfs/vxfs_lookup.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c
index 664b07a53870..25d4099a4aea 100644
--- a/fs/freevxfs/vxfs_lookup.c
+++ b/fs/freevxfs/vxfs_lookup.c
@@ -49,7 +49,7 @@
49 49
50 50
51static struct dentry * vxfs_lookup(struct inode *, struct dentry *, unsigned int); 51static struct dentry * vxfs_lookup(struct inode *, struct dentry *, unsigned int);
52static int vxfs_readdir(struct file *, void *, filldir_t); 52static int vxfs_readdir(struct file *, struct dir_context *);
53 53
54const struct inode_operations vxfs_dir_inode_ops = { 54const struct inode_operations vxfs_dir_inode_ops = {
55 .lookup = vxfs_lookup, 55 .lookup = vxfs_lookup,
@@ -58,7 +58,7 @@ const struct inode_operations vxfs_dir_inode_ops = {
58const struct file_operations vxfs_dir_operations = { 58const struct file_operations vxfs_dir_operations = {
59 .llseek = generic_file_llseek, 59 .llseek = generic_file_llseek,
60 .read = generic_read_dir, 60 .read = generic_read_dir,
61 .readdir = vxfs_readdir, 61 .iterate = vxfs_readdir,
62}; 62};
63 63
64 64
@@ -235,7 +235,7 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, unsigned int flags)
235 * Zero. 235 * Zero.
236 */ 236 */
237static int 237static int
238vxfs_readdir(struct file *fp, void *retp, filldir_t filler) 238vxfs_readdir(struct file *fp, struct dir_context *ctx)
239{ 239{
240 struct inode *ip = file_inode(fp); 240 struct inode *ip = file_inode(fp);
241 struct super_block *sbp = ip->i_sb; 241 struct super_block *sbp = ip->i_sb;
@@ -243,20 +243,17 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
243 u_long page, npages, block, pblocks, nblocks, offset; 243 u_long page, npages, block, pblocks, nblocks, offset;
244 loff_t pos; 244 loff_t pos;
245 245
246 switch ((long)fp->f_pos) { 246 if (ctx->pos == 0) {
247 case 0: 247 if (!dir_emit_dot(fp, ctx))
248 if (filler(retp, ".", 1, fp->f_pos, ip->i_ino, DT_DIR) < 0) 248 return 0;
249 goto out; 249 ctx->pos = 1;
250 fp->f_pos++;
251 /* fallthrough */
252 case 1:
253 if (filler(retp, "..", 2, fp->f_pos, VXFS_INO(ip)->vii_dotdot, DT_DIR) < 0)
254 goto out;
255 fp->f_pos++;
256 /* fallthrough */
257 } 250 }
258 251 if (ctx->pos == 1) {
259 pos = fp->f_pos - 2; 252 if (!dir_emit(ctx, "..", 2, VXFS_INO(ip)->vii_dotdot, DT_DIR))
253 return 0;
254 ctx->pos = 2;
255 }
256 pos = ctx->pos - 2;
260 257
261 if (pos > VXFS_DIRROUND(ip->i_size)) 258 if (pos > VXFS_DIRROUND(ip->i_size))
262 return 0; 259 return 0;
@@ -270,16 +267,16 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
270 block = (u_long)(pos >> sbp->s_blocksize_bits) % pblocks; 267 block = (u_long)(pos >> sbp->s_blocksize_bits) % pblocks;
271 268
272 for (; page < npages; page++, block = 0) { 269 for (; page < npages; page++, block = 0) {
273 caddr_t kaddr; 270 char *kaddr;
274 struct page *pp; 271 struct page *pp;
275 272
276 pp = vxfs_get_page(ip->i_mapping, page); 273 pp = vxfs_get_page(ip->i_mapping, page);
277 if (IS_ERR(pp)) 274 if (IS_ERR(pp))
278 continue; 275 continue;
279 kaddr = (caddr_t)page_address(pp); 276 kaddr = (char *)page_address(pp);
280 277
281 for (; block <= nblocks && block <= pblocks; block++) { 278 for (; block <= nblocks && block <= pblocks; block++) {
282 caddr_t baddr, limit; 279 char *baddr, *limit;
283 struct vxfs_dirblk *dbp; 280 struct vxfs_dirblk *dbp;
284 struct vxfs_direct *de; 281 struct vxfs_direct *de;
285 282
@@ -292,21 +289,18 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
292 (kaddr + offset) : 289 (kaddr + offset) :
293 (baddr + VXFS_DIRBLKOV(dbp))); 290 (baddr + VXFS_DIRBLKOV(dbp)));
294 291
295 for (; (caddr_t)de <= limit; de = vxfs_next_entry(de)) { 292 for (; (char *)de <= limit; de = vxfs_next_entry(de)) {
296 int over;
297
298 if (!de->d_reclen) 293 if (!de->d_reclen)
299 break; 294 break;
300 if (!de->d_ino) 295 if (!de->d_ino)
301 continue; 296 continue;
302 297
303 offset = (caddr_t)de - kaddr; 298 offset = (char *)de - kaddr;
304 over = filler(retp, de->d_name, de->d_namelen, 299 ctx->pos = ((page << PAGE_CACHE_SHIFT) | offset) + 2;
305 ((page << PAGE_CACHE_SHIFT) | offset) + 2, 300 if (!dir_emit(ctx, de->d_name, de->d_namelen,
306 de->d_ino, DT_UNKNOWN); 301 de->d_ino, DT_UNKNOWN)) {
307 if (over) {
308 vxfs_put_page(pp); 302 vxfs_put_page(pp);
309 goto done; 303 return 0;
310 } 304 }
311 } 305 }
312 offset = 0; 306 offset = 0;
@@ -314,9 +308,6 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
314 vxfs_put_page(pp); 308 vxfs_put_page(pp);
315 offset = 0; 309 offset = 0;
316 } 310 }
317 311 ctx->pos = ((page << PAGE_CACHE_SHIFT) | offset) + 2;
318done:
319 fp->f_pos = ((page << PAGE_CACHE_SHIFT) | offset) + 2;
320out:
321 return 0; 312 return 0;
322} 313}