Fix e2fsck to set the filetype of '..' when connecting a dir, to lost+found
If there is an orphaned inode whose '..' entry is pointing at a special
file, the filetype of the '..' entry will set to the type of the special
file. When the orphaned directory is reconnected to /lost+found, the
filetype of the '..' field is not reset to EXT2_FT_DIR, so a second
e2fsck is required to repair the filesystem.
We address this situation by setting the filetype of '..' when we
reconnect the inode to /lost+found.
Addresses Lustre Bug: #11645
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index 26c0a03..72c4ec4 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -645,6 +645,12 @@
fix_problem(fp->ctx, PR_3_ADJUST_INODE, &pctx);
}
dirent->inode = fp->parent;
+ if (fp->ctx->fs->super->s_feature_incompat &
+ EXT2_FEATURE_INCOMPAT_FILETYPE)
+ dirent->name_len = (dirent->name_len & 0xFF) |
+ (EXT2_FT_DIR << 8);
+ else
+ dirent->name_len = dirent->name_len & 0xFF;
fp->done++;
return DIRENT_ABORT | DIRENT_CHANGED;