2009-10-29 14:09:48

by Nick Dokos

[permalink] [raw]
Subject: [PATCH][64-bit e2fsprogs] 64-bit block number truncated in e2sck pass2.

The following patch resolves the problem that I reported last week - see


The > 2^32 block number of a directory was being truncated because the
old ext2fs_read_dir_block() routine was called. In addition to the
blk64_t, the new routine takes an additional flags argument (which is
ignored except in the BIG_ENDIAN case).

But this patch is incomplete: there is another instance of
ext2fs_read_dir_block() in pass1.c, in the routine check_is_really_dir()
- unfortunately that routine seems to be applicable only to block-based
inodes, not extent-based ones. The call to ext2fs_read_dir_block() looks
like this:

retval = ext2fs_read_dir_block(ctx->fs, inode->i_block[0], buf);

and there is mucking around with the i_block array beforehand, but no
provision for extents. The routine comes with the following comment:

* Check to see if the inode might really be a directory, despite i_mode
* This is a lot of complexity for something for which I'm not really
* convinced happens frequently in the wild. If for any reason this
* causes any problems, take this code out.
* [tytso:20070331.0827EDT]

So before rewriting it to deal with extents, I thought I'd ask the question:
is the routine worth keeping?



>From 99cd1625c4cf48eab97b947527fbf51e3bf7b9c5 Mon Sep 17 00:00:00 2001
From: Nick Dokos <[email protected]>
Date: Wed, 28 Oct 2009 23:28:51 -0400
Subject: [PATCH] 64-bit fix: ext2fs_read_dir_block() changed to ext2fs_read_dir_block3().

The former takes a blk_t, the latter a blk64_t argument. We also need
to pass the fs flags as an additional argument, although it's only used
in big endian architectures.

Signed-off-by: Nick Dokos <[email protected]>
e2fsck/pass2.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index b757131..7b75f83 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -780,7 +780,7 @@ static int check_dir_block(ext2_filsys fs,

old_op = ehandler_operation(_("reading directory block"));
- cd->pctx.errcode = ext2fs_read_dir_block(fs, block_nr, buf);
+ cd->pctx.errcode = ext2fs_read_dir_block3(fs, block_nr, buf, fs->flags);
if (cd->pctx.errcode == EXT2_ET_DIR_CORRUPTED)
cd->pctx.errcode = 0; /* We'll handle this ourselves */