+1999-11-09 <tytso@valinux.com>
+
+ * 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.
+
1999-11-07 <tytso@valinux.com>
* pass4.c (e2fsck_pass4): Clear inode_imagic_map after freeing it,
extern void mtrace_print(char *mesg);
#endif
extern blk_t get_backup_sb(ext2_filsys fs);
+extern int ext2_file_type(unsigned int mode);
/* unix.c */
extern void e2fsck_clear_progbar(e2fsck_t ctx);
return 1;
}
+/*
+ * If the immutable flag is set on the inode, offer to clear it.
+ */
+static void check_immutable(e2fsck_t ctx, struct problem_context *pctx)
+{
+ if (!(pctx->inode->i_flags & EXT2_IMMUTABLE_FL))
+ return;
+
+ if (!fix_problem(ctx, PR_1_SET_IMMUTABLE, pctx))
+ return;
+
+ pctx->inode->i_flags &= ~EXT2_IMMUTABLE_FL;
+ e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
+}
+
+
void e2fsck_pass1(e2fsck_t ctx)
{
int i;
struct problem_context pctx;
struct scan_callback_struct scan_struct;
struct ext2fs_sb *sb;
+ int imagic_fs;
#ifdef RESOURCE_TRACK
init_resource_track(&rtrack);
ext2_max_sizes[i] = max_sizes;
}
#undef EXT2_BPP
-
+
+ sb = (struct ext2fs_sb *) fs->super;
+ imagic_fs = (sb->s_feature_compat & EXT2_FEATURE_COMPAT_IMAGIC_INODES);
+
/*
* Allocate bitmaps structures
*/
ext2fs_mark_inode_bitmap(ctx->inode_bad_map, ino);
}
if (inode.i_flags & EXT2_IMAGIC_FL) {
- if (!ctx->inode_imagic_map)
- alloc_imagic_map(ctx);
- ext2fs_mark_inode_bitmap(ctx->inode_imagic_map, ino);
+ if (imagic_fs) {
+ if (!ctx->inode_imagic_map)
+ alloc_imagic_map(ctx);
+ ext2fs_mark_inode_bitmap(ctx->inode_imagic_map,
+ ino);
+ } else {
+ if (fix_problem(ctx, PR_1_SET_IMAGIC, &pctx)) {
+ inode.i_flags &= ~EXT2_IMAGIC_FL;
+ e2fsck_write_inode(ctx, ino,
+ &inode, "pass1");
+ }
+ }
}
if (LINUX_S_ISDIR(inode.i_mode)) {
ext2fs_mark_inode_bitmap(ctx->inode_reg_map, ino);
ctx->fs_regular_count++;
} else if (LINUX_S_ISCHR (inode.i_mode) &&
- e2fsck_pass1_check_device_inode(&inode))
+ e2fsck_pass1_check_device_inode(&inode)) {
+ check_immutable(ctx, &pctx);
ctx->fs_chardev_count++;
- else if (LINUX_S_ISBLK (inode.i_mode) &&
- e2fsck_pass1_check_device_inode(&inode))
+ } else if (LINUX_S_ISBLK (inode.i_mode) &&
+ e2fsck_pass1_check_device_inode(&inode)) {
+ check_immutable(ctx, &pctx);
ctx->fs_blockdev_count++;
- else if (LINUX_S_ISLNK (inode.i_mode)) {
+ } else if (LINUX_S_ISLNK (inode.i_mode)) {
ctx->fs_symlinks_count++;
if (!inode.i_blocks) {
ctx->fs_fast_symlinks_count++;
}
}
else if (LINUX_S_ISFIFO (inode.i_mode) &&
- e2fsck_pass1_check_device_inode(&inode))
+ e2fsck_pass1_check_device_inode(&inode)) {
+ check_immutable(ctx, &pctx);
ctx->fs_fifo_count++;
- else if ((LINUX_S_ISSOCK (inode.i_mode)) &&
- e2fsck_pass1_check_device_inode(&inode))
+ } else if ((LINUX_S_ISSOCK (inode.i_mode)) &&
+ e2fsck_pass1_check_device_inode(&inode)) {
+ check_immutable(ctx, &pctx);
ctx->fs_sockets_count++;
- else {
+ } else {
if (!ctx->inode_bad_map)
alloc_bad_map(ctx);
ext2fs_mark_inode_bitmap(ctx->inode_bad_map, ino);
ext2fs_free_block_bitmap(ctx->block_illegal_map);
ctx->block_illegal_map = 0;
- sb = (struct ext2fs_sb *) fs->super;
if (ctx->large_files &&
!(sb->s_feature_ro_compat &
EXT2_FEATURE_RO_COMPAT_LARGE_FILE)) {
else {
e2fsck_read_inode(ctx, dirent->inode, &inode,
"check_filetype");
- if (LINUX_S_ISCHR (inode.i_mode))
- should_be = EXT2_FT_CHRDEV;
- else if (LINUX_S_ISBLK (inode.i_mode))
- should_be = EXT2_FT_BLKDEV;
- else if (LINUX_S_ISLNK (inode.i_mode))
- should_be = EXT2_FT_SYMLINK;
- else if (LINUX_S_ISFIFO (inode.i_mode))
- should_be = EXT2_FT_FIFO;
- else if (LINUX_S_ISSOCK (inode.i_mode))
- should_be = EXT2_FT_SOCK;
+ should_be = ext2_file_type(inode.i_mode);
}
if (filetype == should_be)
return 0;
/*
* 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);
/*
* 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);
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;
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;
}
"@f contains large files, but lacks LARGE_FILE flag in @S.\n",
PROMPT_FIX, 0 },
+ /* Imagic flag set on an inode when filesystem doesn't support it */
+ { PR_1_SET_IMAGIC,
+ "@i %i has imagic flag set. ",
+ PROMPT_CLEAR, 0 },
+
+ /* Immutable flag set on a device or socket inode */
+ { PR_1_SET_IMMUTABLE,
+ "Special (device/socket/fifo) @i %i has immutable flag set. ",
+ PROMPT_CLEAR, 0 },
+
+
/* Pass 1b errors */
/* Pass 1B: Rescan for duplicate/bad blocks */
/* Filesystem contains large files, but has no such flag in sb */
#define PR_1_FEATURE_LARGE_FILES 0x01002E
+/* Imagic flag set on an inode when filesystem doesn't support it */
+#define PR_1_SET_IMAGIC 0x01002F
+
+/* Immutable flag set on a device or socket inode */
+#define PR_1_SET_IMMUTABLE 0x010030
+
/*
* Pass 1b errors
*/
return fs->super->s_blocks_per_group + 1;
}
+/*
+ * Given a mode, return the ext2 file type
+ */
+int ext2_file_type(unsigned int mode)
+{
+ if (LINUX_S_ISREG(mode))
+ return EXT2_FT_REG_FILE;
+
+ if (LINUX_S_ISDIR(mode))
+ return EXT2_FT_DIR;
+
+ if (LINUX_S_ISCHR(mode))
+ return EXT2_FT_CHRDEV;
+
+ if (LINUX_S_ISBLK(mode))
+ return EXT2_FT_BLKDEV;
+
+ if (LINUX_S_ISLNK(mode))
+ return EXT2_FT_SYMLINK;
+
+ if (LINUX_S_ISFIFO(mode))
+ return EXT2_FT_FIFO;
+
+ if (LINUX_S_ISSOCK(mode))
+ return EXT2_FT_SOCK;
+
+ return 0;
+}
+1999-11-10 <tytso@valinux.com>
+
+ * mke2fs.8.in: Update manual page so that the sparse_option
+ filesystem option is properly named.
+
1999-11-04 <tytso@valinux.com>
* fsck.c (main): Move setting of the interactive flag to before
.BI \-O " feature\fR[,...]"
Create the filesystem with the listed set of features
(filesystem options). The following features are supported:
-.IR sparse ,
+.IR sparse_super ,
which cause the filesystem to use sparse superblocks, and
.IR filetype ,
which will cause the filesystem to store file type information in