1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* pass5.c --- check block and inode bitmaps against on-disk bitmaps
|
2008-08-28 11:07:54 +08:00
|
|
|
*
|
1997-04-30 00:15:03 +08:00
|
|
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
2008-08-28 11:07:54 +08:00
|
|
|
*
|
1997-04-26 21:21:57 +08:00
|
|
|
*/
|
|
|
|
|
2011-09-19 05:34:37 +08:00
|
|
|
#include "config.h"
|
2010-11-18 11:38:38 +08: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 21:21:57 +08:00
|
|
|
#include "e2fsck.h"
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
#include "problem.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
|
2010-11-18 11:38:38 +08: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-04 01:48:10 +08:00
|
|
|
static void check_block_bitmaps(e2fsck_t ctx);
|
|
|
|
static void check_inode_bitmaps(e2fsck_t ctx);
|
|
|
|
static void check_inode_end(e2fsck_t ctx);
|
|
|
|
static void check_block_end(e2fsck_t ctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
1997-11-04 03:42:40 +08:00
|
|
|
void e2fsck_pass5(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
1997-10-20 09:38:32 +08:00
|
|
|
#ifdef RESOURCE_TRACK
|
1997-04-26 21:21:57 +08:00
|
|
|
struct resource_track rtrack;
|
1997-10-20 09:38:32 +08:00
|
|
|
#endif
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
struct problem_context pctx;
|
2008-08-28 11:07:54 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
#ifdef MTRACE
|
|
|
|
mtrace_print("Pass 5");
|
|
|
|
#endif
|
|
|
|
|
2007-08-04 08:07:09 +08: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-04 01:48:10 +08:00
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (!(ctx->options & E2F_OPT_PREEN))
|
|
|
|
fix_problem(ctx, PR_5_PASS_HEADER, &pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 13:23:04 +08:00
|
|
|
if (ctx->progress)
|
1998-05-07 13:02:00 +08:00
|
|
|
if ((ctx->progress)(ctx, 5, 0, ctx->fs->group_desc_count*2))
|
1998-02-25 04:22:23 +08:00
|
|
|
return;
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 13:23:04 +08:00
|
|
|
|
|
|
|
e2fsck_read_bitmaps(ctx);
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
check_block_bitmaps(ctx);
|
1998-02-25 04:22:23 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-04 03:42:40 +08:00
|
|
|
return;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
check_inode_bitmaps(ctx);
|
1998-02-25 04:22:23 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-04 03:42:40 +08:00
|
|
|
return;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
check_inode_end(ctx);
|
1998-02-25 04:22:23 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-04 03:42:40 +08:00
|
|
|
return;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
check_block_end(ctx);
|
1998-02-25 04:22:23 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
1997-11-04 03:42:40 +08:00
|
|
|
return;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_free_inode_bitmap(ctx->inode_used_map);
|
|
|
|
ctx->inode_used_map = 0;
|
|
|
|
ext2fs_free_inode_bitmap(ctx->inode_dir_map);
|
|
|
|
ctx->inode_dir_map = 0;
|
|
|
|
ext2fs_free_block_bitmap(ctx->block_found_map);
|
|
|
|
ctx->block_found_map = 0;
|
|
|
|
|
2009-05-28 21:55:10 +08:00
|
|
|
print_resource_track(ctx, _("Pass 5"), &rtrack, ctx->fs->io);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
2012-03-12 01:39:45 +08:00
|
|
|
static void e2fsck_discard_blocks(e2fsck_t ctx, blk64_t start,
|
|
|
|
blk64_t count)
|
2010-11-18 11:38:38 +08: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-12 01:39:45 +08:00
|
|
|
if (ext2fs_test_changed(fs))
|
2010-11-18 11:38:38 +08:00
|
|
|
ctx->options &= ~E2F_OPT_DISCARD;
|
|
|
|
|
2012-03-12 03:35:06 +08:00
|
|
|
if ((ctx->options & E2F_OPT_DISCARD) &&
|
2010-11-18 11:38:38 +08:00
|
|
|
(io_channel_discard(fs->io, start, count)))
|
|
|
|
ctx->options &= ~E2F_OPT_DISCARD;
|
|
|
|
}
|
|
|
|
|
2012-03-12 00:55:45 +08: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-06 03:13:05 +08:00
|
|
|
static void e2fsck_discard_inodes(e2fsck_t ctx, dgrp_t group,
|
|
|
|
ext2_ino_t start, int count)
|
2012-03-12 00:55:45 +08: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-12 03:36:45 +08: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-12 00:55:45 +08: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-12 01:39:45 +08:00
|
|
|
e2fsck_discard_blocks(ctx, blk, num);
|
2012-03-12 00:55:45 +08:00
|
|
|
}
|
|
|
|
|
2010-06-14 05:00:00 +08:00
|
|
|
#define NO_BLK ((blk64_t) -1)
|
2002-03-07 15:47:07 +08:00
|
|
|
|
2013-12-03 09:52:43 +08:00
|
|
|
static void print_bitmap_problem(e2fsck_t ctx, problem_t problem,
|
2002-03-07 15:47:07 +08:00
|
|
|
struct problem_context *pctx)
|
|
|
|
{
|
|
|
|
switch (problem) {
|
|
|
|
case PR_5_BLOCK_UNUSED:
|
|
|
|
if (pctx->blk == pctx->blk2)
|
|
|
|
pctx->blk2 = 0;
|
|
|
|
else
|
|
|
|
problem = PR_5_BLOCK_RANGE_UNUSED;
|
|
|
|
break;
|
|
|
|
case PR_5_BLOCK_USED:
|
|
|
|
if (pctx->blk == pctx->blk2)
|
|
|
|
pctx->blk2 = 0;
|
|
|
|
else
|
|
|
|
problem = PR_5_BLOCK_RANGE_USED;
|
|
|
|
break;
|
|
|
|
case PR_5_INODE_UNUSED:
|
|
|
|
if (pctx->ino == pctx->ino2)
|
|
|
|
pctx->ino2 = 0;
|
|
|
|
else
|
|
|
|
problem = PR_5_INODE_RANGE_UNUSED;
|
|
|
|
break;
|
|
|
|
case PR_5_INODE_USED:
|
|
|
|
if (pctx->ino == pctx->ino2)
|
|
|
|
pctx->ino2 = 0;
|
|
|
|
else
|
|
|
|
problem = PR_5_INODE_RANGE_USED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fix_problem(ctx, problem, pctx);
|
|
|
|
pctx->blk = pctx->blk2 = NO_BLK;
|
|
|
|
pctx->ino = pctx->ino2 = 0;
|
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
|
2011-06-16 10:15:34 +08: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-04 01:48:10 +08:00
|
|
|
static void check_block_bitmaps(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
2009-07-12 09:29:30 +08:00
|
|
|
blk64_t i;
|
2012-04-06 03:13:05 +08:00
|
|
|
unsigned int *free_array;
|
2013-12-03 12:21:31 +08:00
|
|
|
dgrp_t g, group = 0;
|
2012-04-06 03:13:05 +08:00
|
|
|
unsigned int blocks = 0;
|
2010-06-14 05:00:00 +08:00
|
|
|
blk64_t free_blocks = 0;
|
2010-11-18 11:38:38 +08:00
|
|
|
blk64_t first_free = ext2fs_blocks_count(fs->super);
|
2012-04-06 03:13:05 +08:00
|
|
|
unsigned int group_free = 0;
|
1997-04-26 21:21:57 +08: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-04 01:48:10 +08:00
|
|
|
struct problem_context pctx;
|
2013-12-03 09:52:43 +08: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-04 01:48:10 +08:00
|
|
|
errcode_t retval;
|
2008-04-21 11:33:34 +08:00
|
|
|
int csum_flag;
|
2006-05-09 08:17:26 +08:00
|
|
|
int skip_group = 0;
|
2009-07-10 01:46:59 +08:00
|
|
|
int old_desc_blocks = 0;
|
|
|
|
int count = 0;
|
|
|
|
int cmp_block = 0;
|
|
|
|
int redo_flag = 0;
|
2009-07-12 09:29:30 +08:00
|
|
|
blk64_t super_blk, old_desc_blk, new_desc_blk;
|
2012-11-25 08:17:44 +08: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-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
clear_problem_context(&pctx);
|
2012-04-06 03:13:05 +08:00
|
|
|
free_array = (unsigned int *) e2fsck_allocate_memory(ctx,
|
|
|
|
fs->group_desc_count * sizeof(unsigned int), "free block count array");
|
1997-04-26 21:58:21 +08:00
|
|
|
|
2011-06-16 10:15:34 +08:00
|
|
|
if ((B2C(fs->super->s_first_data_block) <
|
2009-08-23 10:29:02 +08:00
|
|
|
ext2fs_get_block_bitmap_start2(ctx->block_found_map)) ||
|
2011-06-16 10:15:34 +08:00
|
|
|
(B2C(ext2fs_blocks_count(fs->super)-1) >
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
pctx.num = 1;
|
2011-06-16 10:15:34 +08:00
|
|
|
pctx.blk = B2C(fs->super->s_first_data_block);
|
|
|
|
pctx.blk2 = B2C(ext2fs_blocks_count(fs->super) - 1);
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
1997-04-26 21:58:21 +08:00
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
|
2011-06-16 10:15:34 +08:00
|
|
|
if ((B2C(fs->super->s_first_data_block) <
|
2009-08-23 10:29:02 +08:00
|
|
|
ext2fs_get_block_bitmap_start2(fs->block_map)) ||
|
2011-06-16 10:15:34 +08:00
|
|
|
(B2C(ext2fs_blocks_count(fs->super)-1) >
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
pctx.num = 2;
|
2011-06-16 10:15:34 +08:00
|
|
|
pctx.blk = B2C(fs->super->s_first_data_block);
|
|
|
|
pctx.blk2 = B2C(ext2fs_blocks_count(fs->super) - 1);
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
1997-04-26 21:58:21 +08:00
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
|
2007-10-22 10:04:03 +08:00
|
|
|
csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
|
1998-02-20 13:24:59 +08:00
|
|
|
redo_counts:
|
|
|
|
had_problem = 0;
|
2002-03-07 15:47:07 +08:00
|
|
|
save_problem = 0;
|
|
|
|
pctx.blk = pctx.blk2 = NO_BLK;
|
2008-04-21 11:33:34 +08:00
|
|
|
if (csum_flag &&
|
2009-10-26 09:42:12 +08:00
|
|
|
(ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT)))
|
2006-05-09 08:17:26 +08:00
|
|
|
skip_group++;
|
2011-06-16 10:15:34 +08:00
|
|
|
for (i = B2C(fs->super->s_first_data_block);
|
2009-09-08 08:46:34 +08:00
|
|
|
i < ext2fs_blocks_count(fs->super);
|
2011-06-11 06:58:16 +08:00
|
|
|
i += EXT2FS_CLUSTER_RATIO(fs)) {
|
2012-11-25 08:17:44 +08: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 10:29:02 +08:00
|
|
|
actual = ext2fs_fast_test_block_bitmap2(ctx->block_found_map, i);
|
2006-05-09 08:17:26 +08:00
|
|
|
|
2012-11-25 08:17:44 +08: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 ||
|
|
|
|
(group == (int)fs->group_desc_count - 1) ||
|
|
|
|
(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;
|
|
|
|
if (ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT))
|
|
|
|
memset(bitmap_buf, 0, nbytes);
|
|
|
|
else {
|
|
|
|
retval = ext2fs_get_block_bitmap_range2(fs->block_map,
|
|
|
|
B2C(i), fs->super->s_clusters_per_group,
|
|
|
|
bitmap_buf);
|
|
|
|
if (retval)
|
|
|
|
goto no_optimize;
|
|
|
|
}
|
|
|
|
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 11:32:23 +08:00
|
|
|
i += EXT2FS_C2B(fs, fs->super->s_clusters_per_group - 1);
|
2012-11-25 08:17:44 +08:00
|
|
|
goto next_group;
|
|
|
|
no_optimize:
|
|
|
|
|
2006-05-09 08:17:26 +08:00
|
|
|
if (skip_group) {
|
2012-11-25 08:17:44 +08:00
|
|
|
if (first_block_in_bg) {
|
2009-07-10 01:46:59 +08:00
|
|
|
super_blk = 0;
|
|
|
|
old_desc_blk = 0;
|
|
|
|
new_desc_blk = 0;
|
2009-07-12 09:29:30 +08:00
|
|
|
ext2fs_super_and_bgd_loc2(fs, group, &super_blk,
|
2008-04-19 22:30:59 +08:00
|
|
|
&old_desc_blk, &new_desc_blk, 0);
|
|
|
|
|
2009-07-10 01:46:59 +08:00
|
|
|
if (fs->super->s_feature_incompat &
|
|
|
|
EXT2_FEATURE_INCOMPAT_META_BG)
|
|
|
|
old_desc_blocks =
|
|
|
|
fs->super->s_first_meta_bg;
|
|
|
|
else
|
|
|
|
old_desc_blocks = fs->desc_blocks +
|
2008-04-19 22:30:59 +08:00
|
|
|
fs->super->s_reserved_gdt_blocks;
|
|
|
|
|
2009-07-10 01:46:59 +08:00
|
|
|
count = 0;
|
2011-06-16 10:15:34 +08:00
|
|
|
cmp_block = fs->super->s_clusters_per_group;
|
2009-07-10 01:46:59 +08:00
|
|
|
if (group == (int)fs->group_desc_count - 1)
|
2011-09-16 21:25:51 +08:00
|
|
|
cmp_block = EXT2FS_NUM_B2C(fs,
|
|
|
|
ext2fs_group_blocks_count(fs, group));
|
2009-07-10 01:46:59 +08:00
|
|
|
}
|
|
|
|
|
2008-04-19 22:30:59 +08:00
|
|
|
bitmap = 0;
|
2011-06-16 10:15:34 +08:00
|
|
|
if (EQ_CLSTR(i, super_blk) ||
|
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 09:43:47 +08:00
|
|
|
(old_desc_blk && old_desc_blocks &&
|
2011-06-16 10:15:34 +08:00
|
|
|
GE_CLSTR(i, old_desc_blk) &&
|
|
|
|
LE_CLSTR(i, old_desc_blk + old_desc_blocks-1)) ||
|
|
|
|
(new_desc_blk && EQ_CLSTR(i, new_desc_blk)) ||
|
|
|
|
EQ_CLSTR(i, ext2fs_block_bitmap_loc(fs, group)) ||
|
|
|
|
EQ_CLSTR(i, ext2fs_inode_bitmap_loc(fs, group)) ||
|
|
|
|
(GE_CLSTR(i, ext2fs_inode_table_loc(fs, group)) &&
|
|
|
|
LE_CLSTR(i, (ext2fs_inode_table_loc(fs, group) +
|
|
|
|
fs->inode_blocks_per_group - 1)))) {
|
2008-04-19 22:30:59 +08:00
|
|
|
bitmap = 1;
|
2009-07-10 01:46:59 +08:00
|
|
|
actual = (actual != 0);
|
|
|
|
count++;
|
|
|
|
cmp_block--;
|
2011-06-16 10:15:34 +08:00
|
|
|
} else if ((EXT2FS_B2C(fs, i) - count -
|
|
|
|
EXT2FS_B2C(fs, fs->super->s_first_data_block)) %
|
|
|
|
fs->super->s_clusters_per_group == 0) {
|
2009-07-10 01:46:59 +08:00
|
|
|
/*
|
|
|
|
* When the compare data blocks in block bitmap
|
|
|
|
* are 0, count the free block,
|
|
|
|
* skip the current block group.
|
|
|
|
*/
|
2009-08-23 10:29:02 +08:00
|
|
|
if (ext2fs_test_block_bitmap_range2(
|
2011-06-16 10:15:34 +08:00
|
|
|
ctx->block_found_map,
|
|
|
|
EXT2FS_B2C(fs, i),
|
2009-07-10 01:46:59 +08:00
|
|
|
cmp_block)) {
|
|
|
|
/*
|
|
|
|
* -1 means to skip the current block
|
|
|
|
* group.
|
|
|
|
*/
|
2011-06-16 10:15:34 +08:00
|
|
|
blocks = fs->super->s_clusters_per_group - 1;
|
2009-07-10 01:46:59 +08:00
|
|
|
group_free = cmp_block;
|
|
|
|
free_blocks += cmp_block;
|
|
|
|
/*
|
|
|
|
* The current block group's last block
|
|
|
|
* is set to i.
|
|
|
|
*/
|
2011-06-16 10:15:34 +08:00
|
|
|
i += EXT2FS_C2B(fs, cmp_block - 1);
|
2009-07-10 01:46:59 +08:00
|
|
|
bitmap = 1;
|
|
|
|
goto do_counts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (redo_flag)
|
|
|
|
bitmap = actual;
|
|
|
|
else
|
2009-08-23 10:29:02 +08:00
|
|
|
bitmap = ext2fs_fast_test_block_bitmap2(fs->block_map, i);
|
2007-03-29 00:07:41 +08:00
|
|
|
|
2011-12-18 00:56:35 +08:00
|
|
|
if (!actual == !bitmap)
|
1997-04-26 21:21:57 +08:00
|
|
|
goto do_counts;
|
2006-05-09 08:17:26 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
if (!actual && bitmap) {
|
|
|
|
/*
|
|
|
|
* Block not used, but marked in use in the bitmap.
|
|
|
|
*/
|
2002-03-07 15:47:07 +08:00
|
|
|
problem = PR_5_BLOCK_UNUSED;
|
1997-04-26 21:21:57 +08:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Block used, but not marked in use in the bitmap.
|
|
|
|
*/
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
problem = PR_5_BLOCK_USED;
|
2007-10-22 10:04:03 +08:00
|
|
|
|
|
|
|
if (skip_group) {
|
|
|
|
struct problem_context pctx2;
|
|
|
|
pctx2.blk = i;
|
|
|
|
pctx2.group = group;
|
|
|
|
if (fix_problem(ctx, PR_5_BLOCK_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 09:41:32 +08:00
|
|
|
ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
|
2007-10-22 10:04:03 +08:00
|
|
|
skip_group = 0;
|
|
|
|
}
|
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2002-03-07 15:47:07 +08:00
|
|
|
if (pctx.blk == NO_BLK) {
|
|
|
|
pctx.blk = pctx.blk2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
} else {
|
|
|
|
if ((problem == save_problem) &&
|
|
|
|
(pctx.blk2 == i-1))
|
|
|
|
pctx.blk2++;
|
|
|
|
else {
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
|
|
|
pctx.blk = pctx.blk2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
}
|
|
|
|
}
|
1999-07-19 23:27:37 +08:00
|
|
|
ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
|
1998-02-20 13:24:59 +08:00
|
|
|
had_problem++;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
2010-11-18 11:38:38 +08: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 21:21:57 +08:00
|
|
|
do_counts:
|
2012-03-12 02:15:19 +08:00
|
|
|
if (!bitmap) {
|
1997-04-26 21:21:57 +08:00
|
|
|
group_free++;
|
|
|
|
free_blocks++;
|
2010-11-18 11:38:38 +08:00
|
|
|
if (first_free > i)
|
|
|
|
first_free = i;
|
2012-03-12 02:15:19 +08:00
|
|
|
} else if (i > first_free) {
|
|
|
|
e2fsck_discard_blocks(ctx, first_free,
|
|
|
|
(i - first_free));
|
2010-11-18 11:38:38 +08:00
|
|
|
first_free = ext2fs_blocks_count(fs->super);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
blocks ++;
|
2011-06-11 06:58:16 +08: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 15:49:34 +08: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 08:17:44 +08:00
|
|
|
next_group:
|
2012-03-05 15:49:34 +08:00
|
|
|
first_free = ext2fs_blocks_count(fs->super);
|
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
free_array[group] = group_free;
|
|
|
|
group ++;
|
|
|
|
blocks = 0;
|
|
|
|
group_free = 0;
|
2006-05-09 08:17:26 +08:00
|
|
|
skip_group = 0;
|
1998-05-07 13:02:00 +08:00
|
|
|
if (ctx->progress)
|
|
|
|
if ((ctx->progress)(ctx, 5, group,
|
|
|
|
fs->group_desc_count*2))
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
2008-04-21 11:33:34 +08:00
|
|
|
if (csum_flag &&
|
2009-09-08 08:46:34 +08:00
|
|
|
(i != ext2fs_blocks_count(fs->super)-1) &&
|
2009-10-26 09:42:12 +08:00
|
|
|
ext2fs_bg_flags_test(fs, group,
|
2009-09-08 09:15:12 +08:00
|
|
|
EXT2_BG_BLOCK_UNINIT))
|
2006-05-09 08:17:26 +08:00
|
|
|
skip_group++;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
2002-03-07 15:47:07 +08:00
|
|
|
if (pctx.blk != NO_BLK)
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
1998-02-20 13:24:59 +08:00
|
|
|
if (had_problem)
|
2002-03-07 15:47:07 +08:00
|
|
|
fixit = end_problem_latch(ctx, PR_LATCH_BBITMAP);
|
1998-02-20 13:24:59 +08:00
|
|
|
else
|
|
|
|
fixit = -1;
|
1999-07-19 23:27:37 +08:00
|
|
|
ctx->flags &= ~E2F_FLAG_PROG_SUPPRESS;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (fixit == 1) {
|
|
|
|
ext2fs_free_block_bitmap(fs->block_map);
|
|
|
|
retval = ext2fs_copy_bitmap(ctx->block_found_map,
|
|
|
|
&fs->block_map);
|
2000-06-11 03:21:33 +08:00
|
|
|
if (retval) {
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
fix_problem(ctx, PR_5_COPY_BBITMAP_ERROR, &pctx);
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
2000-06-11 03:21:33 +08:00
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_set_bitmap_padding(fs->block_map);
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
/* Redo the counts */
|
|
|
|
blocks = 0; free_blocks = 0; group_free = 0; group = 0;
|
|
|
|
memset(free_array, 0, fs->group_desc_count * sizeof(int));
|
2009-07-10 01:46:59 +08: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-04 01:48:10 +08:00
|
|
|
goto redo_counts;
|
|
|
|
} else if (fixit == 0)
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
|
2013-12-03 12:21:31 +08: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-04 01:48:10 +08:00
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT_GROUP,
|
|
|
|
&pctx)) {
|
2013-12-03 12:21:31 +08:00
|
|
|
ext2fs_bg_free_blocks_count_set(fs, g, free_array[g]);
|
1997-04-26 21:21:57 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 13:38:43 +08:00
|
|
|
free_blocks = EXT2FS_C2B(fs, free_blocks);
|
2009-09-08 08:46:34 +08: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-04 01:48:10 +08:00
|
|
|
pctx.group = 0;
|
2009-09-08 08:46:34 +08: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-04 01:48:10 +08:00
|
|
|
pctx.blk2 = free_blocks;
|
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_BLOCK_COUNT, &pctx)) {
|
2009-09-08 08:46:34 +08:00
|
|
|
ext2fs_free_blocks_count_set(fs->super, free_blocks);
|
1997-04-26 21:21:57 +08:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
2012-04-25 04:22:48 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
errout:
|
2003-08-01 21:41:07 +08:00
|
|
|
ext2fs_free_mem(&free_array);
|
2012-11-25 08:17:44 +08:00
|
|
|
ext2fs_free_mem(&actual_buf);
|
|
|
|
ext2fs_free_mem(&bitmap_buf);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void check_inode_bitmaps(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
Many files:
dirinfo.c, e2fsck.h, emptydir.c, iscan.c, jfs_user.h, journal.c,
message.c, pass1.c, pass1b.c, pass2.c, pass3.c, pass4.c, pass5.c,
problem.h, scantest.c, super.c, swapfs.c: Change ino_t to ext2_ino_t.
2001-01-11 23:12:14 +08:00
|
|
|
ext2_ino_t i;
|
2003-12-07 14:28:50 +08:00
|
|
|
unsigned int free_inodes = 0;
|
|
|
|
int group_free = 0;
|
|
|
|
int dirs_count = 0;
|
2013-12-03 12:21:31 +08:00
|
|
|
dgrp_t group = 0;
|
2003-12-07 14:28:50 +08:00
|
|
|
unsigned int inodes = 0;
|
2012-04-06 03:13:05 +08:00
|
|
|
ext2_ino_t *free_array;
|
|
|
|
ext2_ino_t *dir_array;
|
2003-12-07 14:28:50 +08: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-04 01:48:10 +08:00
|
|
|
errcode_t retval;
|
|
|
|
struct problem_context pctx;
|
2013-12-03 09:52:43 +08:00
|
|
|
problem_t problem, save_problem;
|
|
|
|
int fixit, had_problem;
|
2008-04-21 11:33:34 +08:00
|
|
|
int csum_flag;
|
2006-05-09 08:17:26 +08:00
|
|
|
int skip_group = 0;
|
2009-07-10 01:46:59 +08:00
|
|
|
int redo_flag = 0;
|
2012-04-06 03:13:05 +08:00
|
|
|
ext2_ino_t first_free = fs->super->s_inodes_per_group + 1;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
clear_problem_context(&pctx);
|
2012-04-06 03:13:05 +08:00
|
|
|
free_array = (ext2_ino_t *) e2fsck_allocate_memory(ctx,
|
|
|
|
fs->group_desc_count * sizeof(ext2_ino_t), "free inode count array");
|
2007-03-29 00:07:41 +08:00
|
|
|
|
2012-04-06 03:13:05 +08:00
|
|
|
dir_array = (ext2_ino_t *) e2fsck_allocate_memory(ctx,
|
|
|
|
fs->group_desc_count * sizeof(ext2_ino_t), "directory count array");
|
2007-03-29 00:07:41 +08:00
|
|
|
|
2009-08-23 10:29:02 +08:00
|
|
|
if ((1 < ext2fs_get_inode_bitmap_start2(ctx->inode_used_map)) ||
|
2007-03-29 00:07:41 +08:00
|
|
|
(fs->super->s_inodes_count >
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
pctx.num = 3;
|
|
|
|
pctx.blk = 1;
|
|
|
|
pctx.blk2 = fs->super->s_inodes_count;
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
1997-04-26 21:58:21 +08:00
|
|
|
}
|
2009-08-23 10:29:02 +08:00
|
|
|
if ((1 < ext2fs_get_inode_bitmap_start2(fs->inode_map)) ||
|
2007-03-29 00:07:41 +08:00
|
|
|
(fs->super->s_inodes_count >
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
pctx.num = 4;
|
|
|
|
pctx.blk = 1;
|
|
|
|
pctx.blk2 = fs->super->s_inodes_count;
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
fix_problem(ctx, PR_5_BMAP_ENDPOINTS, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
1997-04-26 21:58:21 +08:00
|
|
|
}
|
|
|
|
|
2007-10-22 10:04:03 +08:00
|
|
|
csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
redo_counts:
|
1998-02-20 13:24:59 +08:00
|
|
|
had_problem = 0;
|
2002-03-07 15:47:07 +08:00
|
|
|
save_problem = 0;
|
|
|
|
pctx.ino = pctx.ino2 = 0;
|
2008-04-21 11:33:34 +08:00
|
|
|
if (csum_flag &&
|
2009-10-26 09:42:12 +08:00
|
|
|
(ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT)))
|
2006-05-09 08:17:26 +08:00
|
|
|
skip_group++;
|
|
|
|
|
2006-08-30 14:16:55 +08:00
|
|
|
/* Protect loop from wrap-around if inodes_count is maxed */
|
|
|
|
for (i = 1; i <= fs->super->s_inodes_count && i > 0; i++) {
|
2009-07-10 01:46:59 +08: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-12 00:55:45 +08:00
|
|
|
first_free = 1;
|
2009-07-10 01:46:59 +08: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 10:29:02 +08:00
|
|
|
actual = ext2fs_fast_test_inode_bitmap2(ctx->inode_used_map, i);
|
2009-07-10 01:46:59 +08:00
|
|
|
if (redo_flag)
|
|
|
|
bitmap = actual;
|
|
|
|
else if (!skip_group)
|
2009-08-23 10:29:02 +08:00
|
|
|
bitmap = ext2fs_fast_test_inode_bitmap2(fs->inode_map, i);
|
2011-12-18 00:56:35 +08:00
|
|
|
if (!actual == !bitmap)
|
1997-04-26 21:21:57 +08:00
|
|
|
goto do_counts;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
if (!actual && bitmap) {
|
|
|
|
/*
|
|
|
|
* Inode wasn't used, but marked in bitmap
|
|
|
|
*/
|
2002-03-07 15:47:07 +08:00
|
|
|
problem = PR_5_INODE_UNUSED;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
} else /* if (actual && !bitmap) */ {
|
1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* Inode used, but not in bitmap
|
|
|
|
*/
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
problem = PR_5_INODE_USED;
|
2007-10-22 10:04:03 +08: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 09:41:32 +08:00
|
|
|
ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
|
2007-10-22 10:04:03 +08:00
|
|
|
skip_group = 0;
|
|
|
|
}
|
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2002-03-07 15:47:07 +08:00
|
|
|
if (pctx.ino == 0) {
|
|
|
|
pctx.ino = pctx.ino2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
} else {
|
|
|
|
if ((problem == save_problem) &&
|
|
|
|
(pctx.ino2 == i-1))
|
|
|
|
pctx.ino2++;
|
|
|
|
else {
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
|
|
|
pctx.ino = pctx.ino2 = i;
|
|
|
|
save_problem = problem;
|
|
|
|
}
|
|
|
|
}
|
1999-07-19 23:27:37 +08:00
|
|
|
ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
|
1998-02-20 13:24:59 +08:00
|
|
|
had_problem++;
|
2010-11-18 11:38:38 +08: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-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
do_counts:
|
2012-03-12 00:55:45 +08:00
|
|
|
inodes++;
|
2006-05-09 08:17:26 +08:00
|
|
|
if (bitmap) {
|
2009-08-23 10:29:02 +08:00
|
|
|
if (ext2fs_test_inode_bitmap2(ctx->inode_dir_map, i))
|
1997-04-26 21:21:57 +08:00
|
|
|
dirs_count++;
|
2012-03-12 00:55:45 +08: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-12 02:15:19 +08:00
|
|
|
} else {
|
2006-05-09 08:17:26 +08:00
|
|
|
group_free++;
|
|
|
|
free_inodes++;
|
2012-03-12 00:55:45 +08:00
|
|
|
if (first_free > inodes)
|
|
|
|
first_free = inodes;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2010-11-18 11:38:38 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
if ((inodes == fs->super->s_inodes_per_group) ||
|
|
|
|
(i == fs->super->s_inodes_count)) {
|
2012-03-12 00:55:45 +08: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 11:38:38 +08: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-12 00:55:45 +08:00
|
|
|
io_channel_discard_zeroes_data(fs->io) &&
|
2010-11-18 11:38:38 +08:00
|
|
|
!(ext2fs_bg_flags_test(fs, group,
|
2012-03-12 00:55:45 +08:00
|
|
|
EXT2_BG_INODE_ZEROED))) {
|
2010-11-18 11:38:38 +08:00
|
|
|
ext2fs_bg_flags_set(fs, group,
|
|
|
|
EXT2_BG_INODE_ZEROED);
|
|
|
|
ext2fs_group_desc_csum_set(fs, group);
|
|
|
|
}
|
|
|
|
|
2012-03-12 00:55:45 +08:00
|
|
|
first_free = fs->super->s_inodes_per_group + 1;
|
|
|
|
free_array[group] = group_free;
|
|
|
|
dir_array[group] = dirs_count;
|
1997-04-26 21:21:57 +08:00
|
|
|
group ++;
|
|
|
|
inodes = 0;
|
2006-05-09 08:17:26 +08:00
|
|
|
skip_group = 0;
|
1997-04-26 21:21:57 +08:00
|
|
|
group_free = 0;
|
|
|
|
dirs_count = 0;
|
1998-05-07 13:02:00 +08:00
|
|
|
if (ctx->progress)
|
|
|
|
if ((ctx->progress)(ctx, 5,
|
|
|
|
group + fs->group_desc_count,
|
|
|
|
fs->group_desc_count*2))
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
2008-04-21 11:33:34 +08:00
|
|
|
if (csum_flag &&
|
2006-05-09 08:17:26 +08:00
|
|
|
(i != fs->super->s_inodes_count) &&
|
2009-10-26 09:42:12 +08:00
|
|
|
(ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT)
|
2009-09-08 09:15:12 +08:00
|
|
|
))
|
2006-05-09 08:17:26 +08:00
|
|
|
skip_group++;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
2002-03-07 15:47:07 +08:00
|
|
|
if (pctx.ino)
|
|
|
|
print_bitmap_problem(ctx, save_problem, &pctx);
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1998-02-20 13:24:59 +08:00
|
|
|
if (had_problem)
|
|
|
|
fixit = end_problem_latch(ctx, PR_LATCH_IBITMAP);
|
|
|
|
else
|
|
|
|
fixit = -1;
|
1999-07-19 23:27:37 +08:00
|
|
|
ctx->flags &= ~E2F_FLAG_PROG_SUPPRESS;
|
2007-03-29 00:07:41 +08:00
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (fixit == 1) {
|
|
|
|
ext2fs_free_inode_bitmap(fs->inode_map);
|
|
|
|
retval = ext2fs_copy_bitmap(ctx->inode_used_map,
|
|
|
|
&fs->inode_map);
|
2000-06-11 03:21:33 +08:00
|
|
|
if (retval) {
|
|
|
|
clear_problem_context(&pctx);
|
|
|
|
fix_problem(ctx, PR_5_COPY_IBITMAP_ERROR, &pctx);
|
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
2007-03-29 00:07:41 +08:00
|
|
|
goto errout;
|
2000-06-11 03:21:33 +08:00
|
|
|
}
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_set_bitmap_padding(fs->inode_map);
|
|
|
|
ext2fs_mark_ib_dirty(fs);
|
|
|
|
|
|
|
|
/* redo counts */
|
|
|
|
inodes = 0; free_inodes = 0; group_free = 0;
|
|
|
|
dirs_count = 0; group = 0;
|
|
|
|
memset(free_array, 0, fs->group_desc_count * sizeof(int));
|
|
|
|
memset(dir_array, 0, fs->group_desc_count * sizeof(int));
|
2009-07-10 01:46:59 +08: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-04 01:48:10 +08:00
|
|
|
goto redo_counts;
|
|
|
|
} else if (fixit == 0)
|
|
|
|
ext2fs_unmark_valid(fs);
|
2007-03-29 00:07:41 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
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 09:43:47 +08: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-04 01:48:10 +08: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 09:43:47 +08: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-04 01:48:10 +08: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 09:43:47 +08:00
|
|
|
ext2fs_bg_free_inodes_count_set(fs, i, free_array[i]);
|
1997-04-26 21:21:57 +08: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 09:43:47 +08: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-04 01:48:10 +08: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 09:43:47 +08: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-04 01:48:10 +08: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 09:43:47 +08:00
|
|
|
ext2fs_bg_used_dirs_count_set(fs, i, dir_array[i]);
|
1997-04-26 21:21:57 +08: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-04 01:48:10 +08:00
|
|
|
pctx.group = -1;
|
|
|
|
pctx.ino = fs->super->s_free_inodes_count;
|
|
|
|
pctx.ino2 = free_inodes;
|
|
|
|
|
|
|
|
if (fix_problem(ctx, PR_5_FREE_INODE_COUNT, &pctx)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
fs->super->s_free_inodes_count = free_inodes;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
2012-04-25 04:22:48 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2007-03-29 00:07:41 +08:00
|
|
|
errout:
|
2003-08-01 21:41:07 +08:00
|
|
|
ext2fs_free_mem(&free_array);
|
|
|
|
ext2fs_free_mem(&dir_array);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void check_inode_end(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
Many files:
dirinfo.c, e2fsck.h, emptydir.c, iscan.c, jfs_user.h, journal.c,
message.c, pass1.c, pass1b.c, pass2.c, pass3.c, pass4.c, pass5.c,
problem.h, scantest.c, super.c, swapfs.c: Change ino_t to ext2_ino_t.
2001-01-11 23:12:14 +08:00
|
|
|
ext2_ino_t end, save_inodes_count, i;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
struct problem_context pctx;
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
end = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map, end,
|
|
|
|
&save_inodes_count);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 1;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
if (save_inodes_count == end)
|
|
|
|
return;
|
2006-08-30 14:16:55 +08:00
|
|
|
|
2008-08-28 11:07:54 +08:00
|
|
|
/* protect loop from wrap-around if end is maxed */
|
2006-08-30 14:16:55 +08:00
|
|
|
for (i = save_inodes_count + 1; i <= end && i > save_inodes_count; i++) {
|
1997-04-26 21:34:30 +08:00
|
|
|
if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) {
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) {
|
2009-07-06 16:15:24 +08:00
|
|
|
for (; i <= end; i++)
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_mark_inode_bitmap(fs->inode_map,
|
1997-04-26 21:21:57 +08:00
|
|
|
i);
|
|
|
|
ext2fs_mark_ib_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map,
|
|
|
|
save_inodes_count, 0);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 2;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void check_block_end(e2fsck_t ctx)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
struct problem_context pctx;
|
|
|
|
|
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
2009-08-23 10:29:02 +08:00
|
|
|
end = ext2fs_get_block_bitmap_start2(fs->block_map) +
|
2011-06-11 06:58:16 +08:00
|
|
|
((blk64_t)EXT2_CLUSTERS_PER_GROUP(fs->super) * fs->group_desc_count) - 1;
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
&save_blocks_count);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 3;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
if (save_blocks_count == end)
|
|
|
|
return;
|
2006-08-30 14:16:55 +08:00
|
|
|
|
2008-08-28 11:07:54 +08:00
|
|
|
/* Protect loop from wrap-around if end is maxed */
|
2006-08-30 14:16:55 +08:00
|
|
|
for (i = save_blocks_count + 1; i <= end && i > save_blocks_count; i++) {
|
2011-06-11 06:58:16 +08: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-04 01:48:10 +08:00
|
|
|
if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) {
|
2009-07-06 16:15:24 +08:00
|
|
|
for (; i <= end; i++)
|
2009-08-23 10:29:02 +08:00
|
|
|
ext2fs_mark_block_bitmap2(fs->block_map,
|
2011-06-11 06:58:16 +08:00
|
|
|
EXT2FS_C2B(fs, i));
|
1997-04-26 21:21:57 +08:00
|
|
|
ext2fs_mark_bb_dirty(fs);
|
|
|
|
} else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-23 10:29:02 +08: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-04 01:48:10 +08:00
|
|
|
save_blocks_count, 0);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
pctx.num = 4;
|
|
|
|
fix_problem(ctx, PR_5_FUDGE_BITMAP_ERROR, &pctx);
|
1997-11-04 03:42:40 +08:00
|
|
|
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
|
|
|
|
return;
|
1997-04-26 21:34:30 +08:00
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
|
|
|
|
|