Fix resize inode handling on big endian systems, by adding new routines
that read/write indirect blocks, byte swapping them if necessary.

diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index 88ce286..7685680 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -59,25 +59,13 @@
 		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 @@
 			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 @@
 		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 @@
 			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 @@
 		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 @@
 			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;
 	}