diff options
Diffstat (limited to 'lib/ext2fs/block.c')
-rw-r--r-- | lib/ext2fs/block.c | 99 |
1 files changed, 18 insertions, 81 deletions
diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c index 88ce2867..7685680d 100644 --- a/lib/ext2fs/block.c +++ b/lib/ext2fs/block.c @@ -59,25 +59,13 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - if ((ctx->fs->flags & EXT2_FLAG_IMAGE_FILE) && - (ctx->fs->io != ctx->fs->image_io)) { - ctx->errcode = 0; - memset(ctx->ind_buf, 0, ctx->fs->blocksize); - } else - ctx->errcode = io_channel_read_blk(ctx->fs->io, *ind_block, - 1, ctx->ind_buf); + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *ind_block, + ctx->ind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; return ret; } -#ifdef EXT2FS_ENABLE_SWAPFS - if (ctx->fs->flags & (EXT2_FLAG_SWAP_BYTES | - EXT2_FLAG_SWAP_BYTES_READ)) { - block_nr = (blk_t *) ctx->ind_buf; - for (i = 0; i < limit; i++, block_nr++) - *block_nr = ext2fs_swab32(*block_nr); - } -#endif + block_nr = (blk_t *) ctx->ind_buf; offset = 0; if (ctx->flags & BLOCK_FLAG_APPEND) { @@ -107,18 +95,9 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, offset += sizeof(blk_t); } } - if (!(ctx->fs->flags & EXT2_FLAG_IMAGE_FILE) && - (changed & BLOCK_CHANGED)) { -#ifdef EXT2FS_ENABLE_SWAPFS - if (ctx->fs->flags & (EXT2_FLAG_SWAP_BYTES | - EXT2_FLAG_SWAP_BYTES_WRITE)) { - block_nr = (blk_t *) ctx->ind_buf; - for (i = 0; i < limit; i++, block_nr++) - *block_nr = ext2fs_swab32(*block_nr); - } -#endif - ctx->errcode = io_channel_write_blk(ctx->fs->io, *ind_block, - 1, ctx->ind_buf); + if (changed & BLOCK_CHANGED) { + ctx->errcode = ext2fs_write_ind_block(ctx->fs, *ind_block, + ctx->ind_buf); if (ctx->errcode) ret |= BLOCK_ERROR | BLOCK_ABORT; } @@ -154,25 +133,13 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - if ((ctx->fs->flags & EXT2_FLAG_IMAGE_FILE) && - (ctx->fs->io != ctx->fs->image_io)) { - ctx->errcode = 0; - memset(ctx->dind_buf, 0, ctx->fs->blocksize); - } else - ctx->errcode = io_channel_read_blk(ctx->fs->io, *dind_block, - 1, ctx->dind_buf); + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *dind_block, + ctx->dind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; return ret; } -#ifdef EXT2FS_ENABLE_SWAPFS - if (ctx->fs->flags & (EXT2_FLAG_SWAP_BYTES | - EXT2_FLAG_SWAP_BYTES_READ)) { - block_nr = (blk_t *) ctx->dind_buf; - for (i = 0; i < limit; i++, block_nr++) - *block_nr = ext2fs_swab32(*block_nr); - } -#endif + block_nr = (blk_t *) ctx->dind_buf; offset = 0; if (ctx->flags & BLOCK_FLAG_APPEND) { @@ -204,18 +171,9 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, offset += sizeof(blk_t); } } - if (!(ctx->fs->flags & EXT2_FLAG_IMAGE_FILE) && - (changed & BLOCK_CHANGED)) { -#ifdef EXT2FS_ENABLE_SWAPFS - if (ctx->fs->flags & (EXT2_FLAG_SWAP_BYTES | - EXT2_FLAG_SWAP_BYTES_WRITE)) { - block_nr = (blk_t *) ctx->dind_buf; - for (i = 0; i < limit; i++, block_nr++) - *block_nr = ext2fs_swab32(*block_nr); - } -#endif - ctx->errcode = io_channel_write_blk(ctx->fs->io, *dind_block, - 1, ctx->dind_buf); + if (changed & BLOCK_CHANGED) { + ctx->errcode = ext2fs_write_ind_block(ctx->fs, *dind_block, + ctx->dind_buf); if (ctx->errcode) ret |= BLOCK_ERROR | BLOCK_ABORT; } @@ -251,25 +209,13 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - if ((ctx->fs->flags & EXT2_FLAG_IMAGE_FILE) && - (ctx->fs->io != ctx->fs->image_io)) { - ctx->errcode = 0; - memset(ctx->tind_buf, 0, ctx->fs->blocksize); - } else - ctx->errcode = io_channel_read_blk(ctx->fs->io, *tind_block, - 1, ctx->tind_buf); + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *tind_block, + ctx->tind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; return ret; } -#ifdef EXT2FS_ENABLE_SWAPFS - if (ctx->fs->flags & (EXT2_FLAG_SWAP_BYTES | - EXT2_FLAG_SWAP_BYTES_READ)) { - block_nr = (blk_t *) ctx->tind_buf; - for (i = 0; i < limit; i++, block_nr++) - *block_nr = ext2fs_swab32(*block_nr); - } -#endif + block_nr = (blk_t *) ctx->tind_buf; offset = 0; if (ctx->flags & BLOCK_FLAG_APPEND) { @@ -301,18 +247,9 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, offset += sizeof(blk_t); } } - if (!(ctx->fs->flags & EXT2_FLAG_IMAGE_FILE) && - (changed & BLOCK_CHANGED)) { -#ifdef EXT2FS_ENABLE_SWAPFS - if (ctx->fs->flags & (EXT2_FLAG_SWAP_BYTES | - EXT2_FLAG_SWAP_BYTES_WRITE)) { - block_nr = (blk_t *) ctx->tind_buf; - for (i = 0; i < limit; i++, block_nr++) - *block_nr = ext2fs_swab32(*block_nr); - } -#endif - ctx->errcode = io_channel_write_blk(ctx->fs->io, *tind_block, - 1, ctx->tind_buf); + if (changed & BLOCK_CHANGED) { + ctx->errcode = ext2fs_write_ind_block(ctx->fs, *tind_block, + ctx->tind_buf); if (ctx->errcode) ret |= BLOCK_ERROR | BLOCK_ABORT; } |