aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-05-22 17:07:56 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-06-29 04:57:00 -0400
commitb8227554c951eb144e975c5e741d33f29c29596f (patch)
treed980fa8d88fd7bf4a1b7a5ac02d29dbc95fc7200 /fs
parent9cdda8d31ffb87ba688f91104be200e2a96a38cd (diff)
[readdir] convert xfs
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_dir2.c13
-rw-r--r--fs/xfs/xfs_dir2_block.c17
-rw-r--r--fs/xfs/xfs_dir2_leaf.c18
-rw-r--r--fs/xfs/xfs_dir2_priv.h11
-rw-r--r--fs/xfs/xfs_dir2_sf.c31
-rw-r--r--fs/xfs/xfs_file.c12
-rw-r--r--fs/xfs/xfs_vnodeops.h3
7 files changed, 44 insertions, 61 deletions
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index b26a50f9921d..8f023dee404d 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -368,10 +368,8 @@ xfs_dir_removename(
368int 368int
369xfs_readdir( 369xfs_readdir(
370 xfs_inode_t *dp, 370 xfs_inode_t *dp,
371 void *dirent, 371 struct dir_context *ctx,
372 size_t bufsize, 372 size_t bufsize)
373 xfs_off_t *offset,
374 filldir_t filldir)
375{ 373{
376 int rval; /* return value */ 374 int rval; /* return value */
377 int v; /* type-checking value */ 375 int v; /* type-checking value */
@@ -385,14 +383,13 @@ xfs_readdir(
385 XFS_STATS_INC(xs_dir_getdents); 383 XFS_STATS_INC(xs_dir_getdents);
386 384
387 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 385 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
388 rval = xfs_dir2_sf_getdents(dp, dirent, offset, filldir); 386 rval = xfs_dir2_sf_getdents(dp, ctx);
389 else if ((rval = xfs_dir2_isblock(NULL, dp, &v))) 387 else if ((rval = xfs_dir2_isblock(NULL, dp, &v)))
390 ; 388 ;
391 else if (v) 389 else if (v)
392 rval = xfs_dir2_block_getdents(dp, dirent, offset, filldir); 390 rval = xfs_dir2_block_getdents(dp, ctx);
393 else 391 else
394 rval = xfs_dir2_leaf_getdents(dp, dirent, bufsize, offset, 392 rval = xfs_dir2_leaf_getdents(dp, ctx, bufsize);
395 filldir);
396 return rval; 393 return rval;
397} 394}
398 395
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index e59f5fc816fe..09aea0247d96 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -569,9 +569,7 @@ xfs_dir2_block_addname(
569int /* error */ 569int /* error */
570xfs_dir2_block_getdents( 570xfs_dir2_block_getdents(
571 xfs_inode_t *dp, /* incore inode */ 571 xfs_inode_t *dp, /* incore inode */
572 void *dirent, 572 struct dir_context *ctx)
573 xfs_off_t *offset,
574 filldir_t filldir)
575{ 573{
576 xfs_dir2_data_hdr_t *hdr; /* block header */ 574 xfs_dir2_data_hdr_t *hdr; /* block header */
577 struct xfs_buf *bp; /* buffer for block */ 575 struct xfs_buf *bp; /* buffer for block */
@@ -589,7 +587,7 @@ xfs_dir2_block_getdents(
589 /* 587 /*
590 * If the block number in the offset is out of range, we're done. 588 * If the block number in the offset is out of range, we're done.
591 */ 589 */
592 if (xfs_dir2_dataptr_to_db(mp, *offset) > mp->m_dirdatablk) 590 if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk)
593 return 0; 591 return 0;
594 592
595 error = xfs_dir3_block_read(NULL, dp, &bp); 593 error = xfs_dir3_block_read(NULL, dp, &bp);
@@ -600,7 +598,7 @@ xfs_dir2_block_getdents(
600 * Extract the byte offset we start at from the seek pointer. 598 * Extract the byte offset we start at from the seek pointer.
601 * We'll skip entries before this. 599 * We'll skip entries before this.
602 */ 600 */
603 wantoff = xfs_dir2_dataptr_to_off(mp, *offset); 601 wantoff = xfs_dir2_dataptr_to_off(mp, ctx->pos);
604 hdr = bp->b_addr; 602 hdr = bp->b_addr;
605 xfs_dir3_data_check(dp, bp); 603 xfs_dir3_data_check(dp, bp);
606 /* 604 /*
@@ -639,13 +637,12 @@ xfs_dir2_block_getdents(
639 cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 637 cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
640 (char *)dep - (char *)hdr); 638 (char *)dep - (char *)hdr);
641 639
640 ctx->pos = cook & 0x7fffffff;
642 /* 641 /*
643 * If it didn't fit, set the final offset to here & return. 642 * If it didn't fit, set the final offset to here & return.
644 */ 643 */
645 if (filldir(dirent, (char *)dep->name, dep->namelen, 644 if (!dir_emit(ctx, (char *)dep->name, dep->namelen,
646 cook & 0x7fffffff, be64_to_cpu(dep->inumber), 645 be64_to_cpu(dep->inumber), DT_UNKNOWN)) {
647 DT_UNKNOWN)) {
648 *offset = cook & 0x7fffffff;
649 xfs_trans_brelse(NULL, bp); 646 xfs_trans_brelse(NULL, bp);
650 return 0; 647 return 0;
651 } 648 }
@@ -655,7 +652,7 @@ xfs_dir2_block_getdents(
655 * Reached the end of the block. 652 * Reached the end of the block.
656 * Set the offset to a non-existent block 1 and return. 653 * Set the offset to a non-existent block 1 and return.
657 */ 654 */
658 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & 655 ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) &
659 0x7fffffff; 656 0x7fffffff;
660 xfs_trans_brelse(NULL, bp); 657 xfs_trans_brelse(NULL, bp);
661 return 0; 658 return 0;
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index da71a1819d78..e0cc1243a8aa 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -1300,10 +1300,8 @@ out:
1300int /* error */ 1300int /* error */
1301xfs_dir2_leaf_getdents( 1301xfs_dir2_leaf_getdents(
1302 xfs_inode_t *dp, /* incore directory inode */ 1302 xfs_inode_t *dp, /* incore directory inode */
1303 void *dirent, 1303 struct dir_context *ctx,
1304 size_t bufsize, 1304 size_t bufsize)
1305 xfs_off_t *offset,
1306 filldir_t filldir)
1307{ 1305{
1308 struct xfs_buf *bp = NULL; /* data block buffer */ 1306 struct xfs_buf *bp = NULL; /* data block buffer */
1309 xfs_dir2_data_hdr_t *hdr; /* data block header */ 1307 xfs_dir2_data_hdr_t *hdr; /* data block header */
@@ -1322,7 +1320,7 @@ xfs_dir2_leaf_getdents(
1322 * If the offset is at or past the largest allowed value, 1320 * If the offset is at or past the largest allowed value,
1323 * give up right away. 1321 * give up right away.
1324 */ 1322 */
1325 if (*offset >= XFS_DIR2_MAX_DATAPTR) 1323 if (ctx->pos >= XFS_DIR2_MAX_DATAPTR)
1326 return 0; 1324 return 0;
1327 1325
1328 mp = dp->i_mount; 1326 mp = dp->i_mount;
@@ -1343,7 +1341,7 @@ xfs_dir2_leaf_getdents(
1343 * Inside the loop we keep the main offset value as a byte offset 1341 * Inside the loop we keep the main offset value as a byte offset
1344 * in the directory file. 1342 * in the directory file.
1345 */ 1343 */
1346 curoff = xfs_dir2_dataptr_to_byte(mp, *offset); 1344 curoff = xfs_dir2_dataptr_to_byte(mp, ctx->pos);
1347 1345
1348 /* 1346 /*
1349 * Force this conversion through db so we truncate the offset 1347 * Force this conversion through db so we truncate the offset
@@ -1444,8 +1442,8 @@ xfs_dir2_leaf_getdents(
1444 dep = (xfs_dir2_data_entry_t *)ptr; 1442 dep = (xfs_dir2_data_entry_t *)ptr;
1445 length = xfs_dir2_data_entsize(dep->namelen); 1443 length = xfs_dir2_data_entsize(dep->namelen);
1446 1444
1447 if (filldir(dirent, (char *)dep->name, dep->namelen, 1445 ctx->pos = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff;
1448 xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff, 1446 if (!dir_emit(ctx, (char *)dep->name, dep->namelen,
1449 be64_to_cpu(dep->inumber), DT_UNKNOWN)) 1447 be64_to_cpu(dep->inumber), DT_UNKNOWN))
1450 break; 1448 break;
1451 1449
@@ -1462,9 +1460,9 @@ xfs_dir2_leaf_getdents(
1462 * All done. Set output offset value to current offset. 1460 * All done. Set output offset value to current offset.
1463 */ 1461 */
1464 if (curoff > xfs_dir2_dataptr_to_byte(mp, XFS_DIR2_MAX_DATAPTR)) 1462 if (curoff > xfs_dir2_dataptr_to_byte(mp, XFS_DIR2_MAX_DATAPTR))
1465 *offset = XFS_DIR2_MAX_DATAPTR & 0x7fffffff; 1463 ctx->pos = XFS_DIR2_MAX_DATAPTR & 0x7fffffff;
1466 else 1464 else
1467 *offset = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff; 1465 ctx->pos = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff;
1468 kmem_free(map_info); 1466 kmem_free(map_info);
1469 if (bp) 1467 if (bp)
1470 xfs_trans_brelse(NULL, bp); 1468 xfs_trans_brelse(NULL, bp);
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 7cf573c88aad..0511cda4a712 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -33,8 +33,8 @@ extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
33extern const struct xfs_buf_ops xfs_dir3_block_buf_ops; 33extern const struct xfs_buf_ops xfs_dir3_block_buf_ops;
34 34
35extern int xfs_dir2_block_addname(struct xfs_da_args *args); 35extern int xfs_dir2_block_addname(struct xfs_da_args *args);
36extern int xfs_dir2_block_getdents(struct xfs_inode *dp, void *dirent, 36extern int xfs_dir2_block_getdents(struct xfs_inode *dp,
37 xfs_off_t *offset, filldir_t filldir); 37 struct dir_context *ctx);
38extern int xfs_dir2_block_lookup(struct xfs_da_args *args); 38extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
39extern int xfs_dir2_block_removename(struct xfs_da_args *args); 39extern int xfs_dir2_block_removename(struct xfs_da_args *args);
40extern int xfs_dir2_block_replace(struct xfs_da_args *args); 40extern int xfs_dir2_block_replace(struct xfs_da_args *args);
@@ -91,8 +91,8 @@ extern void xfs_dir3_leaf_compact(struct xfs_da_args *args,
91extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr, 91extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,
92 struct xfs_dir2_leaf_entry *ents, int *indexp, 92 struct xfs_dir2_leaf_entry *ents, int *indexp,
93 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); 93 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
94extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, void *dirent, 94extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, struct dir_context *ctx,
95 size_t bufsize, xfs_off_t *offset, filldir_t filldir); 95 size_t bufsize);
96extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, 96extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno,
97 struct xfs_buf **bpp, __uint16_t magic); 97 struct xfs_buf **bpp, __uint16_t magic);
98extern void xfs_dir3_leaf_log_ents(struct xfs_trans *tp, struct xfs_buf *bp, 98extern void xfs_dir3_leaf_log_ents(struct xfs_trans *tp, struct xfs_buf *bp,
@@ -153,8 +153,7 @@ extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
153 int size, xfs_dir2_sf_hdr_t *sfhp); 153 int size, xfs_dir2_sf_hdr_t *sfhp);
154extern int xfs_dir2_sf_addname(struct xfs_da_args *args); 154extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
155extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); 155extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
156extern int xfs_dir2_sf_getdents(struct xfs_inode *dp, void *dirent, 156extern int xfs_dir2_sf_getdents(struct xfs_inode *dp, struct dir_context *ctx);
157 xfs_off_t *offset, filldir_t filldir);
158extern int xfs_dir2_sf_lookup(struct xfs_da_args *args); 157extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
159extern int xfs_dir2_sf_removename(struct xfs_da_args *args); 158extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
160extern int xfs_dir2_sf_replace(struct xfs_da_args *args); 159extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 6157424dbf8f..97676a347da1 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -768,9 +768,7 @@ xfs_dir2_sf_create(
768int /* error */ 768int /* error */
769xfs_dir2_sf_getdents( 769xfs_dir2_sf_getdents(
770 xfs_inode_t *dp, /* incore directory inode */ 770 xfs_inode_t *dp, /* incore directory inode */
771 void *dirent, 771 struct dir_context *ctx)
772 xfs_off_t *offset,
773 filldir_t filldir)
774{ 772{
775 int i; /* shortform entry number */ 773 int i; /* shortform entry number */
776 xfs_mount_t *mp; /* filesystem mount point */ 774 xfs_mount_t *mp; /* filesystem mount point */
@@ -802,7 +800,7 @@ xfs_dir2_sf_getdents(
802 /* 800 /*
803 * If the block number in the offset is out of range, we're done. 801 * If the block number in the offset is out of range, we're done.
804 */ 802 */
805 if (xfs_dir2_dataptr_to_db(mp, *offset) > mp->m_dirdatablk) 803 if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk)
806 return 0; 804 return 0;
807 805
808 /* 806 /*
@@ -819,22 +817,20 @@ xfs_dir2_sf_getdents(
819 /* 817 /*
820 * Put . entry unless we're starting past it. 818 * Put . entry unless we're starting past it.
821 */ 819 */
822 if (*offset <= dot_offset) { 820 if (ctx->pos <= dot_offset) {
823 if (filldir(dirent, ".", 1, dot_offset & 0x7fffffff, dp->i_ino, DT_DIR)) { 821 ctx->pos = dot_offset & 0x7fffffff;
824 *offset = dot_offset & 0x7fffffff; 822 if (!dir_emit(ctx, ".", 1, dp->i_ino, DT_DIR))
825 return 0; 823 return 0;
826 }
827 } 824 }
828 825
829 /* 826 /*
830 * Put .. entry unless we're starting past it. 827 * Put .. entry unless we're starting past it.
831 */ 828 */
832 if (*offset <= dotdot_offset) { 829 if (ctx->pos <= dotdot_offset) {
833 ino = xfs_dir2_sf_get_parent_ino(sfp); 830 ino = xfs_dir2_sf_get_parent_ino(sfp);
834 if (filldir(dirent, "..", 2, dotdot_offset & 0x7fffffff, ino, DT_DIR)) { 831 ctx->pos = dotdot_offset & 0x7fffffff;
835 *offset = dotdot_offset & 0x7fffffff; 832 if (!dir_emit(ctx, "..", 2, ino, DT_DIR))
836 return 0; 833 return 0;
837 }
838 } 834 }
839 835
840 /* 836 /*
@@ -845,21 +841,20 @@ xfs_dir2_sf_getdents(
845 off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 841 off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
846 xfs_dir2_sf_get_offset(sfep)); 842 xfs_dir2_sf_get_offset(sfep));
847 843
848 if (*offset > off) { 844 if (ctx->pos > off) {
849 sfep = xfs_dir2_sf_nextentry(sfp, sfep); 845 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
850 continue; 846 continue;
851 } 847 }
852 848
853 ino = xfs_dir2_sfe_get_ino(sfp, sfep); 849 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
854 if (filldir(dirent, (char *)sfep->name, sfep->namelen, 850 ctx->pos = off & 0x7fffffff;
855 off & 0x7fffffff, ino, DT_UNKNOWN)) { 851 if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
856 *offset = off & 0x7fffffff; 852 ino, DT_UNKNOWN))
857 return 0; 853 return 0;
858 }
859 sfep = xfs_dir2_sf_nextentry(sfp, sfep); 854 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
860 } 855 }
861 856
862 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & 857 ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) &
863 0x7fffffff; 858 0x7fffffff;
864 return 0; 859 return 0;
865} 860}
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index a5f2042aec8b..0ad2b95fca12 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -906,11 +906,10 @@ xfs_file_release(
906 906
907STATIC int 907STATIC int
908xfs_file_readdir( 908xfs_file_readdir(
909 struct file *filp, 909 struct file *file,
910 void *dirent, 910 struct dir_context *ctx)
911 filldir_t filldir)
912{ 911{
913 struct inode *inode = file_inode(filp); 912 struct inode *inode = file_inode(file);
914 xfs_inode_t *ip = XFS_I(inode); 913 xfs_inode_t *ip = XFS_I(inode);
915 int error; 914 int error;
916 size_t bufsize; 915 size_t bufsize;
@@ -929,8 +928,7 @@ xfs_file_readdir(
929 */ 928 */
930 bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size); 929 bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size);
931 930
932 error = xfs_readdir(ip, dirent, bufsize, 931 error = xfs_readdir(ip, ctx, bufsize);
933 (xfs_off_t *)&filp->f_pos, filldir);
934 if (error) 932 if (error)
935 return -error; 933 return -error;
936 return 0; 934 return 0;
@@ -1432,7 +1430,7 @@ const struct file_operations xfs_file_operations = {
1432const struct file_operations xfs_dir_file_operations = { 1430const struct file_operations xfs_dir_file_operations = {
1433 .open = xfs_dir_open, 1431 .open = xfs_dir_open,
1434 .read = generic_read_dir, 1432 .read = generic_read_dir,
1435 .readdir = xfs_file_readdir, 1433 .iterate = xfs_file_readdir,
1436 .llseek = generic_file_llseek, 1434 .llseek = generic_file_llseek,
1437 .unlocked_ioctl = xfs_file_ioctl, 1435 .unlocked_ioctl = xfs_file_ioctl,
1438#ifdef CONFIG_COMPAT 1436#ifdef CONFIG_COMPAT
diff --git a/fs/xfs/xfs_vnodeops.h b/fs/xfs/xfs_vnodeops.h
index 5163022d9808..38c67c34d73f 100644
--- a/fs/xfs/xfs_vnodeops.h
+++ b/fs/xfs/xfs_vnodeops.h
@@ -31,8 +31,7 @@ int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
31 struct xfs_inode *ip); 31 struct xfs_inode *ip);
32int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip, 32int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip,
33 struct xfs_name *target_name); 33 struct xfs_name *target_name);
34int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, 34int xfs_readdir(struct xfs_inode *dp, struct dir_context *ctx, size_t bufsize);
35 xfs_off_t *offset, filldir_t filldir);
36int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name, 35int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name,
37 const char *target_path, umode_t mode, struct xfs_inode **ipp); 36 const char *target_path, umode_t mode, struct xfs_inode **ipp);
38int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state); 37int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state);