1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* pass4.c -- pass #4 of e2fsck: Check reference counts
|
|
|
|
*
|
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%
|
|
|
|
*
|
|
|
|
* Pass 4 frees the following data structures:
|
|
|
|
* - A bitmap of which inodes are in bad blocks. (inode_bb_map)
|
Many files:
pass4.c (e2fsck_pass4): If an inode is set in the inode_imagic_map
bitmap, don't check to see if it is disconnected from the inode tree
(because it almost certainly will be). Free inode_imagic_map at the
end of pass 4.
pass2.c (check_dir_block, check_filetype): If the FILETYPE feature is
set, check the directory entry's filetype information field, and
fix/set it if necessary. (e2fsck_pass2): Free the inode_reg_map
bitmap at the end of pass 2.
pass1.c (e2fsck_pass1, alloc_imagic_map): Allocate and fill in
information for inode_reg_map and inode_imagic_map, which indicates
which inodes are regular files and AFS inodes, respectively.
Since only the master superblock is written during a restart, force
that superblock to be used after a restart; otherwise changes to the
block group descriptors end up getting ignored.
problem.c, problemP.h: If e2fsck is run -n, make def_yn variable be 0
for "no". Add support for a new flag, PR_NO_NOMSG, which supresses
the problem message if e2fsck is run with the -n option.
problem.c, problem.h (PR_2_SET_FILETYPE, PR_2_BAD_FILETYPE): Add new
problem codes.
message.c (expand_dirent_expression): Add support for %dt which prints
the dirent type information.
e2fsck.c (e2fsck_reset_context): Free new bitmaps (inode_reg_map and
inode_imagic_map).
e2fsck.h (e2fsck_t): Add new inode_reg_map and inode_magic_map to the
context structure.
ChangeLog, nt_io.c:
nt_io.c: New file which supports I/O under Windows NT.
ChangeLog, gen_uuid_nt.c:
gen_uuid_nt.c: New file which creates a UUID under Windows NT.
Many files:
Add support for non-Unix compiles
1999-10-22 03:33:18 +08:00
|
|
|
* - A bitmap of which inodes are imagic inodes. (inode_imagic_map)
|
1997-04-26 21:21:57 +08:00
|
|
|
*/
|
|
|
|
|
2011-09-19 05:34:37 +08:00
|
|
|
#include "config.h"
|
1997-04-26 21:21:57 +08:00
|
|
|
#include "e2fsck.h"
|
1997-04-30 00:15:03 +08:00
|
|
|
#include "problem.h"
|
2008-02-02 16:16:32 +08:00
|
|
|
#include <ext2fs/ext2_ext_attr.h>
|
1997-04-26 21:21:57 +08:00
|
|
|
|
1997-04-29 23:29:49 +08:00
|
|
|
/*
|
|
|
|
* This routine is called when an inode is not connected to the
|
|
|
|
* directory tree.
|
2008-08-28 11:07:54 +08:00
|
|
|
*
|
1997-04-29 23:29:49 +08:00
|
|
|
* This subroutine returns 1 then the caller shouldn't bother with the
|
|
|
|
* rest of the pass 4 tests.
|
|
|
|
*/
|
2008-02-02 16:16:32 +08:00
|
|
|
static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i,
|
|
|
|
struct ext2_inode *inode)
|
1997-04-29 23:29:49 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
1997-04-30 00:15:03 +08:00
|
|
|
struct problem_context pctx;
|
2008-02-02 16:16:32 +08:00
|
|
|
__u32 eamagic = 0;
|
|
|
|
int extra_size = 0;
|
1997-04-29 23:29:49 +08:00
|
|
|
|
2008-02-02 16:16:32 +08:00
|
|
|
if (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE) {
|
|
|
|
e2fsck_read_inode_full(ctx, i, inode,EXT2_INODE_SIZE(fs->super),
|
|
|
|
"pass4: disconnect_inode");
|
|
|
|
extra_size = ((struct ext2_inode_large *)inode)->i_extra_isize;
|
|
|
|
} else {
|
|
|
|
e2fsck_read_inode(ctx, i, inode, "pass4: disconnect_inode");
|
|
|
|
}
|
1997-04-30 00:15:03 +08:00
|
|
|
clear_problem_context(&pctx);
|
|
|
|
pctx.ino = i;
|
2008-02-02 16:16:32 +08:00
|
|
|
pctx.inode = inode;
|
2008-08-28 11:07:54 +08:00
|
|
|
|
2008-02-02 16:16:32 +08:00
|
|
|
if (EXT2_INODE_SIZE(fs->super) -EXT2_GOOD_OLD_INODE_SIZE -extra_size >0)
|
|
|
|
eamagic = *(__u32 *)(((char *)inode) +EXT2_GOOD_OLD_INODE_SIZE +
|
|
|
|
extra_size);
|
2002-08-17 22:19:44 +08:00
|
|
|
/*
|
|
|
|
* Offer to delete any zero-length files that does not have
|
|
|
|
* blocks. If there is an EA block, it might have useful
|
|
|
|
* information, so we won't prompt to delete it, but let it be
|
|
|
|
* reconnected to lost+found.
|
|
|
|
*/
|
2008-02-02 16:16:32 +08:00
|
|
|
if (!inode->i_blocks && eamagic != EXT2_EXT_ATTR_MAGIC &&
|
|
|
|
(LINUX_S_ISREG(inode->i_mode) || LINUX_S_ISDIR(inode->i_mode))) {
|
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_4_ZERO_LEN_INODE, &pctx)) {
|
2008-08-28 11:07:54 +08:00
|
|
|
e2fsck_clear_inode(ctx, i, inode, 0,
|
1997-04-29 23:29:49 +08:00
|
|
|
"disconnect_inode");
|
|
|
|
/*
|
|
|
|
* Fix up the bitmaps...
|
|
|
|
*/
|
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);
|
2002-08-17 22:19:44 +08:00
|
|
|
ext2fs_inode_alloc_stats2(fs, i, -1,
|
2008-02-02 16:16:32 +08:00
|
|
|
LINUX_S_ISDIR(inode->i_mode));
|
2011-07-21 02:40:06 +08:00
|
|
|
quota_data_inodes(ctx->qctx, inode, i, -1);
|
1997-04-29 23:29:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2008-08-28 11:07:54 +08:00
|
|
|
|
1997-04-29 23:29:49 +08:00
|
|
|
/*
|
|
|
|
* Prompt to reconnect.
|
|
|
|
*/
|
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_4_UNATTACHED_INODE, &pctx)) {
|
1997-11-04 03:42:40 +08:00
|
|
|
if (e2fsck_reconnect_file(ctx, i))
|
1997-04-29 23:29:49 +08:00
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If we don't attach the inode, then skip the
|
|
|
|
* i_links_test since there's no point in trying to
|
|
|
|
* force i_links_count to zero.
|
|
|
|
*/
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-04 03:42:40 +08:00
|
|
|
void e2fsck_pass4(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;
|
2008-02-02 16:16:32 +08:00
|
|
|
struct ext2_inode *inode;
|
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
|
1997-04-30 00:15:03 +08:00
|
|
|
struct problem_context pctx;
|
|
|
|
__u16 link_count, link_counted;
|
2002-05-21 21:14:17 +08:00
|
|
|
char *buf = 0;
|
2013-12-03 12:21:31 +08:00
|
|
|
dgrp_t group, maxgroup;
|
2008-08-28 11:07:54 +08:00
|
|
|
|
2007-08-04 08:07:09 +08:00
|
|
|
init_resource_track(&rtrack, ctx->fs->io);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
#ifdef MTRACE
|
|
|
|
mtrace_print("Pass 4");
|
|
|
|
#endif
|
|
|
|
|
1997-04-30 00:15:03 +08:00
|
|
|
clear_problem_context(&pctx);
|
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_4_PASS_HEADER, &pctx);
|
|
|
|
|
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
|
|
|
group = 0;
|
1998-09-03 09:26:03 +08:00
|
|
|
maxgroup = fs->group_desc_count;
|
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-09-03 09:26:03 +08:00
|
|
|
if ((ctx->progress)(ctx, 4, 0, maxgroup))
|
1998-02-25 04:22:23 +08:00
|
|
|
return;
|
2006-08-30 14:16:55 +08:00
|
|
|
|
2008-02-02 16:16:32 +08:00
|
|
|
inode = e2fsck_allocate_memory(ctx, EXT2_INODE_SIZE(fs->super),
|
|
|
|
"scratch inode");
|
|
|
|
|
2006-08-30 14:16:55 +08:00
|
|
|
/* Protect loop from wrap-around if s_inodes_count maxed */
|
|
|
|
for (i=1; i <= fs->super->s_inodes_count && i > 0; i++) {
|
2012-10-10 10:45:40 +08:00
|
|
|
int isdir;
|
2010-11-27 08:09:43 +08:00
|
|
|
|
2002-07-22 02:14:03 +08:00
|
|
|
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
|
2007-03-29 00:43:05 +08:00
|
|
|
goto errout;
|
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 ((i % fs->super->s_inodes_per_group) == 0) {
|
|
|
|
group++;
|
|
|
|
if (ctx->progress)
|
1998-09-03 09:26:03 +08:00
|
|
|
if ((ctx->progress)(ctx, 4, group, maxgroup))
|
2007-03-29 00:43:05 +08:00
|
|
|
goto errout;
|
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
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
if (i == EXT2_BAD_INO ||
|
1997-04-26 22:48:50 +08:00
|
|
|
(i > EXT2_ROOT_INO && i < EXT2_FIRST_INODE(fs->super)))
|
1997-04-26 21:21:57 +08:00
|
|
|
continue;
|
2009-08-23 10:29:02 +08:00
|
|
|
if (!(ext2fs_test_inode_bitmap2(ctx->inode_used_map, i)) ||
|
Many files:
pass4.c (e2fsck_pass4): If an inode is set in the inode_imagic_map
bitmap, don't check to see if it is disconnected from the inode tree
(because it almost certainly will be). Free inode_imagic_map at the
end of pass 4.
pass2.c (check_dir_block, check_filetype): If the FILETYPE feature is
set, check the directory entry's filetype information field, and
fix/set it if necessary. (e2fsck_pass2): Free the inode_reg_map
bitmap at the end of pass 2.
pass1.c (e2fsck_pass1, alloc_imagic_map): Allocate and fill in
information for inode_reg_map and inode_imagic_map, which indicates
which inodes are regular files and AFS inodes, respectively.
Since only the master superblock is written during a restart, force
that superblock to be used after a restart; otherwise changes to the
block group descriptors end up getting ignored.
problem.c, problemP.h: If e2fsck is run -n, make def_yn variable be 0
for "no". Add support for a new flag, PR_NO_NOMSG, which supresses
the problem message if e2fsck is run with the -n option.
problem.c, problem.h (PR_2_SET_FILETYPE, PR_2_BAD_FILETYPE): Add new
problem codes.
message.c (expand_dirent_expression): Add support for %dt which prints
the dirent type information.
e2fsck.c (e2fsck_reset_context): Free new bitmaps (inode_reg_map and
inode_imagic_map).
e2fsck.h (e2fsck_t): Add new inode_reg_map and inode_magic_map to the
context structure.
ChangeLog, nt_io.c:
nt_io.c: New file which supports I/O under Windows NT.
ChangeLog, gen_uuid_nt.c:
gen_uuid_nt.c: New file which creates a UUID under Windows NT.
Many files:
Add support for non-Unix compiles
1999-10-22 03:33:18 +08:00
|
|
|
(ctx->inode_imagic_map &&
|
2009-08-23 10:29:02 +08:00
|
|
|
ext2fs_test_inode_bitmap2(ctx->inode_imagic_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
|
|
|
(ctx->inode_bb_map &&
|
2009-08-23 10:29:02 +08:00
|
|
|
ext2fs_test_inode_bitmap2(ctx->inode_bb_map, i)))
|
1997-04-26 21:21:57 +08:00
|
|
|
continue;
|
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_icount_fetch(ctx->inode_link_info, i, &link_count);
|
|
|
|
ext2fs_icount_fetch(ctx->inode_count, i, &link_counted);
|
1997-04-30 00:15:03 +08:00
|
|
|
if (link_counted == 0) {
|
2002-05-21 21:14:17 +08:00
|
|
|
if (!buf)
|
|
|
|
buf = e2fsck_allocate_memory(ctx,
|
|
|
|
fs->blocksize, "bad_inode buffer");
|
|
|
|
if (e2fsck_process_bad_inode(ctx, 0, i, buf))
|
ChangeLog, e2fsck.h, pass1.c, pass2.c, pass4.c, swapfs.c:
e2fsck.h:
pass1.c (pass1_get_blocks, pass1_read_inode, pass1_write_inode,
pass1_check_directory, e2fsck_use_inode_shortcuts): Make pass1_* be
private static functions, and create new function
e2fsck_use_inode_shortcuts which sets and clears the inode shortcut
functions in the fs structure.
e2fsck.h:
pass2.c (e2fsck_process_bad_inode): Make process_bad_inode() an
exported function.
pass4.c (e2fsck_pass4): Call e2fsck_process_bad_inode to check if a
disconnected inode has any problems before connecting it to
/lost+found. Bug and suggested fix by Pavel Machek <pavel@bug.ucw.cz>
ChangeLog, swapfs.c:
swapfs.c (ext2fs_swap_inode): Add compatibility for Linux 2.3 kernels
that use i_generation instead of i_version. Patch supplied by Jon
Bright <sircus@sircus.demon.co.uk>.
ChangeLog, mke2fs.8.in:
mke2fs.8.in: Fix typo in man page which caused the badblocks command
to not show up in the "SEE ALSO" section.
ChangeLog, expect.1, expect.2, image.gz, name:
f_recnect_bad: New test which checks the case where a disconnect inode
also bad inode fields; we need to make sure e2fsck offers to fix the
inode (or clear the inode, as necessary).
1999-06-25 23:40:18 +08:00
|
|
|
continue;
|
2008-02-02 16:16:32 +08:00
|
|
|
if (disconnect_inode(ctx, i, inode))
|
1997-04-29 22:53:37 +08:00
|
|
|
continue;
|
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_icount_fetch(ctx->inode_link_info, i,
|
|
|
|
&link_count);
|
|
|
|
ext2fs_icount_fetch(ctx->inode_count, i,
|
|
|
|
&link_counted);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2012-10-10 10:45:40 +08:00
|
|
|
isdir = ext2fs_test_inode_bitmap2(ctx->inode_dir_map, i);
|
2010-11-27 08:09:43 +08:00
|
|
|
if (isdir && (link_counted > EXT2_LINK_MAX))
|
2008-02-02 16:25:03 +08:00
|
|
|
link_counted = 1;
|
1997-04-30 00:15:03 +08:00
|
|
|
if (link_counted != link_count) {
|
2008-02-02 16:16:32 +08:00
|
|
|
e2fsck_read_inode(ctx, i, inode, "pass4");
|
1997-04-30 00:15:03 +08:00
|
|
|
pctx.ino = i;
|
2008-02-02 16:16:32 +08:00
|
|
|
pctx.inode = inode;
|
2010-11-27 08:09:43 +08:00
|
|
|
if ((link_count != inode->i_links_count) && !isdir &&
|
|
|
|
(inode->i_links_count <= EXT2_LINK_MAX)) {
|
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 = link_count;
|
|
|
|
fix_problem(ctx,
|
|
|
|
PR_4_INCONSISTENT_COUNT, &pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
1997-04-30 00:15:03 +08:00
|
|
|
pctx.num = link_counted;
|
2008-02-02 16:25:03 +08:00
|
|
|
/* i_link_count was previously exceeded, but no longer
|
|
|
|
* is, fix this but don't consider it an error */
|
2010-11-27 08:09:43 +08:00
|
|
|
if ((isdir && link_counted > 1 &&
|
2008-02-02 16:25:03 +08:00
|
|
|
(inode->i_flags & EXT2_INDEX_FL) &&
|
|
|
|
link_count == 1 && !(ctx->options & E2F_OPT_NO)) ||
|
2010-11-27 08:09:43 +08:00
|
|
|
fix_problem(ctx, PR_4_BAD_REF_COUNT, &pctx)) {
|
2008-02-02 16:16:32 +08:00
|
|
|
inode->i_links_count = link_counted;
|
|
|
|
e2fsck_write_inode(ctx, i, inode, "pass4");
|
1997-04-30 00:15:03 +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
|
|
|
ext2fs_free_icount(ctx->inode_link_info); ctx->inode_link_info = 0;
|
|
|
|
ext2fs_free_icount(ctx->inode_count); ctx->inode_count = 0;
|
|
|
|
ext2fs_free_inode_bitmap(ctx->inode_bb_map);
|
|
|
|
ctx->inode_bb_map = 0;
|
1999-11-09 02:46:54 +08:00
|
|
|
ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
|
|
|
|
ctx->inode_imagic_map = 0;
|
2007-03-29 00:43:05 +08:00
|
|
|
errout:
|
2002-05-21 21:14:17 +08:00
|
|
|
if (buf)
|
2003-08-01 21:41:07 +08:00
|
|
|
ext2fs_free_mem(&buf);
|
2008-02-02 16:16:32 +08:00
|
|
|
|
|
|
|
ext2fs_free_mem(&inode);
|
2009-05-28 21:55:10 +08:00
|
|
|
print_resource_track(ctx, _("Pass 4"), &rtrack, ctx->fs->io);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|