aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-05-16 14:36:14 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-06-29 04:56:36 -0400
commit1616abe8419d8e4a16f081065c4ee83be488e8fe (patch)
tree666b5c16bf6ce53d8dde4c9773c683d4fe49f9a6 /fs/nilfs2
parentd55fea8ddb9a7eb8ce2f4cb859f402ea9968e61b (diff)
[readdir] convert nilfs2
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/dir.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index f30b017740a7..197a63e9d102 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -256,22 +256,18 @@ static void nilfs_set_de_type(struct nilfs_dir_entry *de, struct inode *inode)
256 de->file_type = nilfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; 256 de->file_type = nilfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
257} 257}
258 258
259static int nilfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 259static int nilfs_readdir(struct file *file, struct dir_context *ctx)
260{ 260{
261 loff_t pos = filp->f_pos; 261 loff_t pos = ctx->pos;
262 struct inode *inode = file_inode(filp); 262 struct inode *inode = file_inode(file);
263 struct super_block *sb = inode->i_sb; 263 struct super_block *sb = inode->i_sb;
264 unsigned int offset = pos & ~PAGE_CACHE_MASK; 264 unsigned int offset = pos & ~PAGE_CACHE_MASK;
265 unsigned long n = pos >> PAGE_CACHE_SHIFT; 265 unsigned long n = pos >> PAGE_CACHE_SHIFT;
266 unsigned long npages = dir_pages(inode); 266 unsigned long npages = dir_pages(inode);
267/* unsigned chunk_mask = ~(nilfs_chunk_size(inode)-1); */ 267/* unsigned chunk_mask = ~(nilfs_chunk_size(inode)-1); */
268 unsigned char *types = NULL;
269 int ret;
270 268
271 if (pos > inode->i_size - NILFS_DIR_REC_LEN(1)) 269 if (pos > inode->i_size - NILFS_DIR_REC_LEN(1))
272 goto success; 270 return 0;
273
274 types = nilfs_filetype_table;
275 271
276 for ( ; n < npages; n++, offset = 0) { 272 for ( ; n < npages; n++, offset = 0) {
277 char *kaddr, *limit; 273 char *kaddr, *limit;
@@ -281,9 +277,8 @@ static int nilfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
281 if (IS_ERR(page)) { 277 if (IS_ERR(page)) {
282 nilfs_error(sb, __func__, "bad page in #%lu", 278 nilfs_error(sb, __func__, "bad page in #%lu",
283 inode->i_ino); 279 inode->i_ino);
284 filp->f_pos += PAGE_CACHE_SIZE - offset; 280 ctx->pos += PAGE_CACHE_SIZE - offset;
285 ret = -EIO; 281 return -EIO;
286 goto done;
287 } 282 }
288 kaddr = page_address(page); 283 kaddr = page_address(page);
289 de = (struct nilfs_dir_entry *)(kaddr + offset); 284 de = (struct nilfs_dir_entry *)(kaddr + offset);
@@ -293,35 +288,28 @@ static int nilfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
293 if (de->rec_len == 0) { 288 if (de->rec_len == 0) {
294 nilfs_error(sb, __func__, 289 nilfs_error(sb, __func__,
295 "zero-length directory entry"); 290 "zero-length directory entry");
296 ret = -EIO;
297 nilfs_put_page(page); 291 nilfs_put_page(page);
298 goto done; 292 return -EIO;
299 } 293 }
300 if (de->inode) { 294 if (de->inode) {
301 int over; 295 unsigned char t;
302 unsigned char d_type = DT_UNKNOWN;
303 296
304 if (types && de->file_type < NILFS_FT_MAX) 297 if (de->file_type < NILFS_FT_MAX)
305 d_type = types[de->file_type]; 298 t = nilfs_filetype_table[de->file_type];
299 else
300 t = DT_UNKNOWN;
306 301
307 offset = (char *)de - kaddr; 302 if (!dir_emit(ctx, de->name, de->name_len,
308 over = filldir(dirent, de->name, de->name_len, 303 le64_to_cpu(de->inode), t)) {
309 (n<<PAGE_CACHE_SHIFT) | offset,
310 le64_to_cpu(de->inode), d_type);
311 if (over) {
312 nilfs_put_page(page); 304 nilfs_put_page(page);
313 goto success; 305 return 0;
314 } 306 }
315 } 307 }
316 filp->f_pos += nilfs_rec_len_from_disk(de->rec_len); 308 ctx->pos += nilfs_rec_len_from_disk(de->rec_len);
317 } 309 }
318 nilfs_put_page(page); 310 nilfs_put_page(page);
319 } 311 }
320 312 return 0;
321success:
322 ret = 0;
323done:
324 return ret;
325} 313}
326 314
327/* 315/*
@@ -678,7 +666,7 @@ not_empty:
678const struct file_operations nilfs_dir_operations = { 666const struct file_operations nilfs_dir_operations = {
679 .llseek = generic_file_llseek, 667 .llseek = generic_file_llseek,
680 .read = generic_read_dir, 668 .read = generic_read_dir,
681 .readdir = nilfs_readdir, 669 .iterate = nilfs_readdir,
682 .unlocked_ioctl = nilfs_ioctl, 670 .unlocked_ioctl = nilfs_ioctl,
683#ifdef CONFIG_COMPAT 671#ifdef CONFIG_COMPAT
684 .compat_ioctl = nilfs_compat_ioctl, 672 .compat_ioctl = nilfs_compat_ioctl,