@@ -180,7 +180,7 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
if (inode->i_flags & EXT4_EXTENTS_FL) {
if (inode->i_size > fs->blocksize)
return 0;
- if (ext2fs_extent_open(fs, ino, &handle))
+ if (ext2fs_extent_open2(fs, ino, inode, &handle))
return 0;
i = 0;
if (ext2fs_extent_get_info(handle, &info) ||
@@ -1769,7 +1769,7 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
ext2_ino_t ino = pctx->ino;
errcode_t retval;
- pctx->errcode = ext2fs_extent_open(fs, ino, &ehandle);
+ pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle);
if (pctx->errcode &&
fix_problem(ctx, PR_1_READ_EXTENT, pctx)) {
e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks_extents");
@@ -367,7 +367,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
int uninit;
unsigned int j;
- ctx.errcode = ext2fs_extent_open(fs, ino, &handle);
+ ctx.errcode = ext2fs_extent_open2(fs, ino, &inode, &handle);
if (ctx.errcode)
goto abort_exit;
@@ -160,7 +160,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
struct ext2fs_extent extent;
unsigned int offset;
- retval = ext2fs_extent_open(fs, ino, &handle);
+ retval = ext2fs_extent_open2(fs, ino, inode, &handle);
if (retval)
goto done;
if (bmap_flags & BMAP_SET) {
@@ -839,6 +839,9 @@ extern errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk,
extern errcode_t ext2fs_extent_header_verify(void *ptr, int size);
extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
ext2_extent_handle_t *handle);
+extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
+ struct ext2_inode *inode,
+ ext2_extent_handle_t *ret_handle);
extern void ext2fs_extent_free(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
int flags, struct ext2fs_extent *extent);
@@ -180,32 +180,44 @@ extern void ext2fs_extent_free(ext2_extent_handle_t handle)
extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
ext2_extent_handle_t *ret_handle)
{
+ return ext2fs_extent_open2(fs, ino, NULL, ret_handle);
+}
+
+extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
+ struct ext2_inode *inode,
+ ext2_extent_handle_t *ret_handle)
+{
struct ext2_extent_handle *handle;
errcode_t retval;
- int isize = EXT2_INODE_SIZE(fs->super);
int i;
struct ext3_extent_header *eh;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
- if ((ino == 0) || (ino > fs->super->s_inodes_count))
- return EXT2_ET_BAD_INODE_NUM;
+ if (!inode)
+ if ((ino == 0) || (ino > fs->super->s_inodes_count))
+ return EXT2_ET_BAD_INODE_NUM;
retval = ext2fs_get_mem(sizeof(struct ext2_extent_handle), &handle);
if (retval)
return retval;
memset(handle, 0, sizeof(struct ext2_extent_handle));
- retval = ext2fs_get_mem(isize, &handle->inode);
+ retval = ext2fs_get_mem(sizeof(struct ext2_inode), &handle->inode);
if (retval)
goto errout;
handle->ino = ino;
handle->fs = fs;
- retval = ext2fs_read_inode_full(fs, ino, handle->inode, isize);
- if (retval)
- goto errout;
+ if (inode) {
+ memcpy(handle->inode, inode, sizeof(struct ext2_inode));
+ }
+ else {
+ retval = ext2fs_read_inode(fs, ino, handle->inode);
+ if (retval)
+ goto errout;
+ }
eh = (struct ext3_extent_header *) &handle->inode->i_block[0];