1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* pass5.c --- check block and inode bitmaps against on-disk bitmaps
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
1997-04-29 20:15:03 +04: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%
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
1997-04-26 17:21:57 +04:00
|
|
|
*/
|
|
|
|
|
2011-09-19 01:34:37 +04:00
|
|
|
#include "config.h"
|
2010-11-18 06:38:38 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
#include "problem.h"
|
1997-04-26 17:21:57 +04:00
|
|
|
|
2010-11-18 06:38:38 +03:00
|
|
|
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
|
|
|
|
|
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-03 21:48:10 +04: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);
|
2012-07-31 03:02:04 +04:00
|
|
|
static void check_inode_bitmap_checksum(e2fsck_t ctx);
|
2012-07-31 03:08:04 +04:00
|
|
|
static void check_block_bitmap_checksum(e2fsck_t ctx);
|
1997-04-26 17:21:57 +04:00
|
|
|
|
1997-11-03 22:42:40 +03:00
|
|
|
void e2fsck_pass5(e2fsck_t ctx)
|
1997-04-26 17:21:57 +04:00
|
|
|
{
|
1997-10-20 05:38:32 +04:00
|
|
|
#ifdef RESOURCE_TRACK
|
1997-04-26 17:21:57 +04:00
|
|
|
struct resource_track rtrack;
|
1997-10-20 05:38:32 +04: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-03 21:48:10 +04:00
|
|
|
struct problem_context pctx;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
#ifdef MTRACE
|
|
|
|
mtrace_print("Pass 5");
|
|
|
|
#endif
|
|
|
|
|
2007-08-04 04:07:09 +04:00
|
|
|
init_resource_track(&rtrack, ctx->fs->io);
|
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-03 21:48:10 +04:00
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
if (!(ctx->options & E2F_OPT_PREEN))
|
|
|
|
fix_problem(ctx, PR_5_PASS_HEADER, &pctx);
|
1997-04-26 17:21:57 +04: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 08:23:04 +03:00
|
|
|
if (ctx->progress)
|
1998-05-07 09:02:00 +04:00
|
|
|
if ((ctx->progress)(ctx, 5, 0, ctx->fs->group_desc_count*2))
|
1998-02-24 23:22:23 +03: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 08:23:04 +03: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-03 21:48:10 +04:00
|
|
|
check_block_bitmaps(ctx);
|
1998-02-24 23:22:23 +03:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-03 22:42:40 +03: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-03 21:48:10 +04:00
|
|
|
check_inode_bitmaps(ctx);
|
1998-02-24 23:22:23 +03:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-03 22:42:40 +03: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-03 21:48:10 +04:00
|
|
|
check_inode_end(ctx);
|
1998-02-24 23:22:23 +03:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-03 22:42:40 +03: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-03 21:48:10 +04:00
|
|
|
check_block_end(ctx);
|
1998-02-24 23:22:23 +03:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-03 22:42:40 +03:00
|
|
|
return;
|
1997-04-26 17:21:57 +04:00
|
|
|
|
2012-07-31 03:02:04 +04:00
|
|
|
check_inode_bitmap_checksum(ctx);
|
2012-07-31 03:08:04 +04:00
|
|
|
check_block_bitmap_checksum(ctx);
|
2012-07-31 03:02:04 +04: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-03 21:48:10 +04: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;
|
e2fsck: don't clobber critical metadata during check_blocks
If we encounter an inode with IND/DIND/TIND blocks or internal extent
tree blocks that point into critical FS metadata such as the
superblock, the group descriptors, the bitmaps, or the inode table,
it's quite possible that the validation code for those blocks is not
going to like what it finds, and it'll ask to try to fix the block.
Unfortunately, this happens before duplicate block processing (pass
1b), which means that we can end up doing stupid things like writing
extent blocks into the inode table, which multiplies e2fsck'
destructive effect and can render a filesystem unfixable.
To solve this, create a bitmap of all the critical FS metadata. If
before pass1b runs (basically check_blocks) we find a metadata block
that points into these critical regions, continue processing that
block, but avoid making any modifications, because we could be
misinterpreting inodes as block maps. Pass 1b will find the
multiply-owned blocks and fix that situation, which means that we can
then restart e2fsck from the beginning and actually fix whatever
problems we find.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-23 20:11:23 +04:00
|
|
|
ext2fs_free_block_bitmap(ctx->block_metadata_map);
|
|
|
|
ctx->block_metadata_map = 0;
|
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-03 21:48:10 +04:00
|
|
|
|
2009-05-28 17:55:10 +04:00
|
|
|
print_resource_track(ctx, _("Pass 5"), &rtrack, ctx->fs->io);
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
|
|
|
|
2012-07-31 03:02:04 +04:00
|
|
|
static void check_inode_bitmap_checksum(e2fsck_t ctx)
|
|
|
|
{
|
|
|
|
struct problem_context pctx;
|
2014-11-04 19:35:56 +03:00
|
|
|
char *buf = NULL;
|
2012-07-31 03:02:04 +04:00
|
|
|
dgrp_t i;
|
|
|
|
int nbytes;
|
|
|
|
ext2_ino_t ino_itr;
|
|
|
|
errcode_t retval;
|
|
|
|
|
2015-10-24 07:43:19 +03:00
|
|
|
if (!ext2fs_has_feature_metadata_csum(ctx->fs->super))
|
2012-07-31 03:02:04 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* If bitmap is dirty from being fixed, checksum will be corrected */
|
|
|
|
if (ext2fs_test_ib_dirty(ctx->fs))
|
|
|
|
return;
|
|
|
|
|
|
|
|
nbytes = (size_t)(EXT2_INODES_PER_GROUP(ctx->fs->super) / 8);
|
2014-09-19 09:30:04 +04:00
|
|
|
retval = ext2fs_get_mem(ctx->fs->blocksize, &buf);
|
2012-07-31 03:02:04 +04:00
|
|
|
if (retval) {
|
2014-05-27 21:14:18 +04:00
|
|
|
com_err(ctx->program_name, 0, "%s",
|
2012-07-31 03:02:04 +04:00
|
|
|
_("check_inode_bitmap_checksum: Memory allocation error"));
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
for (i = 0; i < ctx->fs->group_desc_count; i++) {
|
|
|
|
if (ext2fs_bg_flags_test(ctx->fs, i, EXT2_BG_INODE_UNINIT))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ino_itr = 1 + (i * (nbytes << 3));
|
|
|
|
retval = ext2fs_get_inode_bitmap_range2(ctx->fs->inode_map,
|
|
|
|
ino_itr, nbytes << 3,
|
|
|
|
buf);
|
|
|
|
if (retval)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ext2fs_inode_bitmap_csum_verify(ctx->fs, i, buf, nbytes))
|
|
|
|
continue;
|
|
|
|
pctx.group = i;
|
|
|
|
if (!fix_problem(ctx, PR_5_INODE_BITMAP_CSUM_INVALID, &pctx))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fixing one checksum will rewrite all of them. The bitmap
|
|
|
|
* will be checked against the one we made during pass1 for
|
|
|
|
* discrepancies, and fixed if need be.
|
|
|
|
*/
|
|
|
|
ext2fs_mark_ib_dirty(ctx->fs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ext2fs_free_mem(&buf);
|
|
|
|
}
|
|
|
|
|
2012-07-31 03:08:04 +04:00
|
|
|
static void check_block_bitmap_checksum(e2fsck_t ctx)
|
|
|
|
{
|
|
|
|
struct problem_context pctx;
|
2014-11-04 19:35:56 +03:00
|
|
|
char *buf = NULL;
|
2012-07-31 03:08:04 +04:00
|
|
|
dgrp_t i;
|
|
|
|
int nbytes;
|
|
|
|
blk64_t blk_itr;
|
|
|
|
errcode_t retval;
|
|
|
|
|
2015-10-24 07:43:19 +03:00
|
|
|
if (!ext2fs_has_feature_metadata_csum(ctx->fs->super))
|
2012-07-31 03:08:04 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* If bitmap is dirty from being fixed, checksum will be corrected */
|
|
|
|
if (ext2fs_test_bb_dirty(ctx->fs))
|
|
|
|
return;
|
|
|
|
|
|
|
|
nbytes = (size_t)(EXT2_CLUSTERS_PER_GROUP(ctx->fs->super) / 8);
|
2014-09-19 09:30:04 +04:00
|
|
|
retval = ext2fs_get_mem(ctx->fs->blocksize, &buf);
|
2012-07-31 03:08:04 +04:00
|
|
|
if (retval) {
|
2014-05-27 21:14:18 +04:00
|
|
|
com_err(ctx->program_name, 0, "%s",
|
2012-07-31 03:08:04 +04:00
|
|
|
_("check_block_bitmap_checksum: Memory allocation error"));
|
|
|
|
fatal_error(ctx, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
for (i = 0; i < ctx->fs->group_desc_count; i++) {
|
|
|
|
if (ext2fs_bg_flags_test(ctx->fs, i, EXT2_BG_BLOCK_UNINIT))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
blk_itr = EXT2FS_B2C(ctx->fs,
|
|
|
|
ctx->fs->super->s_first_data_block) +
|
2013-09-16 17:41:15 +04:00
|
|
|
((blk64_t) i * (nbytes << 3));
|
2012-07-31 03:08:04 +04:00
|
|
|
retval = ext2fs_get_block_bitmap_range2(ctx->fs->block_map,
|
|
|
|
blk_itr, nbytes << 3,
|
|
|
|
buf);
|
|
|
|
if (retval)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ext2fs_block_bitmap_csum_verify(ctx->fs, i, buf, nbytes))
|
|
|
|
continue;
|
|
|
|
pctx.group = i;
|
|
|
|
if (!fix_problem(ctx, PR_5_BLOCK_BITMAP_CSUM_INVALID, &pctx))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fixing one checksum will rewrite all of them. The bitmap
|
|
|
|
* will be checked against the one we made during pass1 for
|
|
|
|
* discrepancies, and fixed if need be.
|
|
|
|
*/
|
|
|
|
ext2fs_mark_bb_dirty(ctx->fs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ext2fs_free_mem(&buf);
|
|
|
|
}
|
|
|
|
|
2012-03-11 21:39:45 +04:00
|
|
|
static void e2fsck_discard_blocks(e2fsck_t ctx, blk64_t start,
|
|
|
|
blk64_t count)
|
2010-11-18 06:38:38 +03:00
|
|
|
{
|
|
|
|
ext2_filsys fs = ctx->fs;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the filesystem has changed it means that there was an corruption
|
|
|
|
* which should be repaired, but in some cases just one e2fsck run is
|
|
|
|
* not enough to fix the problem, hence it is not safe to run discard
|
|
|
|
* in this case.
|
|
|
|
*/
|
2012-03-11 21:39:45 +04:00
|
|
|
if (ext2fs_test_changed(fs))
|
2010-11-18 06:38:38 +03:00
|
|
|
ctx->options &= ~E2F_OPT_DISCARD;
|
|
|
|
|
2012-03-11 23:35:06 +04:00
|
|
|
if ((ctx->options & E2F_OPT_DISCARD) &&
|
2010-11-18 06:38:38 +03:00
|
|
|
(io_channel_discard(fs->io, start, count)))
|
|
|
|
ctx->options &= ~E2F_OPT_DISCARD;
|
|
|
|
}
|
|
|
|
|
2012-03-11 20:55:45 +04:00
|
|
|
/*
|
|
|
|
* This will try to discard number 'count' inodes starting at
|
|
|
|
* inode number 'start' within the 'group'. Note that 'start'
|
|
|
|
* is 1-based, it means that we need to adjust it by -1 in this
|
|
|
|
* function to compute right offset in the particular inode table.
|
|
|
|
*/
|
2012-04-05 23:13:05 +04:00
|
|
|
static void e2fsck_discard_inodes(e2fsck_t ctx, dgrp_t group,
|
|
|
|
ext2_ino_t start, int count)
|
2012-03-11 20:55:45 +04:00
|
|
|
{
|
|
|
|
ext2_filsys fs = ctx->fs;
|
|
|
|
blk64_t blk, num;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check for 'start'
|
|
|
|
*/
|
|
|
|
if ((start < 1) || (start > EXT2_INODES_PER_GROUP(fs->super))) {
|
|
|
|
printf("PROGRAMMING ERROR: Got start %d outside of group %d!"
|
|
|
|
" Disabling discard\n",
|
|
|
|
start, group);
|
|
|
|
ctx->options &= ~E2F_OPT_DISCARD;
|
|
|
|
}
|
|
|
|
|
2012-03-11 23:36:45 +04:00
|
|
|
/*
|
|
|
|
* Do not attempt to discard if E2F_OPT_DISCARD is not set. And also
|
|
|
|
* skip the discard on this group if discard does not zero data.
|
|
|
|
* The reason is that if the inode table is not zeroed discard would
|
|
|
|
* no help us since we need to zero it anyway, or if the inode table
|
|
|
|
* is zeroed then the read after discard would not be deterministic
|
|
|
|
* anyway and we would not be able to assume that this inode table
|
|
|
|
* was zeroed anymore so we would have to zero it again, which does
|
|
|
|
* not really make sense.
|
|
|
|
*/
|
|
|
|
if (!(ctx->options & E2F_OPT_DISCARD) ||
|
|
|
|
!io_channel_discard_zeroes_data(fs->io))
|
2012-03-11 20:55:45 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start is inode number within the group which starts
|
|
|
|
* counting from 1, so we need to adjust it.
|
|
|
|
*/
|
|
|
|
start -= 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We can discard only blocks containing only unused
|
|
|
|
* inodes in the table.
|
|
|
|
*/
|
|
|
|
blk = DIV_ROUND_UP(start,
|
|
|
|
EXT2_INODES_PER_BLOCK(fs->super));
|
|
|
|
count -= (blk * EXT2_INODES_PER_BLOCK(fs->super) - start);
|
|
|
|
blk += ext2fs_inode_table_loc(fs, group);
|
|
|
|
num = count / EXT2_INODES_PER_BLOCK(fs->super);
|
|
|
|
|
|
|
|
if (num > 0)
|
2012-03-11 21:39:45 +04:00
|
|
|
e2fsck_discard_blocks(ctx, blk, num);
|
2012-03-11 20:55:45 +04:00
|
|
|
}
|
|
|
|
|
2010-06-14 01:00:00 +04:00
|
|
|
#define NO_BLK ((blk64_t) -1)
|
2002-03-07 10:47:07 +03:00
|
|
|
|
2013-12-03 05:52:43 +04:00
|
|
|
static void print_bitmap_problem(e2fsck_t ctx, problem_t problem,
|
2002-03-07 10:47:07 +03: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-28 20:07:41 +04:00
|
|
|
|
2011-06-16 06:15:34 +04:00
|
|
|
/* Just to be more succint */
|
|
|
|
#define B2C(x) EXT2FS_B2C(fs, (x))
|
|
|
|
#define EQ_CLSTR(x, y) (B2C(x) == B2C(y))
|
|
|
|
#define LE_CLSTR(x, y) (B2C(x) <= B2C(y))
|
|
|
|
#define GE_CLSTR(x, y) (B2C(x) >= B2C(y))
|
|
|
|
|
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-03 21:48:10 +04:00
|
|
|
static void check_block_bitmaps(e2fsck_t ctx)
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
ext2_filsys fs = ctx->fs;
|
2009-07-12 05:29:30 +04:00
|
|
|
blk64_t i;
|
2012-04-05 23:13:05 +04:00
|
|
|
unsigned int *free_array;
|
2013-12-03 08:21:31 +04:00
|
|
|
dgrp_t g, group = 0;
|
2012-04-05 23:13:05 +04:00
|
|
|
unsigned int blocks = 0;
|
2010-06-14 01:00:00 +04:00
|
|
|
blk64_t free_blocks = 0;
|
2010-11-18 06:38:38 +03:00
|
|
|
blk64_t first_free = ext2fs_blocks_count(fs->super);
|
2012-04-05 23:13:05 +04:00
|
|
|
unsigned int group_free = 0;
|
1997-04-26 17:21:57 +04:00
|
|
|
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-03 21:48:10 +04:00
|
|
|
struct problem_context pctx;
|
2013-12-03 05:52:43 +04:00
|
|
|
problem_t problem, save_problem;
|
|
|
|
int 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-03 21:48:10 +04:00
|
|
|
errcode_t retval;
|
2009-07-09 21:46:59 +04:00
|
|
|
int redo_flag = 0;
|
2012-11-25 04:17:44 +04:00
|
|
|
char *actual_buf, *bitmap_buf;
|
|
|
|
|
|
|
|
actual_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize,
|
|
|
|
"actual bitmap buffer");
|
|
|
|
bitmap_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize,
|
|
|
|
"bitmap block buffer");
|
2007-03-28 20:07:41 +04: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-03 21:48:10 +04:00
|
|
|
clear_problem_context(&pctx);
|
2012-04-05 23:13:05 +04:00
|
|
|
free_array = (unsigned int *) e2fsck_allocate_memory(ctx,
|
|
|
|
fs->group_desc_count * sizeof(unsigned int), "free block count array");
|
1997-04-26 17:58:21 +04:00
|
|
|
|
2011-06-16 06:15:34 +04:00
|
|
|
if ((B2C(fs->super->s_first_data_block) <
|
2009-08-23 06:29:02 +04:00
|
|
|
ext2fs_get_block_bitmap_start2(ctx->block_found_map)) ||
|
2011-06-16 06:15:34 +04:00
|
|
|
(B2C(ext2fs_blocks_count(fs->super)-1) >
|
2009-08-23 06:29:02 +04:00
|
|
|
ext2fs_get_block_bitmap_end2(ctx->block_found_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-03 21:48:10 +04:00
|
|
|
pctx.num = 1;
|
2011-06-16 06:15:34 +04:00
|
|
|
pctx.blk = B2C(fs->super->s_first_data_block);
|
|
|
|
pctx.blk2 = B2C(ext2fs_blocks_count(fs->super) - 1);
|
2009-08-23 06:29:02 +04:00
|
|
|
pctx.ino = ext2fs_get_block_bitmap_start2(ctx->block_found_map);
|
|
|
|
pctx.ino2 = ext2fs_get_block_bitmap_end2(ctx->block_found_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-03 21:48:10 +04:00
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-03 22:42:40 +03:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-28 20:07:41 +04:00
|
|
|
goto errout;
|
1997-04-26 17:58:21 +04:00
|
|
|
}
|
2007-03-28 20:07:41 +04:00
|
|
|
|
2011-06-16 06:15:34 +04:00
|
|
|
if ((B2C(fs->super->s_first_data_block) <
|
2009-08-23 06:29:02 +04:00
|
|
|
ext2fs_get_block_bitmap_start2(fs->block_map)) ||
|
2011-06-16 06:15:34 +04:00
|
|
|
(B2C(ext2fs_blocks_count(fs->super)-1) >
|
2009-08-23 06:29:02 +04:00
|
|
|
ext2fs_get_block_bitmap_end2(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-03 21:48:10 +04:00
|
|
|
pctx.num = 2;
|
2011-06-16 06:15:34 +04:00
|
|
|
pctx.blk = B2C(fs->super->s_first_data_block);
|
|
|
|
pctx.blk2 = B2C(ext2fs_blocks_count(fs->super) - 1);
|
2009-08-23 06:29:02 +04:00
|
|
|
pctx.ino = ext2fs_get_block_bitmap_start2(fs->block_map);
|
|
|
|
pctx.ino2 = ext2fs_get_block_bitmap_end2(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-03 21:48:10 +04:00
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-03 22:42:40 +03:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-28 20:07:41 +04:00
|
|
|
goto errout;
|
1997-04-26 17:58:21 +04:00
|
|
|
}
|
2007-03-28 20:07:41 +04:00
|
|
|
|
1998-02-20 08:24:59 +03:00
|
|
|
redo_counts:
|
|
|
|
had_problem = 0;
|
2002-03-07 10:47:07 +03:00
|
|
|
save_problem = 0;
|
|
|
|
pctx.blk = pctx.blk2 = NO_BLK;
|
2011-06-16 06:15:34 +04:00
|
|
|
for (i = B2C(fs->super->s_first_data_block);
|
2009-09-08 04:46:34 +04:00
|
|
|
i < ext2fs_blocks_count(fs->super);
|
2011-06-11 02:58:16 +04:00
|
|
|
i += EXT2FS_CLUSTER_RATIO(fs)) {
|
2012-11-25 04:17:44 +04:00
|
|
|
int first_block_in_bg = (B2C(i) -
|
|
|
|
B2C(fs->super->s_first_data_block)) %
|
|
|
|
fs->super->s_clusters_per_group == 0;
|
|
|
|
int n, nbytes = fs->super->s_clusters_per_group / 8;
|
|
|
|
|
2009-08-23 06:29:02 +04:00
|
|
|
actual = ext2fs_fast_test_block_bitmap2(ctx->block_found_map, i);
|
2006-05-09 04:17:26 +04:00
|
|
|
|
2012-11-25 04:17:44 +04:00
|
|
|
/*
|
|
|
|
* Try to optimize pass5 by extracting a bitmap block
|
|
|
|
* as expected from what we have on disk, and then
|
|
|
|
* comparing the two. If they are identical, then
|
|
|
|
* update the free block counts and go on to the next
|
|
|
|
* block group. This is much faster than doing the
|
|
|
|
* individual bit-by-bit comparison. The one downside
|
|
|
|
* is that this doesn't work if we are asking e2fsck
|
|
|
|
* to do a discard operation.
|
|
|
|
*/
|
|
|
|
if (!first_block_in_bg ||
|
2016-05-29 20:36:20 +03:00
|
|
|
(group == fs->group_desc_count - 1) ||
|
2012-11-25 04:17:44 +04:00
|
|
|
(ctx->options & E2F_OPT_DISCARD))
|
|
|
|
goto no_optimize;
|
|
|
|
|
|
|
|
retval = ext2fs_get_block_bitmap_range2(ctx->block_found_map,
|
|
|
|
B2C(i), fs->super->s_clusters_per_group,
|
|
|
|
actual_buf);
|
|
|
|
if (retval)
|
|
|
|
goto no_optimize;
|
2014-01-11 23:05:02 +04:00
|
|
|
retval = ext2fs_get_block_bitmap_range2(fs->block_map,
|
|
|
|
B2C(i), fs->super->s_clusters_per_group,
|
|
|
|
bitmap_buf);
|
|
|
|
if (retval)
|
|
|
|
goto no_optimize;
|
2012-11-25 04:17:44 +04:00
|
|
|
if (memcmp(actual_buf, bitmap_buf, nbytes) != 0)
|
|
|
|
goto no_optimize;
|
|
|
|
n = ext2fs_bitcount(actual_buf, nbytes);
|
|
|
|
group_free = fs->super->s_clusters_per_group - n;
|
|
|
|
free_blocks += group_free;
|
2012-12-16 07:32:23 +04:00
|
|
|
i += EXT2FS_C2B(fs, fs->super->s_clusters_per_group - 1);
|
2012-11-25 04:17:44 +04:00
|
|
|
goto next_group;
|
|
|
|
no_optimize:
|
|
|
|
|
2014-01-11 23:05:02 +04:00
|
|
|
if (redo_flag)
|
2009-07-09 21:46:59 +04:00
|
|
|
bitmap = actual;
|
|
|
|
else
|
2009-08-23 06:29:02 +04:00
|
|
|
bitmap = ext2fs_fast_test_block_bitmap2(fs->block_map, i);
|
2007-03-28 20:07:41 +04:00
|
|
|
|
2011-12-17 20:56:35 +04:00
|
|
|
if (!actual == !bitmap)
|
1997-04-26 17:21:57 +04:00
|
|
|
goto do_counts;
|
2006-05-09 04:17:26 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
if (!actual && bitmap) {
|
|
|
|
/*
|
|
|
|
* Block not used, but marked in use in the bitmap.
|
|
|
|
*/
|
2002-03-07 10:47:07 +03:00
|
|
|
problem = PR_5_BLOCK_UNUSED;
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
problem = PR_5_BLOCK_USED;
|
2007-10-22 06:04:03 +04:00
|
|
|
|
2014-01-11 23:05:02 +04:00
|
|
|
if (ext2fs_bg_flags_test(fs, group,
|
|
|
|
EXT2_BG_BLOCK_UNINIT)) {
|
2007-10-22 06:04:03 +04:00
|
|
|
struct problem_context pctx2;
|
|
|
|
pctx2.blk = i;
|
|
|
|
pctx2.group = group;
|
2014-01-11 23:05:02 +04:00
|
|
|
if (fix_problem(ctx, PR_5_BLOCK_UNINIT,
|
|
|
|
&pctx2))
|
|
|
|
ext2fs_bg_flags_clear(fs, group,
|
|
|
|
EXT2_BG_BLOCK_UNINIT);
|
2007-10-22 06:04:03 +04:00
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
2002-03-07 10:47:07 +03:00
|
|
|
if (pctx.blk == NO_BLK) {
|
|
|
|
pctx.blk = pctx.blk2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
} else {
|
|
|
|
if ((problem == save_problem) &&
|
2013-12-16 08:53:32 +04:00
|
|
|
(pctx.blk2 == i - EXT2FS_CLUSTER_RATIO(fs)))
|
|
|
|
pctx.blk2 += EXT2FS_CLUSTER_RATIO(fs);
|
2002-03-07 10:47:07 +03:00
|
|
|
else {
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
|
|
|
pctx.blk = pctx.blk2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
}
|
|
|
|
}
|
1999-07-19 19:27:37 +04:00
|
|
|
ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
|
1998-02-20 08:24:59 +03:00
|
|
|
had_problem++;
|
2007-03-28 20:07:41 +04:00
|
|
|
|
2010-11-18 06:38:38 +03:00
|
|
|
/*
|
|
|
|
* If there a problem we should turn off the discard so we
|
|
|
|
* do not compromise the filesystem.
|
|
|
|
*/
|
|
|
|
ctx->options &= ~E2F_OPT_DISCARD;
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
do_counts:
|
2012-03-11 22:15:19 +04:00
|
|
|
if (!bitmap) {
|
1997-04-26 17:21:57 +04:00
|
|
|
group_free++;
|
|
|
|
free_blocks++;
|
2010-11-18 06:38:38 +03:00
|
|
|
if (first_free > i)
|
|
|
|
first_free = i;
|
2012-03-11 22:15:19 +04:00
|
|
|
} else if (i > first_free) {
|
|
|
|
e2fsck_discard_blocks(ctx, first_free,
|
|
|
|
(i - first_free));
|
2010-11-18 06:38:38 +03:00
|
|
|
first_free = ext2fs_blocks_count(fs->super);
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
|
|
|
blocks ++;
|
2011-06-11 02:58:16 +04:00
|
|
|
if ((blocks == fs->super->s_clusters_per_group) ||
|
|
|
|
(EXT2FS_B2C(fs, i) ==
|
|
|
|
EXT2FS_B2C(fs, ext2fs_blocks_count(fs->super)-1))) {
|
2012-03-05 11:49:34 +04:00
|
|
|
/*
|
|
|
|
* If the last block of this group is free, then we can
|
|
|
|
* discard it as well.
|
|
|
|
*/
|
|
|
|
if (!bitmap && i >= first_free)
|
|
|
|
e2fsck_discard_blocks(ctx, first_free,
|
|
|
|
(i - first_free) + 1);
|
2012-11-25 04:17:44 +04:00
|
|
|
next_group:
|
2012-03-05 11:49:34 +04:00
|
|
|
first_free = ext2fs_blocks_count(fs->super);
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
free_array[group] = group_free;
|
|
|
|
group ++;
|
|
|
|
blocks = 0;
|
|
|
|
group_free = 0;
|
1998-05-07 09:02:00 +04:00
|
|
|
if (ctx->progress)
|
|
|
|
if ((ctx->progress)(ctx, 5, group,
|
|
|
|
fs->group_desc_count*2))
|
2007-03-28 20:07:41 +04:00
|
|
|
goto errout;
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
|
|
|
}
|
2002-03-07 10:47:07 +03:00
|
|
|
if (pctx.blk != NO_BLK)
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
1998-02-20 08:24:59 +03:00
|
|
|
if (had_problem)
|
2002-03-07 10:47:07 +03:00
|
|
|
fixit = end_problem_latch(ctx, PR_LATCH_BBITMAP);
|
1998-02-20 08:24:59 +03:00
|
|
|
else
|
|
|
|
fixit = -1;
|
1999-07-19 19:27:37 +04:00
|
|
|
ctx->flags &= ~E2F_FLAG_PROG_SUPPRESS;
|
2007-03-28 20:07:41 +04: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-03 21:48:10 +04:00
|
|
|
if (fixit == 1) {
|
|
|
|
ext2fs_free_block_bitmap(fs->block_map);
|
|
|
|
retval = ext2fs_copy_bitmap(ctx->block_found_map,
|
|
|
|
&fs->block_map);
|
2000-06-10 23:21:33 +04:00
|
|
|
if (retval) {
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
fix_problem(ctx, PR_5_COPY_BBITMAP_ERROR, &pctx);
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
2007-03-28 20:07:41 +04:00
|
|
|
goto errout;
|
2000-06-10 23:21:33 +04: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-03 21:48:10 +04:00
|
|
|
ext2fs_set_bitmap_padding(fs->block_map);
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
2007-03-28 20:07:41 +04: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-03 21:48:10 +04:00
|
|
|
/* Redo the counts */
|
|
|
|
blocks = 0; free_blocks = 0; group_free = 0; group = 0;
|
|
|
|
memset(free_array, 0, fs->group_desc_count * sizeof(int));
|
2009-07-09 21:46:59 +04:00
|
|
|
redo_flag++;
|
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-03 21:48:10 +04:00
|
|
|
goto redo_counts;
|
|
|
|
} else if (fixit == 0)
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
|
2013-12-03 08:21:31 +04:00
|
|
|
for (g = 0; g < fs->group_desc_count; g++) {
|
|
|
|
if (free_array[g] != ext2fs_bg_free_blocks_count(fs, g)) {
|
|
|
|
pctx.group = g;
|
|
|
|
pctx.blk = ext2fs_bg_free_blocks_count(fs, g);
|
|
|
|
pctx.blk2 = free_array[g];
|
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-03 21:48:10 +04:00
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT_GROUP,
|
|
|
|
&pctx)) {
|
2013-12-03 08:21:31 +04:00
|
|
|
ext2fs_bg_free_blocks_count_set(fs, g, free_array[g]);
|
1997-04-26 17:21:57 +04:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 09:38:43 +04:00
|
|
|
free_blocks = EXT2FS_C2B(fs, free_blocks);
|
2009-09-08 04:46:34 +04:00
|
|
|
if (free_blocks != ext2fs_free_blocks_count(fs->super)) {
|
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-03 21:48:10 +04:00
|
|
|
pctx.group = 0;
|
2009-09-08 04:46:34 +04:00
|
|
|
pctx.blk = ext2fs_free_blocks_count(fs->super);
|
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-03 21:48:10 +04:00
|
|
|
pctx.blk2 = free_blocks;
|
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT, &pctx)) {
|
2009-09-08 04:46:34 +04:00
|
|
|
ext2fs_free_blocks_count_set(fs->super, free_blocks);
|
1997-04-26 17:21:57 +04:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2012-04-25 00:22:48 +04:00
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
2007-03-28 20:07:41 +04:00
|
|
|
errout:
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&free_array);
|
2012-11-25 04:17:44 +04:00
|
|
|
ext2fs_free_mem(&actual_buf);
|
|
|
|
ext2fs_free_mem(&bitmap_buf);
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
2007-03-28 20:07:41 +04: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-03 21:48:10 +04:00
|
|
|
static void check_inode_bitmaps(e2fsck_t ctx)
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04: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 18:12:14 +03:00
|
|
|
ext2_ino_t i;
|
2003-12-07 09:28:50 +03:00
|
|
|
unsigned int free_inodes = 0;
|
|
|
|
int group_free = 0;
|
|
|
|
int dirs_count = 0;
|
2013-12-03 08:21:31 +04:00
|
|
|
dgrp_t group = 0;
|
2003-12-07 09:28:50 +03:00
|
|
|
unsigned int inodes = 0;
|
2012-04-05 23:13:05 +04:00
|
|
|
ext2_ino_t *free_array;
|
|
|
|
ext2_ino_t *dir_array;
|
2003-12-07 09:28:50 +03:00
|
|
|
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-03 21:48:10 +04:00
|
|
|
errcode_t retval;
|
|
|
|
struct problem_context pctx;
|
2013-12-03 05:52:43 +04:00
|
|
|
problem_t problem, save_problem;
|
|
|
|
int fixit, had_problem;
|
2008-04-21 07:33:34 +04:00
|
|
|
int csum_flag;
|
2006-05-09 04:17:26 +04:00
|
|
|
int skip_group = 0;
|
2009-07-09 21:46:59 +04:00
|
|
|
int redo_flag = 0;
|
2012-04-05 23:13:05 +04:00
|
|
|
ext2_ino_t first_free = fs->super->s_inodes_per_group + 1;
|
2007-03-28 20:07:41 +04: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-03 21:48:10 +04:00
|
|
|
clear_problem_context(&pctx);
|
2012-04-05 23:13:05 +04:00
|
|
|
free_array = (ext2_ino_t *) e2fsck_allocate_memory(ctx,
|
|
|
|
fs->group_desc_count * sizeof(ext2_ino_t), "free inode count array");
|
2007-03-28 20:07:41 +04:00
|
|
|
|
2012-04-05 23:13:05 +04:00
|
|
|
dir_array = (ext2_ino_t *) e2fsck_allocate_memory(ctx,
|
|
|
|
fs->group_desc_count * sizeof(ext2_ino_t), "directory count array");
|
2007-03-28 20:07:41 +04:00
|
|
|
|
2009-08-23 06:29:02 +04:00
|
|
|
if ((1 < ext2fs_get_inode_bitmap_start2(ctx->inode_used_map)) ||
|
2007-03-28 20:07:41 +04:00
|
|
|
(fs->super->s_inodes_count >
|
2009-08-23 06:29:02 +04:00
|
|
|
ext2fs_get_inode_bitmap_end2(ctx->inode_used_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-03 21:48:10 +04:00
|
|
|
pctx.num = 3;
|
|
|
|
pctx.blk = 1;
|
|
|
|
pctx.blk2 = fs->super->s_inodes_count;
|
2009-08-23 06:29:02 +04:00
|
|
|
pctx.ino = ext2fs_get_inode_bitmap_start2(ctx->inode_used_map);
|
|
|
|
pctx.ino2 = ext2fs_get_inode_bitmap_end2(ctx->inode_used_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-03 21:48:10 +04:00
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-03 22:42:40 +03:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-28 20:07:41 +04:00
|
|
|
goto errout;
|
1997-04-26 17:58:21 +04:00
|
|
|
}
|
2009-08-23 06:29:02 +04:00
|
|
|
if ((1 < ext2fs_get_inode_bitmap_start2(fs->inode_map)) ||
|
2007-03-28 20:07:41 +04:00
|
|
|
(fs->super->s_inodes_count >
|
2009-08-23 06:29:02 +04:00
|
|
|
ext2fs_get_inode_bitmap_end2(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-03 21:48:10 +04:00
|
|
|
pctx.num = 4;
|
|
|
|
pctx.blk = 1;
|
|
|
|
pctx.blk2 = fs->super->s_inodes_count;
|
2009-08-23 06:29:02 +04:00
|
|
|
pctx.ino = ext2fs_get_inode_bitmap_start2(fs->inode_map);
|
|
|
|
pctx.ino2 = ext2fs_get_inode_bitmap_end2(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-03 21:48:10 +04:00
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-03 22:42:40 +03:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-28 20:07:41 +04:00
|
|
|
goto errout;
|
1997-04-26 17:58:21 +04:00
|
|
|
}
|
|
|
|
|
2012-08-03 04:47:45 +04:00
|
|
|
csum_flag = ext2fs_has_group_desc_csum(fs);
|
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-03 21:48:10 +04:00
|
|
|
redo_counts:
|
1998-02-20 08:24:59 +03:00
|
|
|
had_problem = 0;
|
2002-03-07 10:47:07 +03:00
|
|
|
save_problem = 0;
|
|
|
|
pctx.ino = pctx.ino2 = 0;
|
2008-04-21 07:33:34 +04:00
|
|
|
if (csum_flag &&
|
2009-10-26 04:42:12 +03:00
|
|
|
(ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT)))
|
2006-05-09 04:17:26 +04:00
|
|
|
skip_group++;
|
|
|
|
|
2006-08-30 10:16:55 +04:00
|
|
|
/* Protect loop from wrap-around if inodes_count is maxed */
|
|
|
|
for (i = 1; i <= fs->super->s_inodes_count && i > 0; i++) {
|
2009-07-09 21:46:59 +04:00
|
|
|
bitmap = 0;
|
|
|
|
if (skip_group &&
|
|
|
|
i % fs->super->s_inodes_per_group == 1) {
|
|
|
|
/*
|
|
|
|
* Current inode is the first inode
|
|
|
|
* in the current block group.
|
|
|
|
*/
|
|
|
|
if (ext2fs_test_inode_bitmap_range(
|
|
|
|
ctx->inode_used_map, i,
|
|
|
|
fs->super->s_inodes_per_group)) {
|
|
|
|
/*
|
|
|
|
* When the compared inodes in inodes bitmap
|
|
|
|
* are 0, count the free inode,
|
|
|
|
* skip the current block group.
|
|
|
|
*/
|
2012-03-11 20:55:45 +04:00
|
|
|
first_free = 1;
|
2009-07-09 21:46:59 +04:00
|
|
|
inodes = fs->super->s_inodes_per_group - 1;
|
|
|
|
group_free = inodes;
|
|
|
|
free_inodes += inodes;
|
|
|
|
i += inodes;
|
|
|
|
skip_group = 0;
|
|
|
|
goto do_counts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 06:29:02 +04:00
|
|
|
actual = ext2fs_fast_test_inode_bitmap2(ctx->inode_used_map, i);
|
2009-07-09 21:46:59 +04:00
|
|
|
if (redo_flag)
|
|
|
|
bitmap = actual;
|
|
|
|
else if (!skip_group)
|
2009-08-23 06:29:02 +04:00
|
|
|
bitmap = ext2fs_fast_test_inode_bitmap2(fs->inode_map, i);
|
2011-12-17 20:56:35 +04:00
|
|
|
if (!actual == !bitmap)
|
1997-04-26 17:21:57 +04:00
|
|
|
goto do_counts;
|
2007-03-28 20:07:41 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
if (!actual && bitmap) {
|
|
|
|
/*
|
|
|
|
* Inode wasn't used, but marked in bitmap
|
|
|
|
*/
|
2002-03-07 10:47:07 +03: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-03 21:48:10 +04:00
|
|
|
} else /* if (actual && !bitmap) */ {
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
problem = PR_5_INODE_USED;
|
2007-10-22 06:04:03 +04:00
|
|
|
|
|
|
|
/* We should never hit this, because it means that
|
|
|
|
* inodes were marked in use that weren't noticed
|
|
|
|
* in pass1 or pass 2. It is easier to fix the problem
|
|
|
|
* than to kill e2fsck and leave the user stuck. */
|
|
|
|
if (skip_group) {
|
|
|
|
struct problem_context pctx2;
|
|
|
|
pctx2.blk = i;
|
|
|
|
pctx2.group = group;
|
|
|
|
if (fix_problem(ctx, PR_5_INODE_UNINIT,&pctx2)){
|
libext2fs: clean up ext2fs_bg_flags_ interfaces
The ext2fs_bg_flag* functions were confusing.
Currently we have this:
void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags);
(_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags)
and these, which can twiddle individual bits in bg_flags:
void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
A better interface, after the patch below, is just:
ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */
ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */
ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */
and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:41:32 +03:00
|
|
|
ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
|
2007-10-22 06:04:03 +04:00
|
|
|
skip_group = 0;
|
|
|
|
}
|
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
2002-03-07 10:47:07 +03: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 19:27:37 +04:00
|
|
|
ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
|
1998-02-20 08:24:59 +03:00
|
|
|
had_problem++;
|
2010-11-18 06:38:38 +03:00
|
|
|
/*
|
|
|
|
* If there a problem we should turn off the discard so we
|
|
|
|
* do not compromise the filesystem.
|
|
|
|
*/
|
|
|
|
ctx->options &= ~E2F_OPT_DISCARD;
|
2007-03-28 20:07:41 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
do_counts:
|
2012-03-11 20:55:45 +04:00
|
|
|
inodes++;
|
2006-05-09 04:17:26 +04:00
|
|
|
if (bitmap) {
|
2009-08-23 06:29:02 +04:00
|
|
|
if (ext2fs_test_inode_bitmap2(ctx->inode_dir_map, i))
|
1997-04-26 17:21:57 +04:00
|
|
|
dirs_count++;
|
2012-03-11 20:55:45 +04:00
|
|
|
if (inodes > first_free) {
|
|
|
|
e2fsck_discard_inodes(ctx, group, first_free,
|
|
|
|
inodes - first_free);
|
|
|
|
first_free = fs->super->s_inodes_per_group + 1;
|
|
|
|
}
|
2012-03-11 22:15:19 +04:00
|
|
|
} else {
|
2006-05-09 04:17:26 +04:00
|
|
|
group_free++;
|
|
|
|
free_inodes++;
|
2012-03-11 20:55:45 +04:00
|
|
|
if (first_free > inodes)
|
|
|
|
first_free = inodes;
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
2010-11-18 06:38:38 +03:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
if ((inodes == fs->super->s_inodes_per_group) ||
|
|
|
|
(i == fs->super->s_inodes_count)) {
|
2012-03-11 20:55:45 +04:00
|
|
|
/*
|
|
|
|
* If the last inode is free, we can discard it as well.
|
|
|
|
*/
|
|
|
|
if (!bitmap && inodes >= first_free)
|
|
|
|
e2fsck_discard_inodes(ctx, group, first_free,
|
|
|
|
inodes - first_free + 1);
|
2010-11-18 06:38:38 +03:00
|
|
|
/*
|
|
|
|
* If discard zeroes data and the group inode table
|
|
|
|
* was not zeroed yet, set itable as zeroed
|
|
|
|
*/
|
|
|
|
if ((ctx->options & E2F_OPT_DISCARD) &&
|
2012-03-11 20:55:45 +04:00
|
|
|
io_channel_discard_zeroes_data(fs->io) &&
|
2010-11-18 06:38:38 +03:00
|
|
|
!(ext2fs_bg_flags_test(fs, group,
|
2012-03-11 20:55:45 +04:00
|
|
|
EXT2_BG_INODE_ZEROED))) {
|
2010-11-18 06:38:38 +03:00
|
|
|
ext2fs_bg_flags_set(fs, group,
|
|
|
|
EXT2_BG_INODE_ZEROED);
|
|
|
|
ext2fs_group_desc_csum_set(fs, group);
|
|
|
|
}
|
|
|
|
|
2012-03-11 20:55:45 +04:00
|
|
|
first_free = fs->super->s_inodes_per_group + 1;
|
|
|
|
free_array[group] = group_free;
|
|
|
|
dir_array[group] = dirs_count;
|
1997-04-26 17:21:57 +04:00
|
|
|
group ++;
|
|
|
|
inodes = 0;
|
2006-05-09 04:17:26 +04:00
|
|
|
skip_group = 0;
|
1997-04-26 17:21:57 +04:00
|
|
|
group_free = 0;
|
|
|
|
dirs_count = 0;
|
1998-05-07 09:02:00 +04:00
|
|
|
if (ctx->progress)
|
|
|
|
if ((ctx->progress)(ctx, 5,
|
|
|
|
group + fs->group_desc_count,
|
|
|
|
fs->group_desc_count*2))
|
2007-03-28 20:07:41 +04:00
|
|
|
goto errout;
|
2008-04-21 07:33:34 +04:00
|
|
|
if (csum_flag &&
|
2006-05-09 04:17:26 +04:00
|
|
|
(i != fs->super->s_inodes_count) &&
|
2009-10-26 04:42:12 +03:00
|
|
|
(ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT)
|
2009-09-08 05:15:12 +04:00
|
|
|
))
|
2006-05-09 04:17:26 +04:00
|
|
|
skip_group++;
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
|
|
|
}
|
2002-03-07 10:47:07 +03:00
|
|
|
if (pctx.ino)
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
2007-03-28 20:07:41 +04:00
|
|
|
|
1998-02-20 08:24:59 +03:00
|
|
|
if (had_problem)
|
|
|
|
fixit = end_problem_latch(ctx, PR_LATCH_IBITMAP);
|
|
|
|
else
|
|
|
|
fixit = -1;
|
1999-07-19 19:27:37 +04:00
|
|
|
ctx->flags &= ~E2F_FLAG_PROG_SUPPRESS;
|
2007-03-28 20:07:41 +04: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-03 21:48:10 +04:00
|
|
|
if (fixit == 1) {
|
|
|
|
ext2fs_free_inode_bitmap(fs->inode_map);
|
|
|
|
retval = ext2fs_copy_bitmap(ctx->inode_used_map,
|
|
|
|
&fs->inode_map);
|
2000-06-10 23:21:33 +04:00
|
|
|
if (retval) {
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
fix_problem(ctx, PR_5_COPY_IBITMAP_ERROR, &pctx);
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
2007-03-28 20:07:41 +04:00
|
|
|
goto errout;
|
2000-06-10 23:21:33 +04: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-03 21:48:10 +04: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));
|
2009-07-09 21:46:59 +04:00
|
|
|
redo_flag++;
|
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-03 21:48:10 +04:00
|
|
|
goto redo_counts;
|
|
|
|
} else if (fixit == 0)
|
|
|
|
ext2fs_unmark_valid(fs);
|
2007-03-28 20:07:41 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:43:47 +03:00
|
|
|
if (free_array[i] != ext2fs_bg_free_inodes_count(fs, 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-03 21:48:10 +04:00
|
|
|
pctx.group = i;
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:43:47 +03:00
|
|
|
pctx.ino = ext2fs_bg_free_inodes_count(fs, 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-03 21:48:10 +04:00
|
|
|
pctx.ino2 = free_array[i];
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_INODE_COUNT_GROUP,
|
|
|
|
&pctx)) {
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:43:47 +03:00
|
|
|
ext2fs_bg_free_inodes_count_set(fs, i, free_array[i]);
|
1997-04-26 17:21:57 +04:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:43:47 +03:00
|
|
|
if (dir_array[i] != ext2fs_bg_used_dirs_count(fs, 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-03 21:48:10 +04:00
|
|
|
pctx.group = i;
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:43:47 +03:00
|
|
|
pctx.ino = ext2fs_bg_used_dirs_count(fs, 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-03 21:48:10 +04:00
|
|
|
pctx.ino2 = dir_array[i];
|
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_DIR_COUNT_GROUP,
|
|
|
|
&pctx)) {
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:43:47 +03:00
|
|
|
ext2fs_bg_used_dirs_count_set(fs, i, dir_array[i]);
|
1997-04-26 17:21:57 +04:00
|
|
|
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-03 21:48:10 +04: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 17:21:57 +04:00
|
|
|
fs->super->s_free_inodes_count = free_inodes;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
2012-04-25 00:22:48 +04:00
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
2007-03-28 20:07:41 +04:00
|
|
|
errout:
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&free_array);
|
|
|
|
ext2fs_free_mem(&dir_array);
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
static void check_inode_end(e2fsck_t ctx)
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04: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 18:12:14 +03: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-03 21:48:10 +04:00
|
|
|
struct problem_context pctx;
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04: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-03 22:42:40 +03:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 17:34:30 +04:00
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
if (save_inodes_count == end)
|
|
|
|
return;
|
2006-08-30 10:16:55 +04:00
|
|
|
|
2008-08-28 07:07:54 +04:00
|
|
|
/* protect loop from wrap-around if end is maxed */
|
2006-08-30 10:16:55 +04:00
|
|
|
for (i = save_inodes_count + 1; i <= end && i > save_inodes_count; i++) {
|
1997-04-26 17:34:30 +04: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-03 21:48:10 +04:00
|
|
|
if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) {
|
2009-07-06 12:15:24 +04:00
|
|
|
for (; i <= end; i++)
|
1997-04-26 17:34:30 +04:00
|
|
|
ext2fs_mark_inode_bitmap(fs->inode_map,
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04: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-03 22:42:40 +03:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 17:34:30 +04:00
|
|
|
}
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
static void check_block_end(e2fsck_t ctx)
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
ext2_filsys fs = ctx->fs;
|
2009-08-23 06:29:02 +04:00
|
|
|
blk64_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-03 21:48:10 +04:00
|
|
|
struct problem_context pctx;
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 17:21:57 +04:00
|
|
|
|
2009-08-23 06:29:02 +04:00
|
|
|
end = ext2fs_get_block_bitmap_start2(fs->block_map) +
|
2014-07-26 15:40:36 +04:00
|
|
|
EXT2_GROUPS_TO_CLUSTERS(fs->super, fs->group_desc_count) - 1;
|
2009-08-23 06:29:02 +04:00
|
|
|
pctx.errcode = ext2fs_fudge_block_bitmap_end2(fs->block_map, end,
|
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-03 21:48:10 +04:00
|
|
|
&save_blocks_count);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 3;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-03 22:42:40 +03:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 17:34:30 +04:00
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
if (save_blocks_count == end)
|
|
|
|
return;
|
2006-08-30 10:16:55 +04:00
|
|
|
|
2008-08-28 07:07:54 +04:00
|
|
|
/* Protect loop from wrap-around if end is maxed */
|
2006-08-30 10:16:55 +04:00
|
|
|
for (i = save_blocks_count + 1; i <= end && i > save_blocks_count; i++) {
|
2011-06-11 02:58:16 +04:00
|
|
|
if (!ext2fs_test_block_bitmap2(fs->block_map,
|
|
|
|
EXT2FS_C2B(fs, 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-03 21:48:10 +04:00
|
|
|
if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) {
|
2009-07-06 12:15:24 +04:00
|
|
|
for (; i <= end; i++)
|
2009-08-23 06:29:02 +04:00
|
|
|
ext2fs_mark_block_bitmap2(fs->block_map,
|
2011-06-11 02:58:16 +04:00
|
|
|
EXT2FS_C2B(fs, i));
|
1997-04-26 17:21:57 +04:00
|
|
|
ext2fs_mark_bb_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 06:29:02 +04:00
|
|
|
pctx.errcode = ext2fs_fudge_block_bitmap_end2(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-03 21:48:10 +04:00
|
|
|
save_blocks_count, 0);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 4;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-03 22:42:40 +03:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 17:34:30 +04:00
|
|
|
}
|
1997-04-26 17:21:57 +04: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-03 21:48:10 +04:00
|
|
|
|
|
|
|
|