diff options
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index e4df1aaae2a2..c171767e242a 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "xfs_inum.h" | 22 | #include "xfs_inum.h" |
23 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
24 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
25 | #include "xfs_ag.h" | ||
25 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
26 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
27 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
@@ -432,12 +433,10 @@ xfs_dir2_block_addname( | |||
432 | */ | 433 | */ |
433 | int /* error */ | 434 | int /* error */ |
434 | xfs_dir2_block_getdents( | 435 | xfs_dir2_block_getdents( |
435 | xfs_trans_t *tp, /* transaction (NULL) */ | ||
436 | xfs_inode_t *dp, /* incore inode */ | 436 | xfs_inode_t *dp, /* incore inode */ |
437 | uio_t *uio, /* caller's buffer control */ | 437 | void *dirent, |
438 | int *eofp, /* eof reached? (out) */ | 438 | xfs_off_t *offset, |
439 | xfs_dirent_t *dbp, /* caller's buffer */ | 439 | filldir_t filldir) |
440 | xfs_dir2_put_t put) /* abi's formatting function */ | ||
441 | { | 440 | { |
442 | xfs_dir2_block_t *block; /* directory block structure */ | 441 | xfs_dir2_block_t *block; /* directory block structure */ |
443 | xfs_dabuf_t *bp; /* buffer for block */ | 442 | xfs_dabuf_t *bp; /* buffer for block */ |
@@ -447,31 +446,32 @@ xfs_dir2_block_getdents( | |||
447 | char *endptr; /* end of the data entries */ | 446 | char *endptr; /* end of the data entries */ |
448 | int error; /* error return value */ | 447 | int error; /* error return value */ |
449 | xfs_mount_t *mp; /* filesystem mount point */ | 448 | xfs_mount_t *mp; /* filesystem mount point */ |
450 | xfs_dir2_put_args_t p; /* arg package for put rtn */ | ||
451 | char *ptr; /* current data entry */ | 449 | char *ptr; /* current data entry */ |
452 | int wantoff; /* starting block offset */ | 450 | int wantoff; /* starting block offset */ |
451 | xfs_ino_t ino; | ||
452 | xfs_off_t cook; | ||
453 | 453 | ||
454 | mp = dp->i_mount; | 454 | mp = dp->i_mount; |
455 | /* | 455 | /* |
456 | * If the block number in the offset is out of range, we're done. | 456 | * If the block number in the offset is out of range, we're done. |
457 | */ | 457 | */ |
458 | if (xfs_dir2_dataptr_to_db(mp, uio->uio_offset) > mp->m_dirdatablk) { | 458 | if (xfs_dir2_dataptr_to_db(mp, *offset) > mp->m_dirdatablk) { |
459 | *eofp = 1; | ||
460 | return 0; | 459 | return 0; |
461 | } | 460 | } |
462 | /* | 461 | /* |
463 | * Can't read the block, give up, else get dabuf in bp. | 462 | * Can't read the block, give up, else get dabuf in bp. |
464 | */ | 463 | */ |
465 | if ((error = | 464 | error = xfs_da_read_buf(NULL, dp, mp->m_dirdatablk, -1, |
466 | xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &bp, XFS_DATA_FORK))) { | 465 | &bp, XFS_DATA_FORK); |
466 | if (error) | ||
467 | return error; | 467 | return error; |
468 | } | 468 | |
469 | ASSERT(bp != NULL); | 469 | ASSERT(bp != NULL); |
470 | /* | 470 | /* |
471 | * Extract the byte offset we start at from the seek pointer. | 471 | * Extract the byte offset we start at from the seek pointer. |
472 | * We'll skip entries before this. | 472 | * We'll skip entries before this. |
473 | */ | 473 | */ |
474 | wantoff = xfs_dir2_dataptr_to_off(mp, uio->uio_offset); | 474 | wantoff = xfs_dir2_dataptr_to_off(mp, *offset); |
475 | block = bp->data; | 475 | block = bp->data; |
476 | xfs_dir2_data_check(dp, bp); | 476 | xfs_dir2_data_check(dp, bp); |
477 | /* | 477 | /* |
@@ -480,9 +480,7 @@ xfs_dir2_block_getdents( | |||
480 | btp = xfs_dir2_block_tail_p(mp, block); | 480 | btp = xfs_dir2_block_tail_p(mp, block); |
481 | ptr = (char *)block->u; | 481 | ptr = (char *)block->u; |
482 | endptr = (char *)xfs_dir2_block_leaf_p(btp); | 482 | endptr = (char *)xfs_dir2_block_leaf_p(btp); |
483 | p.dbp = dbp; | 483 | |
484 | p.put = put; | ||
485 | p.uio = uio; | ||
486 | /* | 484 | /* |
487 | * Loop over the data portion of the block. | 485 | * Loop over the data portion of the block. |
488 | * Each object is a real entry (dep) or an unused one (dup). | 486 | * Each object is a real entry (dep) or an unused one (dup). |
@@ -508,33 +506,24 @@ xfs_dir2_block_getdents( | |||
508 | */ | 506 | */ |
509 | if ((char *)dep - (char *)block < wantoff) | 507 | if ((char *)dep - (char *)block < wantoff) |
510 | continue; | 508 | continue; |
511 | /* | ||
512 | * Set up argument structure for put routine. | ||
513 | */ | ||
514 | p.namelen = dep->namelen; | ||
515 | 509 | ||
516 | p.cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 510 | cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, |
517 | ptr - (char *)block); | 511 | ptr - (char *)block); |
518 | p.ino = be64_to_cpu(dep->inumber); | 512 | ino = be64_to_cpu(dep->inumber); |
519 | #if XFS_BIG_INUMS | 513 | #if XFS_BIG_INUMS |
520 | p.ino += mp->m_inoadd; | 514 | ino += mp->m_inoadd; |
521 | #endif | 515 | #endif |
522 | p.name = (char *)dep->name; | ||
523 | |||
524 | /* | ||
525 | * Put the entry in the caller's buffer. | ||
526 | */ | ||
527 | error = p.put(&p); | ||
528 | 516 | ||
529 | /* | 517 | /* |
530 | * If it didn't fit, set the final offset to here & return. | 518 | * If it didn't fit, set the final offset to here & return. |
531 | */ | 519 | */ |
532 | if (!p.done) { | 520 | if (filldir(dirent, dep->name, dep->namelen, cook, |
533 | uio->uio_offset = | 521 | ino, DT_UNKNOWN)) { |
534 | xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 522 | *offset = xfs_dir2_db_off_to_dataptr(mp, |
523 | mp->m_dirdatablk, | ||
535 | (char *)dep - (char *)block); | 524 | (char *)dep - (char *)block); |
536 | xfs_da_brelse(tp, bp); | 525 | xfs_da_brelse(NULL, bp); |
537 | return error; | 526 | return 0; |
538 | } | 527 | } |
539 | } | 528 | } |
540 | 529 | ||
@@ -542,13 +531,8 @@ xfs_dir2_block_getdents( | |||
542 | * Reached the end of the block. | 531 | * Reached the end of the block. |
543 | * Set the offset to a non-existent block 1 and return. | 532 | * Set the offset to a non-existent block 1 and return. |
544 | */ | 533 | */ |
545 | *eofp = 1; | 534 | *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0); |
546 | 535 | xfs_da_brelse(NULL, bp); | |
547 | uio->uio_offset = | ||
548 | xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0); | ||
549 | |||
550 | xfs_da_brelse(tp, bp); | ||
551 | |||
552 | return 0; | 536 | return 0; |
553 | } | 537 | } |
554 | 538 | ||