From 2e5fcce05ea583c480b28bf3b1f2aa427a3dcc07 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 12 Dec 2003 03:00:56 -0500 Subject: [PATCH] Fix bug in e2fsck: When reconnecting a directory, we may need to create a lost+found directory. This may invalidate our pointer to the directory information, so we must look it up again after calling e2fsck_reconnect_file(). (Addresses Debian bug #219640). --- e2fsck/ChangeLog | 8 ++++++++ e2fsck/pass3.c | 3 ++- tests/ChangeLog | 5 +++++ tests/f_lpf2/expect.1 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/f_lpf2/expect.2 | 7 +++++++ tests/f_lpf2/image.gz | Bin 0 -> 450 bytes tests/f_lpf2/name | 1 + 7 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/f_lpf2/expect.1 create mode 100644 tests/f_lpf2/expect.2 create mode 100644 tests/f_lpf2/image.gz create mode 100644 tests/f_lpf2/name diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index b30d4c2d..754a688f 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,11 @@ +2003-12-12 Theodore Ts'o + + * pass3.c (check_directory): When reconnecting a directory, we may + need to create a lost+found directory. This may + invalidate our pointer to the directory information, so we + must look it up again after calling + e2fsck_reconnect_file(). (Addresses Debian bug #219640). + 2003-12-10 Theodore Ts'o * e2fsck.h (E2F_FLAG_RESTARTED): Assign a unique flag bitfield to diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c index e2bdd544..6ae87a4f 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -302,9 +302,10 @@ static int check_directory(e2fsck_t ctx, struct dir_info *dir, p->parent)))) { pctx->ino = p->ino; if (fix_problem(ctx, PR_3_UNCONNECTED_DIR, pctx)) { - if (e2fsck_reconnect_file(ctx, p->ino)) + if (e2fsck_reconnect_file(ctx, pctx->ino)) ext2fs_unmark_valid(fs); else { + p = e2fsck_get_dir_info(ctx, pctx->ino); p->parent = ctx->lost_and_found; fix_dotdot(ctx, p, ctx->lost_and_found); } diff --git a/tests/ChangeLog b/tests/ChangeLog index 26605c4d..20123746 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2003-12-12 Theodore Ts'o + + * f_lpf2: New test case to validate reconnecting a directory after + creating /lost+found. + 2003-09-03 Theodore Ts'o * m_meta_bg: New test case to test the meta block group feature. diff --git a/tests/f_lpf2/expect.1 b/tests/f_lpf2/expect.1 new file mode 100644 index 00000000..633586cc --- /dev/null +++ b/tests/f_lpf2/expect.1 @@ -0,0 +1,41 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Unconnected directory inode 12 (/???) +Connect to /lost+found? yes + +/lost+found not found. Create? yes + +Unconnected directory inode 13 (/???) +Connect to /lost+found? yes + +Pass 4: Checking reference counts +Inode 2 ref count is 4, should be 3. Fix? yes + +Inode 12 ref count is 3, should be 2. Fix? yes + +Inode 13 ref count is 3, should be 2. Fix? yes + +Pass 5: Checking group summary information +Block bitmap differences: -(9--19) +Fix? yes + +Free blocks count wrong for group #0 (77, counted=89). +Fix? yes + +Free blocks count wrong (77, counted=89). +Fix? yes + +Free inodes count wrong for group #0 (2, counted=3). +Fix? yes + +Directories count wrong for group #0 (5, counted=4). +Fix? yes + +Free inodes count wrong (2, counted=3). +Fix? yes + + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 13/16 files (0.0% non-contiguous), 11/100 blocks +Exit status is 1 diff --git a/tests/f_lpf2/expect.2 b/tests/f_lpf2/expect.2 new file mode 100644 index 00000000..e5519325 --- /dev/null +++ b/tests/f_lpf2/expect.2 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 13/16 files (0.0% non-contiguous), 11/100 blocks +Exit status is 0 diff --git a/tests/f_lpf2/image.gz b/tests/f_lpf2/image.gz new file mode 100644 index 0000000000000000000000000000000000000000..f703fb3fc9ed8dc3320db72d6fb0bd143075c793 GIT binary patch literal 450 zcmb2|=HO^iy=l+HoSB=Lp33m{)^0E5LwfKZ{*)+*)o6TN$WHAo*WK= zy((L0htvmcUGiv&*H77F)~1(Y@66v9%bRGl#(v7Bzsqi&-kP>c_xGKEp!!|4S7PJ$ z?Vr1sBfI{5w(()_<>#g43)kG9yiqNmw69q^ZC_Sc|GQdLf8zXkcAHg<_kA|ss$|?e z^Un88r|!*p_P&1c|H?mWQ|_$!XZp{7`m5-y_{T*Wu2bXWU8j0|n=9SJ_v*NMarM_@ z5A)JvEstD`+dJ=@d0~9Xm5e`SVh^*WswV$G{=@XY1LKd2{7>X3)I0oR{K<~Oc;KzU c{{MgbBB^Qh4AcY-{!dx!TJ?JwCNMGp09n4ht^fc4 literal 0 HcmV?d00001 diff --git a/tests/f_lpf2/name b/tests/f_lpf2/name new file mode 100644 index 00000000..63da3159 --- /dev/null +++ b/tests/f_lpf2/name @@ -0,0 +1 @@ +create lost+found and reconnect lost directory