From 71d521c6097f1c2588fb0b13f43968371d4bfabb Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 1 Jun 2001 19:29:36 +0000 Subject: [PATCH] ChangeLog, pass1.c, pass1b.c: pass1.c (pass1_get_blocks, pass1_read_inode, pass1_write_inode, pass1_check_directory): Add a safety check to make sure ctx->stashed_inode is non-zero. pass1b.c (pass1b): Use e2fsck_use_inode_shortcuts() to disable the inode shortcut processing, instead of manually clearing only half of the function pointers that needed to be NULL'ed out. This caused nasty bugs if the last inode in the filesystem needed dup block processing. pass1b.c (clone_file_block): When cloning a directory's metadata block, don't try to update the directory block list database, since indirect blocks aren't stored in the database and the resulting error will abort the file clone operation. --- e2fsck/ChangeLog | 18 ++++++++++++++++++ e2fsck/pass1.c | 10 ++++------ e2fsck/pass1b.c | 5 ++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 270e18d..50e2266 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,21 @@ +2001-06-01 Theodore Tso + + * pass1.c (pass1_get_blocks, pass1_read_inode, pass1_write_inode, + pass1_check_directory): Add a safety check to make sure + ctx->stashed_inode is non-zero. + + * pass1b.c (pass1b): Use e2fsck_use_inode_shortcuts() to disable + the inode shortcut processing, instead of manually + clearing only half of the function pointers that needed to + be NULL'ed out. This caused nasty bugs if the last inode + in the filesystem needed dup block processing. + + * pass1b.c (clone_file_block): When cloning a directory's metadata + block, don't try to update the directory block list + database, since indirect blocks aren't stored in the + database and the resulting error will abort the file clone + operation. + 2001-05-25 Theodore Tso * Release of E2fsprogs 1.20 diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index e0c08b5..62aa08e 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1522,7 +1522,7 @@ static errcode_t pass1_get_blocks(ext2_filsys fs, ext2_ino_t ino, e2fsck_t ctx = (e2fsck_t) fs->priv_data; int i; - if (ino != ctx->stashed_ino) + if ((ino != ctx->stashed_ino) || !ctx->stashed_inode) return EXT2_ET_CALLBACK_NOTHANDLED; for (i=0; i < EXT2_N_BLOCKS; i++) @@ -1535,7 +1535,7 @@ static errcode_t pass1_read_inode(ext2_filsys fs, ext2_ino_t ino, { e2fsck_t ctx = (e2fsck_t) fs->priv_data; - if (ino != ctx->stashed_ino) + if ((ino != ctx->stashed_ino) || !ctx->stashed_inode) return EXT2_ET_CALLBACK_NOTHANDLED; *inode = *ctx->stashed_inode; return 0; @@ -1546,7 +1546,7 @@ static errcode_t pass1_write_inode(ext2_filsys fs, ext2_ino_t ino, { e2fsck_t ctx = (e2fsck_t) fs->priv_data; - if (ino == ctx->stashed_ino) + if ((ino == ctx->stashed_ino) && ctx->stashed_inode) *ctx->stashed_inode = *inode; return EXT2_ET_CALLBACK_NOTHANDLED; } @@ -1555,7 +1555,7 @@ static errcode_t pass1_check_directory(ext2_filsys fs, ext2_ino_t ino) { e2fsck_t ctx = (e2fsck_t) fs->priv_data; - if (ino != ctx->stashed_ino) + if ((ino != ctx->stashed_ino) || !ctx->stashed_inode) return EXT2_ET_CALLBACK_NOTHANDLED; if (!LINUX_S_ISDIR(ctx->stashed_inode->i_mode)) @@ -1580,5 +1580,3 @@ void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool) fs->write_inode = 0; } } - - diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c index 5aab109..f300de3 100644 --- a/e2fsck/pass1b.c +++ b/e2fsck/pass1b.c @@ -226,8 +226,7 @@ static void pass1b(e2fsck_t ctx, char *block_buf) } } ext2fs_close_inode_scan(scan); - fs->get_blocks = 0; - fs->check_directory = 0; + e2fsck_use_inode_shortcuts(ctx, 0); } static int process_pass1b_block(ext2_filsys fs, @@ -586,7 +585,7 @@ static int clone_file_block(ext2_filsys fs, cs->errcode = retval; return BLOCK_ABORT; } - if (cs->dir) { + if (cs->dir && (blockcnt >= 0)) { retval = ext2fs_set_dir_block(fs->dblist, cs->dir, new_block, blockcnt); if (retval) { -- 1.8.3.1