1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* pass5.c --- check block and inode bitmaps against on-disk bitmaps
|
|
|
|
*
|
1997-04-30 00:15:03 +08:00
|
|
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
1997-04-26 21:21:57 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "e2fsck.h"
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
#include "problem.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void check_block_bitmaps(e2fsck_t ctx);
|
|
|
|
static void check_inode_bitmaps(e2fsck_t ctx);
|
|
|
|
static void check_inode_end(e2fsck_t ctx);
|
|
|
|
static void check_block_end(e2fsck_t ctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
1997-11-04 03:42:40 +08:00
|
|
|
void e2fsck_pass5(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
1997-10-20 09:38:32 +08:00
|
|
|
#ifdef RESOURCE_TRACK
|
1997-04-26 21:21:57 +08:00
|
|
|
struct resource_track rtrack;
|
1997-10-20 09:38:32 +08:00
|
|
|
#endif
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
struct problem_context pctx;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
#ifdef MTRACE
|
|
|
|
mtrace_print("Pass 5");
|
|
|
|
#endif
|
|
|
|
|
1997-10-20 09:38:32 +08:00
|
|
|
#ifdef RESOURCE_TRACK
|
2007-08-04 08:07:09 +08:00
|
|
|
init_resource_track(&rtrack, ctx->fs->io);
|
1997-10-20 09:38:32 +08:00
|
|
|
#endif
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (!(ctx->options & E2F_OPT_PREEN))
|
|
|
|
fix_problem(ctx, PR_5_PASS_HEADER, &pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 13:23:04 +08:00
|
|
|
if (ctx->progress)
|
1998-05-07 13:02:00 +08:00
|
|
|
if ((ctx->progress)(ctx, 5, 0, ctx->fs->group_desc_count*2))
|
1998-02-25 04:22:23 +08:00
|
|
|
return;
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 13:23:04 +08:00
|
|
|
|
|
|
|
e2fsck_read_bitmaps(ctx);
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
check_block_bitmaps(ctx);
|
1998-02-25 04:22:23 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-04 03:42:40 +08:00
|
|
|
return;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
check_inode_bitmaps(ctx);
|
1998-02-25 04:22:23 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-04 03:42:40 +08:00
|
|
|
return;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
check_inode_end(ctx);
|
1998-02-25 04:22:23 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-04 03:42:40 +08:00
|
|
|
return;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
check_block_end(ctx);
|
1998-02-25 04:22:23 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-04 03:42:40 +08:00
|
|
|
return;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_free_inode_bitmap(ctx->inode_used_map);
|
|
|
|
ctx->inode_used_map = 0;
|
|
|
|
ext2fs_free_inode_bitmap(ctx->inode_dir_map);
|
|
|
|
ctx->inode_dir_map = 0;
|
|
|
|
ext2fs_free_block_bitmap(ctx->block_found_map);
|
|
|
|
ctx->block_found_map = 0;
|
|
|
|
|
1997-10-20 09:38:32 +08:00
|
|
|
#ifdef RESOURCE_TRACK
|
1999-07-19 23:27:37 +08:00
|
|
|
if (ctx->options & E2F_OPT_TIME2) {
|
|
|
|
e2fsck_clear_progbar(ctx);
|
2007-08-04 08:07:09 +08:00
|
|
|
print_resource_track(_("Pass 5"), &rtrack, ctx->fs->io);
|
1999-07-19 23:27:37 +08:00
|
|
|
}
|
1997-10-20 09:38:32 +08:00
|
|
|
#endif
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
2002-03-07 15:47:07 +08:00
|
|
|
#define NO_BLK ((blk_t) -1)
|
|
|
|
|
2002-03-08 12:52:56 +08:00
|
|
|
static void print_bitmap_problem(e2fsck_t ctx, int problem,
|
2002-03-07 15:47:07 +08:00
|
|
|
struct problem_context *pctx)
|
|
|
|
{
|
|
|
|
switch (problem) {
|
|
|
|
case PR_5_BLOCK_UNUSED:
|
|
|
|
if (pctx->blk == pctx->blk2)
|
|
|
|
pctx->blk2 = 0;
|
|
|
|
else
|
|
|
|
problem = PR_5_BLOCK_RANGE_UNUSED;
|
|
|
|
break;
|
|
|
|
case PR_5_BLOCK_USED:
|
|
|
|
if (pctx->blk == pctx->blk2)
|
|
|
|
pctx->blk2 = 0;
|
|
|
|
else
|
|
|
|
problem = PR_5_BLOCK_RANGE_USED;
|
|
|
|
break;
|
|
|
|
case PR_5_INODE_UNUSED:
|
|
|
|
if (pctx->ino == pctx->ino2)
|
|
|
|
pctx->ino2 = 0;
|
|
|
|
else
|
|
|
|
problem = PR_5_INODE_RANGE_UNUSED;
|
|
|
|
break;
|
|
|
|
case PR_5_INODE_USED:
|
|
|
|
if (pctx->ino == pctx->ino2)
|
|
|
|
pctx->ino2 = 0;
|
|
|
|
else
|
|
|
|
problem = PR_5_INODE_RANGE_USED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fix_problem(ctx, problem, pctx);
|
|
|
|
pctx->blk = pctx->blk2 = NO_BLK;
|
|
|
|
pctx->ino = pctx->ino2 = 0;
|
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void check_block_bitmaps(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
2006-05-09 08:17:26 +08:00
|
|
|
blk_t i, super;
|
1997-04-26 21:21:57 +08:00
|
|
|
int *free_array;
|
|
|
|
int group = 0;
|
2007-08-30 23:33:40 +08:00
|
|
|
blk_t blocks = 0;
|
|
|
|
blk_t free_blocks = 0;
|
1997-04-26 21:21:57 +08:00
|
|
|
int group_free = 0;
|
|
|
|
int actual, bitmap;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
struct problem_context pctx;
|
2002-03-07 15:47:07 +08:00
|
|
|
int problem, save_problem, fixit, had_problem;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
errcode_t retval;
|
2006-05-09 08:17:26 +08:00
|
|
|
int lazy_bg = 0;
|
|
|
|
int skip_group = 0;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
clear_problem_context(&pctx);
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
free_array = (int *) e2fsck_allocate_memory(ctx,
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 13:23:04 +08:00
|
|
|
fs->group_desc_count * sizeof(int), "free block count array");
|
1997-04-26 21:58:21 +08:00
|
|
|
|
|
|
|
if ((fs->super->s_first_data_block <
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_get_block_bitmap_start(ctx->block_found_map)) ||
|
1997-04-26 21:58:21 +08:00
|
|
|
(fs->super->s_blocks_count-1 >
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_get_block_bitmap_end(ctx->block_found_map))) {
|
|
|
|
pctx.num = 1;
|
|
|
|
pctx.blk = fs->super->s_first_data_block;
|
|
|
|
pctx.blk2 = fs->super->s_blocks_count -1;
|
|
|
|
pctx.ino = ext2fs_get_block_bitmap_start(ctx->block_found_map);
|
|
|
|
pctx.ino2 = ext2fs_get_block_bitmap_end(ctx->block_found_map);
|
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
1997-04-26 21:58:21 +08:00
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:58:21 +08:00
|
|
|
if ((fs->super->s_first_data_block <
|
|
|
|
ext2fs_get_block_bitmap_start(fs->block_map)) ||
|
|
|
|
(fs->super->s_blocks_count-1 >
|
|
|
|
ext2fs_get_block_bitmap_end(fs->block_map))) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.num = 2;
|
|
|
|
pctx.blk = fs->super->s_first_data_block;
|
|
|
|
pctx.blk2 = fs->super->s_blocks_count -1;
|
|
|
|
pctx.ino = ext2fs_get_block_bitmap_start(fs->block_map);
|
|
|
|
pctx.ino2 = ext2fs_get_block_bitmap_end(fs->block_map);
|
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
1997-04-26 21:58:21 +08:00
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
|
|
|
|
if (EXT2_HAS_COMPAT_FEATURE(fs->super, EXT2_FEATURE_COMPAT_LAZY_BG))
|
2006-05-09 08:17:26 +08:00
|
|
|
lazy_bg++;
|
|
|
|
|
1998-02-20 13:24:59 +08:00
|
|
|
redo_counts:
|
|
|
|
had_problem = 0;
|
2002-03-07 15:47:07 +08:00
|
|
|
save_problem = 0;
|
|
|
|
pctx.blk = pctx.blk2 = NO_BLK;
|
2006-05-09 08:17:26 +08:00
|
|
|
if (lazy_bg && (fs->group_desc[group].bg_flags &
|
|
|
|
EXT2_BG_BLOCK_UNINIT))
|
|
|
|
skip_group++;
|
|
|
|
super = fs->super->s_first_data_block;
|
1997-04-26 21:21:57 +08:00
|
|
|
for (i = fs->super->s_first_data_block;
|
|
|
|
i < fs->super->s_blocks_count;
|
|
|
|
i++) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
actual = ext2fs_fast_test_block_bitmap(ctx->block_found_map, i);
|
2006-05-09 08:17:26 +08:00
|
|
|
|
|
|
|
if (skip_group) {
|
|
|
|
if ((i >= super) &&
|
|
|
|
(i <= super + fs->desc_blocks) &&
|
|
|
|
ext2fs_bg_has_super(fs, group))
|
|
|
|
bitmap = 1;
|
|
|
|
else if (i == fs->group_desc[group].bg_block_bitmap)
|
|
|
|
bitmap = 1;
|
|
|
|
else if (i == fs->group_desc[group].bg_inode_bitmap)
|
|
|
|
bitmap = 1;
|
|
|
|
else if (i >= fs->group_desc[group].bg_inode_table &&
|
|
|
|
(i < fs->group_desc[group].bg_inode_table
|
|
|
|
+ fs->inode_blocks_per_group))
|
|
|
|
bitmap = 1;
|
|
|
|
else
|
|
|
|
bitmap = 0;
|
|
|
|
actual = (actual != 0);
|
|
|
|
} else
|
|
|
|
bitmap = ext2fs_fast_test_block_bitmap(fs->block_map, i);
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
if (actual == bitmap)
|
|
|
|
goto do_counts;
|
2006-05-09 08:17:26 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
if (!actual && bitmap) {
|
|
|
|
/*
|
|
|
|
* Block not used, but marked in use in the bitmap.
|
|
|
|
*/
|
2002-03-07 15:47:07 +08:00
|
|
|
problem = PR_5_BLOCK_UNUSED;
|
1997-04-26 21:21:57 +08:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Block used, but not marked in use in the bitmap.
|
|
|
|
*/
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
problem = PR_5_BLOCK_USED;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2002-03-07 15:47:07 +08:00
|
|
|
if (pctx.blk == NO_BLK) {
|
|
|
|
pctx.blk = pctx.blk2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
} else {
|
|
|
|
if ((problem == save_problem) &&
|
|
|
|
(pctx.blk2 == i-1))
|
|
|
|
pctx.blk2++;
|
|
|
|
else {
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
|
|
|
pctx.blk = pctx.blk2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
}
|
|
|
|
}
|
1999-07-19 23:27:37 +08:00
|
|
|
ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
|
1998-02-20 13:24:59 +08:00
|
|
|
had_problem++;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
do_counts:
|
2006-05-09 08:17:26 +08:00
|
|
|
if (!bitmap && !skip_group) {
|
1997-04-26 21:21:57 +08:00
|
|
|
group_free++;
|
|
|
|
free_blocks++;
|
|
|
|
}
|
|
|
|
blocks ++;
|
|
|
|
if ((blocks == fs->super->s_blocks_per_group) ||
|
|
|
|
(i == fs->super->s_blocks_count-1)) {
|
|
|
|
free_array[group] = group_free;
|
|
|
|
group ++;
|
|
|
|
blocks = 0;
|
|
|
|
group_free = 0;
|
2006-05-09 08:17:26 +08:00
|
|
|
skip_group = 0;
|
|
|
|
super += fs->super->s_blocks_per_group;
|
1998-05-07 13:02:00 +08:00
|
|
|
if (ctx->progress)
|
|
|
|
if ((ctx->progress)(ctx, 5, group,
|
|
|
|
fs->group_desc_count*2))
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
2006-05-09 08:17:26 +08:00
|
|
|
if (lazy_bg &&
|
|
|
|
(i != fs->super->s_blocks_count-1) &&
|
|
|
|
(fs->group_desc[group].bg_flags &
|
|
|
|
EXT2_BG_BLOCK_UNINIT))
|
|
|
|
skip_group++;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
2002-03-07 15:47:07 +08:00
|
|
|
if (pctx.blk != NO_BLK)
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
1998-02-20 13:24:59 +08:00
|
|
|
if (had_problem)
|
2002-03-07 15:47:07 +08:00
|
|
|
fixit = end_problem_latch(ctx, PR_LATCH_BBITMAP);
|
1998-02-20 13:24:59 +08:00
|
|
|
else
|
|
|
|
fixit = -1;
|
1999-07-19 23:27:37 +08:00
|
|
|
ctx->flags &= ~E2F_FLAG_PROG_SUPPRESS;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (fixit == 1) {
|
|
|
|
ext2fs_free_block_bitmap(fs->block_map);
|
|
|
|
retval = ext2fs_copy_bitmap(ctx->block_found_map,
|
|
|
|
&fs->block_map);
|
2000-06-11 03:21:33 +08:00
|
|
|
if (retval) {
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
fix_problem(ctx, PR_5_COPY_BBITMAP_ERROR, &pctx);
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
2000-06-11 03:21:33 +08:00
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_set_bitmap_padding(fs->block_map);
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
/* Redo the counts */
|
|
|
|
blocks = 0; free_blocks = 0; group_free = 0; group = 0;
|
|
|
|
memset(free_array, 0, fs->group_desc_count * sizeof(int));
|
|
|
|
goto redo_counts;
|
|
|
|
} else if (fixit == 0)
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
|
|
|
if (free_array[i] != fs->group_desc[i].bg_free_blocks_count) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.group = i;
|
|
|
|
pctx.blk = fs->group_desc[i].bg_free_blocks_count;
|
|
|
|
pctx.blk2 = free_array[i];
|
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT_GROUP,
|
|
|
|
&pctx)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
fs->group_desc[i].bg_free_blocks_count =
|
|
|
|
free_array[i];
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (free_blocks != fs->super->s_free_blocks_count) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.group = 0;
|
|
|
|
pctx.blk = fs->super->s_free_blocks_count;
|
|
|
|
pctx.blk2 = free_blocks;
|
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT, &pctx)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
fs->super->s_free_blocks_count = free_blocks;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
errout:
|
2003-08-01 21:41:07 +08:00
|
|
|
ext2fs_free_mem(&free_array);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void check_inode_bitmaps(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
Many files:
dirinfo.c, e2fsck.h, emptydir.c, iscan.c, jfs_user.h, journal.c,
message.c, pass1.c, pass1b.c, pass2.c, pass3.c, pass4.c, pass5.c,
problem.h, scantest.c, super.c, swapfs.c: Change ino_t to ext2_ino_t.
2001-01-11 23:12:14 +08:00
|
|
|
ext2_ino_t i;
|
2003-12-07 14:28:50 +08:00
|
|
|
unsigned int free_inodes = 0;
|
|
|
|
int group_free = 0;
|
|
|
|
int dirs_count = 0;
|
|
|
|
int group = 0;
|
|
|
|
unsigned int inodes = 0;
|
|
|
|
int *free_array;
|
|
|
|
int *dir_array;
|
|
|
|
int actual, bitmap;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
errcode_t retval;
|
|
|
|
struct problem_context pctx;
|
2003-12-07 14:28:50 +08:00
|
|
|
int problem, save_problem, fixit, had_problem;
|
2006-05-09 08:17:26 +08:00
|
|
|
int lazy_bg = 0;
|
|
|
|
int skip_group = 0;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
clear_problem_context(&pctx);
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
free_array = (int *) e2fsck_allocate_memory(ctx,
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 13:23:04 +08:00
|
|
|
fs->group_desc_count * sizeof(int), "free inode count array");
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
dir_array = (int *) e2fsck_allocate_memory(ctx,
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 13:23:04 +08:00
|
|
|
fs->group_desc_count * sizeof(int), "directory count array");
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if ((1 < ext2fs_get_inode_bitmap_start(ctx->inode_used_map)) ||
|
2007-03-29 00:07:41 +08:00
|
|
|
(fs->super->s_inodes_count >
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_get_inode_bitmap_end(ctx->inode_used_map))) {
|
|
|
|
pctx.num = 3;
|
|
|
|
pctx.blk = 1;
|
|
|
|
pctx.blk2 = fs->super->s_inodes_count;
|
|
|
|
pctx.ino = ext2fs_get_inode_bitmap_start(ctx->inode_used_map);
|
|
|
|
pctx.ino2 = ext2fs_get_inode_bitmap_end(ctx->inode_used_map);
|
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
1997-04-26 21:58:21 +08:00
|
|
|
}
|
|
|
|
if ((1 < ext2fs_get_inode_bitmap_start(fs->inode_map)) ||
|
2007-03-29 00:07:41 +08:00
|
|
|
(fs->super->s_inodes_count >
|
1997-04-26 21:58:21 +08:00
|
|
|
ext2fs_get_inode_bitmap_end(fs->inode_map))) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.num = 4;
|
|
|
|
pctx.blk = 1;
|
|
|
|
pctx.blk2 = fs->super->s_inodes_count;
|
|
|
|
pctx.ino = ext2fs_get_inode_bitmap_start(fs->inode_map);
|
|
|
|
pctx.ino2 = ext2fs_get_inode_bitmap_end(fs->inode_map);
|
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
1997-04-26 21:58:21 +08:00
|
|
|
}
|
|
|
|
|
2007-03-29 00:07:41 +08:00
|
|
|
if (EXT2_HAS_COMPAT_FEATURE(fs->super,
|
2006-05-09 08:17:26 +08:00
|
|
|
EXT2_FEATURE_COMPAT_LAZY_BG))
|
|
|
|
lazy_bg++;
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
redo_counts:
|
1998-02-20 13:24:59 +08:00
|
|
|
had_problem = 0;
|
2002-03-07 15:47:07 +08:00
|
|
|
save_problem = 0;
|
|
|
|
pctx.ino = pctx.ino2 = 0;
|
2006-05-09 08:17:26 +08:00
|
|
|
if (lazy_bg && (fs->group_desc[group].bg_flags &
|
|
|
|
EXT2_BG_INODE_UNINIT))
|
|
|
|
skip_group++;
|
|
|
|
|
2006-08-30 14:16:55 +08:00
|
|
|
/* Protect loop from wrap-around if inodes_count is maxed */
|
|
|
|
for (i = 1; i <= fs->super->s_inodes_count && i > 0; i++) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
actual = ext2fs_fast_test_inode_bitmap(ctx->inode_used_map, i);
|
2007-03-29 00:07:41 +08:00
|
|
|
if (skip_group)
|
2006-05-09 08:17:26 +08:00
|
|
|
bitmap = 0;
|
|
|
|
else
|
|
|
|
bitmap = ext2fs_fast_test_inode_bitmap(fs->inode_map, i);
|
1997-04-26 21:21:57 +08:00
|
|
|
if (actual == bitmap)
|
|
|
|
goto do_counts;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
if (!actual && bitmap) {
|
|
|
|
/*
|
|
|
|
* Inode wasn't used, but marked in bitmap
|
|
|
|
*/
|
2002-03-07 15:47:07 +08:00
|
|
|
problem = PR_5_INODE_UNUSED;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
} else /* if (actual && !bitmap) */ {
|
1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* Inode used, but not in bitmap
|
|
|
|
*/
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
problem = PR_5_INODE_USED;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2002-03-07 15:47:07 +08:00
|
|
|
if (pctx.ino == 0) {
|
|
|
|
pctx.ino = pctx.ino2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
} else {
|
|
|
|
if ((problem == save_problem) &&
|
|
|
|
(pctx.ino2 == i-1))
|
|
|
|
pctx.ino2++;
|
|
|
|
else {
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
|
|
|
pctx.ino = pctx.ino2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
}
|
|
|
|
}
|
1999-07-19 23:27:37 +08:00
|
|
|
ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
|
1998-02-20 13:24:59 +08:00
|
|
|
had_problem++;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
do_counts:
|
2006-05-09 08:17:26 +08:00
|
|
|
if (bitmap) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, i))
|
1997-04-26 21:21:57 +08:00
|
|
|
dirs_count++;
|
2006-05-09 08:17:26 +08:00
|
|
|
} else if (!skip_group) {
|
|
|
|
group_free++;
|
|
|
|
free_inodes++;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
inodes++;
|
|
|
|
if ((inodes == fs->super->s_inodes_per_group) ||
|
|
|
|
(i == fs->super->s_inodes_count)) {
|
|
|
|
free_array[group] = group_free;
|
|
|
|
dir_array[group] = dirs_count;
|
|
|
|
group ++;
|
|
|
|
inodes = 0;
|
2006-05-09 08:17:26 +08:00
|
|
|
skip_group = 0;
|
1997-04-26 21:21:57 +08:00
|
|
|
group_free = 0;
|
|
|
|
dirs_count = 0;
|
1998-05-07 13:02:00 +08:00
|
|
|
if (ctx->progress)
|
|
|
|
if ((ctx->progress)(ctx, 5,
|
|
|
|
group + fs->group_desc_count,
|
|
|
|
fs->group_desc_count*2))
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
2006-05-09 08:17:26 +08:00
|
|
|
if (lazy_bg &&
|
|
|
|
(i != fs->super->s_inodes_count) &&
|
|
|
|
(fs->group_desc[group].bg_flags &
|
|
|
|
EXT2_BG_INODE_UNINIT))
|
|
|
|
skip_group++;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
2002-03-07 15:47:07 +08:00
|
|
|
if (pctx.ino)
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1998-02-20 13:24:59 +08:00
|
|
|
if (had_problem)
|
|
|
|
fixit = end_problem_latch(ctx, PR_LATCH_IBITMAP);
|
|
|
|
else
|
|
|
|
fixit = -1;
|
1999-07-19 23:27:37 +08:00
|
|
|
ctx->flags &= ~E2F_FLAG_PROG_SUPPRESS;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (fixit == 1) {
|
|
|
|
ext2fs_free_inode_bitmap(fs->inode_map);
|
|
|
|
retval = ext2fs_copy_bitmap(ctx->inode_used_map,
|
|
|
|
&fs->inode_map);
|
2000-06-11 03:21:33 +08:00
|
|
|
if (retval) {
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
fix_problem(ctx, PR_5_COPY_IBITMAP_ERROR, &pctx);
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
2000-06-11 03:21:33 +08:00
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_set_bitmap_padding(fs->inode_map);
|
|
|
|
ext2fs_mark_ib_dirty(fs);
|
|
|
|
|
|
|
|
/* redo counts */
|
|
|
|
inodes = 0; free_inodes = 0; group_free = 0;
|
|
|
|
dirs_count = 0; group = 0;
|
|
|
|
memset(free_array, 0, fs->group_desc_count * sizeof(int));
|
|
|
|
memset(dir_array, 0, fs->group_desc_count * sizeof(int));
|
|
|
|
goto redo_counts;
|
|
|
|
} else if (fixit == 0)
|
|
|
|
ext2fs_unmark_valid(fs);
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
|
|
|
if (free_array[i] != fs->group_desc[i].bg_free_inodes_count) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.group = i;
|
|
|
|
pctx.ino = fs->group_desc[i].bg_free_inodes_count;
|
|
|
|
pctx.ino2 = free_array[i];
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_INODE_COUNT_GROUP,
|
|
|
|
&pctx)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
fs->group_desc[i].bg_free_inodes_count =
|
|
|
|
free_array[i];
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
|
|
|
if (dir_array[i] != fs->group_desc[i].bg_used_dirs_count) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.group = i;
|
|
|
|
pctx.ino = fs->group_desc[i].bg_used_dirs_count;
|
|
|
|
pctx.ino2 = dir_array[i];
|
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_DIR_COUNT_GROUP,
|
|
|
|
&pctx)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
fs->group_desc[i].bg_used_dirs_count =
|
|
|
|
dir_array[i];
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (free_inodes != fs->super->s_free_inodes_count) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.group = -1;
|
|
|
|
pctx.ino = fs->super->s_free_inodes_count;
|
|
|
|
pctx.ino2 = free_inodes;
|
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_INODE_COUNT, &pctx)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
fs->super->s_free_inodes_count = free_inodes;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
errout:
|
2003-08-01 21:41:07 +08:00
|
|
|
ext2fs_free_mem(&free_array);
|
|
|
|
ext2fs_free_mem(&dir_array);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void check_inode_end(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
Many files:
dirinfo.c, e2fsck.h, emptydir.c, iscan.c, jfs_user.h, journal.c,
message.c, pass1.c, pass1b.c, pass2.c, pass3.c, pass4.c, pass5.c,
problem.h, scantest.c, super.c, swapfs.c: Change ino_t to ext2_ino_t.
2001-01-11 23:12:14 +08:00
|
|
|
ext2_ino_t end, save_inodes_count, i;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
struct problem_context pctx;
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
end = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map, end,
|
|
|
|
&save_inodes_count);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 1;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
if (save_inodes_count == end)
|
|
|
|
return;
|
2006-08-30 14:16:55 +08:00
|
|
|
|
|
|
|
/* protect loop from wrap-around if end is maxed */
|
|
|
|
for (i = save_inodes_count + 1; i <= end && i > save_inodes_count; i++) {
|
1997-04-26 21:34:30 +08:00
|
|
|
if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
for (i = save_inodes_count + 1; i <= end; i++)
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_mark_inode_bitmap(fs->inode_map,
|
1997-04-26 21:21:57 +08:00
|
|
|
i);
|
|
|
|
ext2fs_mark_ib_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map,
|
|
|
|
save_inodes_count, 0);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 2;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void check_block_end(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
1997-04-26 21:34:30 +08:00
|
|
|
blk_t end, save_blocks_count, i;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
struct problem_context pctx;
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
2007-07-23 16:32:48 +08:00
|
|
|
end = ext2fs_get_block_bitmap_start(fs->block_map) +
|
1997-04-26 21:34:30 +08:00
|
|
|
(EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count) - 1;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.errcode = ext2fs_fudge_block_bitmap_end(fs->block_map, end,
|
|
|
|
&save_blocks_count);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 3;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
if (save_blocks_count == end)
|
|
|
|
return;
|
2006-08-30 14:16:55 +08:00
|
|
|
|
|
|
|
/* Protect loop from wrap-around if end is maxed */
|
|
|
|
for (i = save_blocks_count + 1; i <= end && i > save_blocks_count; i++) {
|
1997-04-26 21:34:30 +08:00
|
|
|
if (!ext2fs_test_block_bitmap(fs->block_map, i)) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) {
|
1999-06-18 09:06:59 +08:00
|
|
|
for (i = save_blocks_count + 1; i <= end; i++)
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_mark_block_bitmap(fs->block_map,
|
1997-04-26 21:21:57 +08:00
|
|
|
i);
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.errcode = ext2fs_fudge_block_bitmap_end(fs->block_map,
|
|
|
|
save_blocks_count, 0);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 4;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
|
|
|
|
|