2001-01-12 Theodore Ts'o <tytso@valinux.com>
+ * journal.c (e2fsck_journal_fix_unsupported_super): Remove unused
+ function. Add FIXME notes to e2fsck_get_journal(), from
+ Andreas Dilger.
+
+ * pass1.c (e2fsck_pass1): Cap the maximum legal size of a file by
+ the limit caused by the fact that i_blocks is in 512 byte
+ units, and that the Linux buffer cache also fundamentally
+ assumes 512 byte sectors.
+ Make sure that the journal inode is a regular file, and
+ when clearing an unused journal inode, make sure the
+ icount db is updated.
+
+ * problem.c, problem.h (PR_1_JOURNAL_BAD_MODE): Add new problem code.
+
* problem.c: For PR_1_RESERVED_BAD_MODE, print a description of
the reserved inode. In PR_0_JOURNAL_HAS_JOURNAL, prompt
to clear the journal, rather than deleting it (which is
clear_problem_context(&pctx);
if (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) {
+ /* FIXME: check if UUID is valid block dev, has a journal */
if (sb->s_journal_dev) {
pctx.num = sb->s_journal_dev;
/* this problem aborts on -y, -p, unsupported on -n */
sb->s_state &= ~EXT2_VALID_FS;
ext2fs_mark_super_dirty(ctx->fs);
}
+ /* FIXME: check if UUID is valid block dev, has a journal */
if (!uuid_is_null(sb->s_journal_uuid)) {
uuid_unparse(sb->s_journal_uuid, uuid_str);
pctx.str = uuid_str;
return 0;
}
-static errcode_t e2fsck_journal_fix_unsupported_super(e2fsck_t ctx,
- struct problem_context *pctx)
-{
- struct ext2_super_block *sb = ctx->fs->super;
-
- /* Unsupported journal superblock - first choice is abort.
- * Declining that gives the option to reset the superblock.
- *
- * Otherwise we get the chance to delete the journal, and
- * failing that we abort because we can't handle this.
- */
- if (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL &&
- fix_problem(ctx, PR_0_JOURNAL_UNSUPP_SUPER, pctx))
- return EXT2_ET_CORRUPT_SUPERBLOCK;
-
- if (e2fsck_journal_fix_bad_inode(ctx, pctx))
- return EXT2_ET_UNSUPP_FEATURE;
-
- return 0;
-}
-
static errcode_t e2fsck_journal_load(journal_t *journal)
{
e2fsck_t ctx = journal->j_dev;
void e2fsck_pass1(e2fsck_t ctx)
{
int i;
- __u64 max_sizes;
+ __u64 max_sizes, max_sect_limit;
ext2_filsys fs = ctx->fs;
ext2_ino_t ino;
struct ext2_inode inode;
(__u64) EXT2_BPP(10+i) * EXT2_BPP(10+i) *
EXT2_BPP(10+i));
max_sizes = (max_sizes * (1UL << (10+i))) - 1;
+ max_sect_limit = 512ULL * ((1LL << 32) - (1 << (i+1)));
+ if (max_sizes > max_sect_limit)
+ max_sizes = max_sect_limit;
ext2_max_sizes[i] = max_sizes;
}
#undef EXT2_BPP
ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
clear_problem_context(&pctx);
goto next;
- }
- if (ino == EXT2_ROOT_INO) {
+ } else if (ino == EXT2_ROOT_INO) {
/*
* Make sure the root inode is a directory; if
* not, offer to clear it. It will be
"pass1");
}
}
- }
- if (ino == EXT2_JOURNAL_INO) {
+ } else if (ino == EXT2_JOURNAL_INO) {
ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
if (fs->super->s_journal_inum == EXT2_JOURNAL_INO) {
+ /*
+ * XXX arguably this check should be
+ * in journal.c, before we decide it's
+ * safe to run the journal...
+ */
+ if (!LINUX_S_ISREG(inode.i_mode) &&
+ fix_problem(ctx, PR_1_JOURNAL_BAD_MODE,
+ &pctx)) {
+ inode.i_mode = LINUX_S_IFREG;
+ e2fsck_write_inode(ctx, ino, &inode,
+ "pass1");
+ }
check_blocks(ctx, &pctx, block_buf);
goto next;
}
- if ((inode.i_blocks || inode.i_block[0]) &&
- fix_problem(ctx, PR1_JOURNAL_INODE_NOT_CLEAR,
+ if ((inode.i_links_count || inode.i_blocks ||
+ inode.i_blocks || inode.i_block[0]) &&
+ fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR,
&pctx)) {
memset(&inode, 0, sizeof(inode));
+ ext2fs_icount_store(ctx->inode_link_info,
+ ino, 0);
e2fsck_write_inode(ctx, ino, &inode, "pass1");
}
- }
- if ((ino != EXT2_ROOT_INO) &&
- (ino < EXT2_FIRST_INODE(fs->super))) {
+ } else if (ino < EXT2_FIRST_INODE(fs->super)) {
int problem = 0;
ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
/* Journal inode is not in use, but contains data */
- { PR1_JOURNAL_INODE_NOT_CLEAR,
+ { PR_1_JOURNAL_INODE_NOT_CLEAR,
"@j @i is not in use, but contains data. ",
PROMPT_CLEAR, PR_PREEN_OK },
+ /* Journal has bad mode */
+ { PR_1_JOURNAL_BAD_MODE,
+ N_("Journal is not regular file. "),
+ PROMPT_FIX, PR_PREEN_OK },
+
/* Pass 1b errors */
/* Pass 1B: Rescan for duplicate/bad blocks */
#define PR_1_FS_REV_LEVEL 0x010033
/* Journal inode not in use, needs clearing */
-#define PR1_JOURNAL_INODE_NOT_CLEAR 0x010034
+#define PR_1_JOURNAL_INODE_NOT_CLEAR 0x010034
+/* Journal inode has wrong mode */
+#define PR_1_JOURNAL_BAD_MODE 0x010035
+
/*
* Pass 1b errors
*/