From 7bef6d52125ef3f1ef07d9da71a13546f6843c56 Mon Sep 17 00:00:00 2001 From: Kit Westneat Date: Mon, 2 Dec 2013 19:11:52 -0500 Subject: [PATCH] e2fsck: use ext2fs_write_dir_block3() instead of ext2fs_write_dir_block() The use of ext2fs_write_dir_block() meant that attempts to fix deleted/unused inodes in a directory would not be fixed for file systems with 64-bit block numbers. (And some random block with the high 32-bits cleared would get corrupted.) Fix a similar problem when expanding directories and when creating the lost+found dirctory. Signed-off-by: Kit Westneat Signed-off-by: "Theodore Ts'o" Reviewed-by: Darrick J. Wong --- e2fsck/pass2.c | 4 ++-- e2fsck/pass3.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index bceadfe6c..f2ac2ddff 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -1132,7 +1132,7 @@ out_htree: } } if (dir_modified) { - cd->pctx.errcode = ext2fs_write_dir_block(fs, block_nr, buf); + cd->pctx.errcode = ext2fs_write_dir_block3(fs, block_nr, buf, 0); if (cd->pctx.errcode) { if (!fix_problem(ctx, PR_2_WRITE_DIRBLOCK, &cd->pctx)) @@ -1455,7 +1455,7 @@ static int allocate_dir_block(e2fsck_t ctx, return 1; } - pctx->errcode = ext2fs_write_dir_block(fs, blk, block); + pctx->errcode = ext2fs_write_dir_block3(fs, blk, block, 0); ext2fs_free_mem(&block); if (pctx->errcode) { pctx->str = "ext2fs_write_dir_block"; diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c index e358bb20a..926f462f6 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -198,9 +198,9 @@ static void check_root(e2fsck_t ctx) return; } - pctx.errcode = ext2fs_write_dir_block(fs, blk, block); + pctx.errcode = ext2fs_write_dir_block3(fs, blk, block, 0); if (pctx.errcode) { - pctx.str = "ext2fs_write_dir_block"; + pctx.str = "ext2fs_write_dir_block3"; fix_problem(ctx, PR_3_CREATE_ROOT_ERROR, &pctx); ctx->flags |= E2F_FLAG_ABORT; return; @@ -444,7 +444,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix) return 0; } - retval = ext2fs_write_dir_block(fs, blk, block); + retval = ext2fs_write_dir_block3(fs, blk, block, 0); ext2fs_free_mem(&block); if (retval) { pctx.errcode = retval; @@ -725,7 +725,7 @@ static int expand_dir_proc(ext2_filsys fs, return BLOCK_ABORT; } es->num--; - retval = ext2fs_write_dir_block(fs, new_blk, block); + retval = ext2fs_write_dir_block3(fs, new_blk, block, 0); } else { retval = ext2fs_get_mem(fs->blocksize, &block); if (retval) { -- 2.39.2