diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-08-12 20:49:36 +1000 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-12 16:39:56 -0500 |
commit | 4a8af273de63d9656559ba5289e91f40aae0441f (patch) | |
tree | ac3d22e894df58c38326bada04073d283c90dee5 /fs/xfs/xfs_dir2_block.c | |
parent | 1fd7115eda5661e872463694fc4a12821c4f914a (diff) |
xfs: move getdents code into it's own file
The directory readdir code is not used by userspace, but it is
intermingled with files that are shared with userspace. This makes
it difficult to compare the differences between the userspac eand
kernel files are the userspace files don't have the getdents code in
them. Move all the kernel getdents code to a separate file to bring
the shared content between userspace and kernel files closer
together.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 97 |
1 files changed, 1 insertions, 96 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index 5e7fbd72cf5..5e8400064fa 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c @@ -126,7 +126,7 @@ const struct xfs_buf_ops xfs_dir3_block_buf_ops = { .verify_write = xfs_dir3_block_write_verify, }; -static int +int xfs_dir3_block_read( struct xfs_trans *tp, struct xfs_inode *dp, @@ -565,101 +565,6 @@ xfs_dir2_block_addname( } /* - * Readdir for block directories. - */ -int /* error */ -xfs_dir2_block_getdents( - xfs_inode_t *dp, /* incore inode */ - struct dir_context *ctx) -{ - xfs_dir2_data_hdr_t *hdr; /* block header */ - struct xfs_buf *bp; /* buffer for block */ - xfs_dir2_block_tail_t *btp; /* block tail */ - xfs_dir2_data_entry_t *dep; /* block data entry */ - xfs_dir2_data_unused_t *dup; /* block unused entry */ - char *endptr; /* end of the data entries */ - int error; /* error return value */ - xfs_mount_t *mp; /* filesystem mount point */ - char *ptr; /* current data entry */ - int wantoff; /* starting block offset */ - xfs_off_t cook; - - mp = dp->i_mount; - /* - * If the block number in the offset is out of range, we're done. - */ - if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) - return 0; - - error = xfs_dir3_block_read(NULL, dp, &bp); - if (error) - return error; - - /* - * Extract the byte offset we start at from the seek pointer. - * We'll skip entries before this. - */ - wantoff = xfs_dir2_dataptr_to_off(mp, ctx->pos); - hdr = bp->b_addr; - xfs_dir3_data_check(dp, bp); - /* - * Set up values for the loop. - */ - btp = xfs_dir2_block_tail_p(mp, hdr); - ptr = (char *)xfs_dir3_data_entry_p(hdr); - endptr = (char *)xfs_dir2_block_leaf_p(btp); - - /* - * Loop over the data portion of the block. - * Each object is a real entry (dep) or an unused one (dup). - */ - while (ptr < endptr) { - dup = (xfs_dir2_data_unused_t *)ptr; - /* - * Unused, skip it. - */ - if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { - ptr += be16_to_cpu(dup->length); - continue; - } - - dep = (xfs_dir2_data_entry_t *)ptr; - - /* - * Bump pointer for the next iteration. - */ - ptr += xfs_dir2_data_entsize(dep->namelen); - /* - * The entry is before the desired starting point, skip it. - */ - if ((char *)dep - (char *)hdr < wantoff) - continue; - - cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, - (char *)dep - (char *)hdr); - - ctx->pos = cook & 0x7fffffff; - /* - * If it didn't fit, set the final offset to here & return. - */ - if (!dir_emit(ctx, (char *)dep->name, dep->namelen, - be64_to_cpu(dep->inumber), DT_UNKNOWN)) { - xfs_trans_brelse(NULL, bp); - return 0; - } - } - - /* - * Reached the end of the block. - * Set the offset to a non-existent block 1 and return. - */ - ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & - 0x7fffffff; - xfs_trans_brelse(NULL, bp); - return 0; -} - -/* * Log leaf entries from the block. */ static void |