ChangeLog, e2fsck.h, pass1.c, pass2.c, pass3.c, problem.c, problem.h, util.c:
pass1.c (e2fsck_pass1): If the filesystem does not support imagic
inodes, if an inode has the imagic flag set, offer to clear the imagic
flag. If a valid device/fifo/socket has the immutable flag set, call
the new helper function check_immutable() to offerto clear the
immutable flag.
pass2.c (check_filetype): Use the new ext2_file_type() helper function
instead of calculating the file_type information manually.
pass3.c (e2fsck_reconnect_file): When adding a link to lost+found,
calculate the filetype information so that ext2fs_link() can use the
information if applicable. (get_lost_and_found): Create the
/lost+found directory with the correct filetype information if
applicable.
util.c (ext2_file_type), e2fsck.h: New function which returns the
directory entry file type information given the inode's mode bits.
problem.c, problem.h: Added new problem codes PR_1_SET_IMAGIC and
PR_1_SET_IMMUTABLE.
ChangeLog, mke2fs.8.in:
mke2fs.8.in: Update manual page so that the sparse_option filesystem
option is properly named.
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index a336835..949e488 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -451,7 +451,7 @@
/*
* Finally, create the directory link
*/
- pctx.errcode = ext2fs_link(fs, EXT2_ROOT_INO, name, ino, 0);
+ pctx.errcode = ext2fs_link(fs, EXT2_ROOT_INO, name, ino, EXT2_FT_DIR);
if (pctx.errcode) {
pctx.str = "ext2fs_link";
fix_problem(ctx, PR_3_CREATE_LPF_ERROR, &pctx);
@@ -474,15 +474,17 @@
/*
* This routine will connect a file to lost+found
*/
-int e2fsck_reconnect_file(e2fsck_t ctx, ino_t inode)
+int e2fsck_reconnect_file(e2fsck_t ctx, ino_t ino)
{
ext2_filsys fs = ctx->fs;
errcode_t retval;
char name[80];
struct problem_context pctx;
+ struct ext2_inode inode;
+ int file_type = 0;
clear_problem_context(&pctx);
- pctx.ino = inode;
+ pctx.ino = ino;
if (!bad_lost_and_found && !lost_and_found) {
lost_and_found = get_lost_and_found(ctx);
@@ -494,8 +496,10 @@
return 1;
}
- sprintf(name, "#%lu", inode);
- retval = ext2fs_link(fs, lost_and_found, name, inode, 0);
+ sprintf(name, "#%lu", ino);
+ if (ext2fs_read_inode(fs, ino, &inode) == 0)
+ file_type = ext2_file_type(inode.i_mode);
+ retval = ext2fs_link(fs, lost_and_found, name, ino, file_type);
if (retval == EXT2_ET_DIR_NO_SPACE) {
if (!fix_problem(ctx, PR_3_EXPAND_LF_DIR, &pctx))
return 1;
@@ -505,14 +509,14 @@
fix_problem(ctx, PR_3_CANT_EXPAND_LPF, &pctx);
return 1;
}
- retval = ext2fs_link(fs, lost_and_found, name, inode, 0);
+ retval = ext2fs_link(fs, lost_and_found, name, ino, file_type);
}
if (retval) {
pctx.errcode = retval;
fix_problem(ctx, PR_3_CANT_RECONNECT, &pctx);
return 1;
}
- adjust_inode_count(ctx, inode, +1);
+ adjust_inode_count(ctx, ino, +1);
return 0;
}