1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* pass1b.c --- Pass #1b of e2fsck
|
|
|
|
*
|
|
|
|
* This file contains pass1B, pass1C, and pass1D of e2fsck. They are
|
|
|
|
* only invoked if pass 1 discovered blocks which are in use by more
|
|
|
|
* than one inode.
|
|
|
|
*
|
|
|
|
* Pass1B scans the data blocks of all the inodes again, generating a
|
|
|
|
* complete list of duplicate blocks and which inodes have claimed
|
|
|
|
* them.
|
|
|
|
*
|
|
|
|
* Pass1C does a tree-traversal of the filesystem, to determine the
|
|
|
|
* parent directories of these inodes. This step is necessary so that
|
|
|
|
* e2fsck can print out the pathnames of affected inodes.
|
|
|
|
*
|
|
|
|
* Pass1D is a reconciliation pass. For each inode with duplicate
|
|
|
|
* blocks, the user is prompted if s/he would like to clone the file
|
|
|
|
* (so that the file gets a fresh copy of the duplicated blocks) or
|
|
|
|
* simply to delete the file.
|
|
|
|
*
|
1997-04-30 00:15:03 +08:00
|
|
|
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
1997-04-26 21:21:57 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <time.h>
|
1997-04-26 21:58:21 +08:00
|
|
|
#ifdef HAVE_ERRNO_H
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
#include <et/com_err.h>
|
|
|
|
#include "e2fsck.h"
|
|
|
|
|
1997-04-30 00:15:03 +08:00
|
|
|
#include "problem.h"
|
|
|
|
|
2001-07-02 23:54:09 +08:00
|
|
|
/* Define an extension to the ext2 library's block count information */
|
|
|
|
#define BLOCK_COUNT_EXTATTR (-5)
|
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* This is structure is allocated for each time that a block is
|
|
|
|
* claimed by more than one file. So if a particular block is claimed
|
|
|
|
* by 3 files, then three copies of this structure will be allocated,
|
|
|
|
* one for each conflict.
|
|
|
|
*
|
|
|
|
* The linked list structure is as follows:
|
|
|
|
*
|
|
|
|
* dup_blk --> block #34 --> block #35 --> block #47
|
|
|
|
* inode #12 inode #14 inode #17
|
|
|
|
* num_bad = 3 num_bad = 2 num_bad = 2
|
|
|
|
* | | |
|
|
|
|
* V V V
|
|
|
|
* block #34 block #35 block #47
|
|
|
|
* inode #14 inode #15 inode #23
|
|
|
|
* |
|
|
|
|
* V
|
|
|
|
* block #34
|
|
|
|
* inode #15
|
|
|
|
*
|
|
|
|
* The num_bad field indicates how many inodes are sharing a
|
|
|
|
* particular block, and is only stored in the first element of the
|
|
|
|
* linked list for a particular block. As the block conflicts are
|
|
|
|
* resolved, num_bad is decremented; when it reaches 1, then we no
|
|
|
|
* longer need to worry about that block.
|
|
|
|
*/
|
|
|
|
struct dup_block {
|
|
|
|
blk_t block; /* Block number */
|
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 ino; /* Inode number */
|
1997-04-26 21:21:57 +08:00
|
|
|
int num_bad;
|
2001-07-02 23:54:09 +08:00
|
|
|
int flags;
|
1997-04-26 21:21:57 +08:00
|
|
|
/* Pointer to next dup record with different block */
|
|
|
|
struct dup_block *next_block;
|
|
|
|
/* Pointer to next dup record with different inode */
|
|
|
|
struct dup_block *next_inode;
|
|
|
|
};
|
|
|
|
|
2001-07-02 23:54:09 +08:00
|
|
|
#define FLAG_EXTATTR (1)
|
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* This structure stores information about a particular inode which
|
|
|
|
* is sharing blocks with other inodes. This information is collected
|
|
|
|
* to display to the user, so that the user knows what files he or she
|
|
|
|
* is dealing with, when trying to decide how to resolve the conflict
|
|
|
|
* of multiply-claimed blocks.
|
|
|
|
*/
|
|
|
|
struct dup_inode {
|
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 ino, dir;
|
1997-04-30 00:15:03 +08:00
|
|
|
int num_dupblocks;
|
|
|
|
struct ext2_inode inode;
|
1997-04-26 21:21:57 +08:00
|
|
|
struct dup_inode *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int process_pass1b_block(ext2_filsys fs, blk_t *blocknr,
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
|
|
|
int ref_offset, void *priv_data);
|
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 delete_file(e2fsck_t ctx, struct dup_inode *dp,
|
1997-04-26 21:21:57 +08:00
|
|
|
char *block_buf);
|
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 int clone_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf);
|
2000-02-09 07:19:32 +08:00
|
|
|
static int check_if_fs_block(e2fsck_t ctx, blk_t test_blk);
|
|
|
|
|
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 pass1b(e2fsck_t ctx, char *block_buf);
|
|
|
|
static void pass1c(e2fsck_t ctx, char *block_buf);
|
|
|
|
static void pass1d(e2fsck_t ctx, char *block_buf);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
static struct dup_block *dup_blk = 0;
|
|
|
|
static struct dup_inode *dup_ino = 0;
|
|
|
|
static int dup_inode_count = 0;
|
|
|
|
|
1997-04-26 21:34:30 +08:00
|
|
|
static ext2fs_inode_bitmap inode_dup_map;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Main procedure for handling duplicate blocks
|
|
|
|
*/
|
1997-11-04 03:42:40 +08:00
|
|
|
void e2fsck_pass1_dupblocks(e2fsck_t ctx, char *block_buf)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
1997-04-26 21:21:57 +08:00
|
|
|
struct dup_block *p, *q, *next_p, *next_q;
|
|
|
|
struct dup_inode *r, *next_r;
|
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
|
|
|
|
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_allocate_inode_bitmap(fs,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 11:11:03 +08:00
|
|
|
_("multiply claimed inode map"), &inode_dup_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
|
|
|
if (pctx.errcode) {
|
|
|
|
fix_problem(ctx, PR_1B_ALLOCATE_IBITMAP_ERROR, &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
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
|
|
|
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
|
|
|
pass1b(ctx, block_buf);
|
|
|
|
pass1c(ctx, block_buf);
|
|
|
|
pass1d(ctx, block_buf);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Time to free all of the accumulated data structures that we
|
|
|
|
* don't need anymore.
|
|
|
|
*/
|
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(inode_dup_map); inode_dup_map = 0;
|
|
|
|
ext2fs_free_block_bitmap(ctx->block_dup_map); ctx->block_dup_map = 0;
|
1997-04-26 21:21:57 +08:00
|
|
|
for (p = dup_blk; p; p = next_p) {
|
|
|
|
next_p = p->next_block;
|
|
|
|
for (q = p; q; q = next_q) {
|
|
|
|
next_q = q->next_inode;
|
1997-11-04 03:42:40 +08:00
|
|
|
ext2fs_free_mem((void **) &q);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (r = dup_ino; r; r = next_r) {
|
|
|
|
next_r = r->next;
|
1997-11-04 03:42:40 +08:00
|
|
|
ext2fs_free_mem((void **) &r);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan the inodes looking for inodes that contain duplicate blocks.
|
|
|
|
*/
|
|
|
|
struct process_block_struct {
|
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 ino;
|
|
|
|
int dup_blocks;
|
|
|
|
e2fsck_t 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
|
|
|
struct problem_context *pctx;
|
1997-04-26 21:21:57 +08:00
|
|
|
};
|
|
|
|
|
1997-11-04 03:42:40 +08:00
|
|
|
static void pass1b(e2fsck_t ctx, char *block_buf)
|
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 ino;
|
1997-04-26 21:21:57 +08:00
|
|
|
struct ext2_inode inode;
|
|
|
|
ext2_inode_scan scan;
|
|
|
|
struct process_block_struct pb;
|
|
|
|
struct dup_inode *dp;
|
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
|
|
|
|
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_1B_PASS_HEADER, &pctx);
|
|
|
|
pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks,
|
|
|
|
&scan);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
fix_problem(ctx, PR_1B_ISCAN_ERROR, &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
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
|
|
|
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
|
|
|
pctx.errcode = ext2fs_get_next_inode(scan, &ino, &inode);
|
|
|
|
if (pctx.errcode) {
|
|
|
|
fix_problem(ctx, PR_1B_ISCAN_ERROR, &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
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
|
|
|
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
|
|
|
ctx->stashed_inode = &inode;
|
|
|
|
pb.ctx = ctx;
|
|
|
|
pb.pctx = &pctx;
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
pctx.str = "pass1b";
|
1997-04-26 21:21:57 +08:00
|
|
|
while (ino) {
|
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.ino = ctx->stashed_ino = ino;
|
1997-04-26 21:21:57 +08:00
|
|
|
if ((ino != EXT2_BAD_INO) &&
|
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_test_inode_bitmap(ctx->inode_used_map, ino) ||
|
1997-04-30 00:15:03 +08:00
|
|
|
!ext2fs_inode_has_valid_blocks(&inode)))
|
1997-04-26 21:21:57 +08:00
|
|
|
goto next;
|
|
|
|
|
|
|
|
pb.ino = ino;
|
|
|
|
pb.dup_blocks = 0;
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
pctx.errcode = ext2fs_block_iterate2(fs, ino, 0, block_buf,
|
1997-04-26 21:21:57 +08:00
|
|
|
process_pass1b_block, &pb);
|
2001-07-02 23:54:09 +08:00
|
|
|
if (inode.i_file_acl)
|
|
|
|
process_pass1b_block(fs, &inode.i_file_acl,
|
|
|
|
BLOCK_COUNT_EXTATTR, 0, 0, &pb);
|
1997-04-26 21:21:57 +08:00
|
|
|
if (pb.dup_blocks) {
|
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
|
|
|
end_problem_latch(ctx, PR_LATCH_DBLOCK);
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
dp = (struct dup_inode *) e2fsck_allocate_memory(ctx,
|
Many files:
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c: Add calls to the progress
indicator function.
pass1.c (scan_callback): Add call to the progress feedback function
(if it exists).
super.c (check_super_block): Skip the device size check if the
get_device_size returns EXT2_EXT_UNIMPLEMENTED.
iscan.c (main): Don't use fatal_error() anymore.
pass1b.c, swapfs.c, badblocks.c: Set E2F_FLAG_ABORT instead of calling
fatal_error(0).
problem.c, pass3.c (PR_3_ROOT_NOT_DIR_ABORT,
PR_3_NO_ROOT_INODE_ABORT): New problem codes.
problem.c, pass2.c (PR_2_SPLIT_DOT): New problem code.
problem.c, pass1.c (PR_1_SUPPRESS_MESSAGES): New problem code.
problemP.h: New file which separates out the private fix_problem data
structures.
util.c, dirinfo.c, pass1.c, pass1b.c, pass2.c, pass5.c, super.c,
swapfs.c util.c: allocate_memory() now takes a e2fsck context as its
first argument, and rename it to be e2fsck_allocate_memory().
problemP.h:
New file which contains the private problem abstraction definitions.
Makefile.pq:
Remove include of MAKEFILE.STD, which doesn't exist at this point.
1997-11-14 13:23:04 +08:00
|
|
|
sizeof(struct dup_inode),
|
|
|
|
"duplicate inode record");
|
1997-04-26 21:21:57 +08:00
|
|
|
dp->ino = ino;
|
1997-04-30 00:15:03 +08:00
|
|
|
dp->dir = 0;
|
|
|
|
dp->inode = inode;
|
1997-04-26 21:21:57 +08:00
|
|
|
dp->num_dupblocks = pb.dup_blocks;
|
|
|
|
dp->next = dup_ino;
|
|
|
|
dup_ino = dp;
|
|
|
|
if (ino != EXT2_BAD_INO)
|
|
|
|
dup_inode_count++;
|
|
|
|
}
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
if (pctx.errcode)
|
|
|
|
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
next:
|
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_get_next_inode(scan, &ino, &inode);
|
|
|
|
if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
|
1997-04-30 05:26:48 +08:00
|
|
|
goto next;
|
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 (pctx.errcode) {
|
|
|
|
fix_problem(ctx, PR_1B_ISCAN_ERROR, &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
|
|
|
ctx->flags |= E2F_FLAG_ABORT;
|
|
|
|
return;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ext2fs_close_inode_scan(scan);
|
2001-06-02 03:29:36 +08:00
|
|
|
e2fsck_use_inode_shortcuts(ctx, 0);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
2001-01-06 13:55:58 +08:00
|
|
|
static int process_pass1b_block(ext2_filsys fs,
|
|
|
|
blk_t *block_nr,
|
|
|
|
e2_blkcnt_t blockcnt,
|
|
|
|
blk_t ref_blk,
|
|
|
|
int ref_offset,
|
|
|
|
void *priv_data)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
|
|
|
struct process_block_struct *p;
|
|
|
|
struct dup_block *dp, *q, *r;
|
|
|
|
int 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
|
|
|
e2fsck_t ctx;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
unix.c (main): If compression is enabled on the filesystem, print a
warning message (for now).
message.c: Add new compression shortcut: @c == compress
problem.c, problem.h (PR_1_COMPR_SET): Add new error code.
pass1.c (check_blocks): If the inode has EXT2_COMPRBLK_FL flag set,
check to see if the filesystem supports compression. If it does pass
this information down to process_block() so it can treat the
compressed block flag words correctly. If not, offer to clear the
flag, since it shouldn't be set.
(process_block): If an inode has the compressed inode flag set, allow
EXT2FS_COMPRESSED_BLKADDR.
pass1b.c (process_pass1b_block, delete_file_block, clone_file_block):
pass2.c (deallocate_inode_block): Use HOLE_BLKADDR to check to see if
the block can be skipped.
ChangeLog, Makefile.in:
Makefile.in: Exclude the internationalization files from being
distributed.
ChangeLog, configure, configure.in:
configure.in: Add support for --enable-compression. This is
experimental code only for now, which is why it's under --enable test.
Once it's stable, it will always be compiled in.
TODO:
Commit additional TODO items.
2000-02-11 23:55:07 +08:00
|
|
|
if (HOLE_BLKADDR(*block_nr))
|
1997-04-26 21:21:57 +08:00
|
|
|
return 0;
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
p = (struct process_block_struct *) priv_data;
|
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 = p->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
|
|
|
if (ext2fs_test_block_bitmap(ctx->block_dup_map, *block_nr)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
/* OK, this is a duplicate block */
|
|
|
|
if (p->ino != EXT2_BAD_INO) {
|
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
|
|
|
p->pctx->blk = *block_nr;
|
|
|
|
fix_problem(ctx, PR_1B_DUP_BLOCK, p->pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
p->dup_blocks++;
|
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_mark_block_bitmap(ctx->block_dup_map, *block_nr);
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_mark_inode_bitmap(inode_dup_map, p->ino);
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
dp = (struct dup_block *) e2fsck_allocate_memory(ctx,
|
|
|
|
sizeof(struct dup_block),
|
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
|
|
|
"duplicate block record");
|
1997-04-26 21:21:57 +08:00
|
|
|
dp->block = *block_nr;
|
|
|
|
dp->ino = p->ino;
|
|
|
|
dp->num_bad = 0;
|
2001-07-02 23:54:09 +08:00
|
|
|
dp->flags = (blockcnt == BLOCK_COUNT_EXTATTR) ?
|
|
|
|
FLAG_EXTATTR : 0;
|
1997-04-26 21:21:57 +08:00
|
|
|
q = dup_blk;
|
|
|
|
while (q) {
|
|
|
|
if (q->block == *block_nr)
|
|
|
|
break;
|
|
|
|
q = q->next_block;
|
|
|
|
}
|
|
|
|
if (q) {
|
|
|
|
dp->next_inode = q->next_inode;
|
|
|
|
q->next_inode = dp;
|
|
|
|
} else {
|
|
|
|
dp->next_block = dup_blk;
|
|
|
|
dup_blk = dp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Set the num_bad field
|
|
|
|
*/
|
|
|
|
for (q = dup_blk; q; q = q->next_block) {
|
|
|
|
i = 0;
|
|
|
|
for (r = q; r; r = r->next_inode)
|
|
|
|
i++;
|
|
|
|
q->num_bad = i;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass 1c: Scan directories for inodes with duplicate blocks. This
|
|
|
|
* is used so that we can print pathnames when prompting the user for
|
|
|
|
* what to do.
|
|
|
|
*/
|
1997-04-30 00:15:03 +08:00
|
|
|
struct search_dir_struct {
|
1997-04-26 21:21:57 +08:00
|
|
|
int count;
|
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 first_inode;
|
|
|
|
ext2_ino_t max_inode;
|
1997-04-26 21:21:57 +08:00
|
|
|
};
|
|
|
|
|
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
|
|
|
static int search_dirent_proc(ext2_ino_t dir, int entry,
|
1997-04-30 00:15:03 +08:00
|
|
|
struct ext2_dir_entry *dirent,
|
|
|
|
int offset, int blocksize,
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
char *buf, void *priv_data)
|
1997-04-30 00:15:03 +08:00
|
|
|
{
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
struct search_dir_struct *sd;
|
1997-04-30 00:15:03 +08:00
|
|
|
struct dup_inode *p;
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
|
|
|
|
sd = (struct search_dir_struct *) priv_data;
|
|
|
|
|
1997-04-30 01:48:10 +08:00
|
|
|
if (dirent->inode > sd->max_inode)
|
|
|
|
/* Should abort this inode, but not everything */
|
|
|
|
return 0;
|
|
|
|
|
1997-04-30 00:15:03 +08:00
|
|
|
if (!dirent->inode || (entry < DIRENT_OTHER_FILE) ||
|
|
|
|
!ext2fs_test_inode_bitmap(inode_dup_map, dirent->inode))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (p = dup_ino; p; p = p->next) {
|
|
|
|
if ((p->ino >= sd->first_inode) &&
|
|
|
|
(p->ino == dirent->inode))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p || p->dir)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
p->dir = dir;
|
|
|
|
sd->count--;
|
|
|
|
|
|
|
|
return(sd->count ? 0 : DIRENT_ABORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-04 03:42:40 +08:00
|
|
|
static void pass1c(e2fsck_t ctx, char *block_buf)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
1997-04-26 21:21:57 +08:00
|
|
|
struct dup_inode *p;
|
|
|
|
int inodes_left = dup_inode_count;
|
1997-04-30 00:15:03 +08:00
|
|
|
struct search_dir_struct sd;
|
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
|
|
|
|
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_1C_PASS_HEADER, &pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First check to see if any of the inodes with dup blocks is
|
1997-04-30 00:15:03 +08:00
|
|
|
* a special inode. (Note that the bad block inode isn't
|
|
|
|
* counted.)
|
1997-04-26 21:21:57 +08:00
|
|
|
*/
|
|
|
|
for (p = dup_ino; p; p = p->next) {
|
1997-04-30 00:15:03 +08:00
|
|
|
if ((p->ino < EXT2_FIRST_INODE(fs->super)) &&
|
|
|
|
(p->ino != EXT2_BAD_INO))
|
1997-04-26 21:21:57 +08:00
|
|
|
inodes_left--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search through all directories to translate inodes to names
|
|
|
|
* (by searching for the containing directory for that inode.)
|
|
|
|
*/
|
1997-04-30 00:15:03 +08:00
|
|
|
sd.count = inodes_left;
|
|
|
|
sd.first_inode = EXT2_FIRST_INODE(fs->super);
|
1997-04-30 01:48:10 +08:00
|
|
|
sd.max_inode = fs->super->s_inodes_count;
|
1997-04-30 00:15:03 +08:00
|
|
|
ext2fs_dblist_dir_iterate(fs->dblist, 0, block_buf,
|
|
|
|
search_dirent_proc, &sd);
|
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 pass1d(e2fsck_t ctx, char *block_buf)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
1997-04-26 21:21:57 +08:00
|
|
|
struct dup_inode *p, *s;
|
|
|
|
struct dup_block *q, *r;
|
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 *shared;
|
1997-04-26 21:21:57 +08:00
|
|
|
int shared_len;
|
|
|
|
int i;
|
|
|
|
int file_ok;
|
1997-04-30 01:48:10 +08:00
|
|
|
int meta_data = 0;
|
1997-04-30 00:15:03 +08:00
|
|
|
struct 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
|
|
|
|
|
|
|
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
|
|
|
fix_problem(ctx, PR_1D_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
|
|
|
e2fsck_read_bitmaps(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
|
|
|
pctx.num = dup_inode_count;
|
|
|
|
fix_problem(ctx, PR_1D_NUM_DUP_INODES, &pctx);
|
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
|
|
|
shared = (ext2_ino_t *) e2fsck_allocate_memory(ctx,
|
|
|
|
sizeof(ext2_ino_t) * dup_inode_count,
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
"Shared inode list");
|
1997-04-26 21:21:57 +08:00
|
|
|
for (p = dup_ino; p; p = p->next) {
|
|
|
|
shared_len = 0;
|
|
|
|
file_ok = 1;
|
|
|
|
if (p->ino == EXT2_BAD_INO)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search through the duplicate records to see which
|
|
|
|
* inodes share blocks with this one
|
|
|
|
*/
|
|
|
|
for (q = dup_blk; q; q = q->next_block) {
|
|
|
|
/*
|
|
|
|
* See if this block is used by this inode.
|
|
|
|
* If it isn't, continue.
|
|
|
|
*/
|
|
|
|
for (r = q; r; r = r->next_inode)
|
|
|
|
if (r->ino == p->ino)
|
|
|
|
break;
|
|
|
|
if (!r)
|
|
|
|
continue;
|
|
|
|
if (q->num_bad > 1)
|
|
|
|
file_ok = 0;
|
2000-02-09 07:19:32 +08:00
|
|
|
if (check_if_fs_block(ctx, q->block)) {
|
1997-04-30 01:48:10 +08:00
|
|
|
file_ok = 0;
|
|
|
|
meta_data = 1;
|
|
|
|
}
|
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
/*
|
|
|
|
* Add all inodes used by this block to the
|
|
|
|
* shared[] --- which is a unique list, so
|
|
|
|
* if an inode is already in shared[], don't
|
|
|
|
* add it again.
|
|
|
|
*/
|
|
|
|
for (r = q; r; r = r->next_inode) {
|
|
|
|
if (r->ino == p->ino)
|
|
|
|
continue;
|
|
|
|
for (i = 0; i < shared_len; i++)
|
|
|
|
if (shared[i] == r->ino)
|
|
|
|
break;
|
|
|
|
if (i == shared_len) {
|
|
|
|
shared[shared_len++] = r->ino;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-04-30 00:15:03 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Report the inode that we are working on
|
|
|
|
*/
|
|
|
|
pctx.inode = &p->inode;
|
|
|
|
pctx.ino = p->ino;
|
|
|
|
pctx.dir = p->dir;
|
|
|
|
pctx.blkcount = p->num_dupblocks;
|
1997-04-30 01:48:10 +08:00
|
|
|
pctx.num = meta_data ? shared_len+1 : shared_len;
|
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_1D_DUP_FILE, &pctx);
|
1997-04-30 00:15:03 +08:00
|
|
|
pctx.blkcount = 0;
|
|
|
|
pctx.num = 0;
|
|
|
|
|
1997-04-30 01:48:10 +08:00
|
|
|
if (meta_data)
|
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_1D_SHARE_METADATA, &pctx);
|
1997-04-30 01:48:10 +08:00
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
for (i = 0; i < shared_len; i++) {
|
|
|
|
for (s = dup_ino; s; s = s->next)
|
|
|
|
if (s->ino == shared[i])
|
|
|
|
break;
|
|
|
|
if (!s)
|
|
|
|
continue;
|
1997-04-30 00:15:03 +08:00
|
|
|
/*
|
|
|
|
* Report the inode that we are sharing with
|
|
|
|
*/
|
|
|
|
pctx.inode = &s->inode;
|
|
|
|
pctx.ino = s->ino;
|
|
|
|
pctx.dir = s->dir;
|
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_1D_DUP_FILE_LIST, &pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
if (file_ok) {
|
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_1D_DUP_BLOCKS_DEALT, &pctx);
|
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
|
|
|
if (fix_problem(ctx, PR_1D_CLONE_QUESTION, &pctx)) {
|
|
|
|
pctx.errcode = clone_file(ctx, p, block_buf);
|
|
|
|
if (pctx.errcode)
|
|
|
|
fix_problem(ctx, PR_1D_CLONE_ERROR, &pctx);
|
|
|
|
else
|
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
|
|
|
if (fix_problem(ctx, PR_1D_DELETE_QUESTION, &pctx))
|
|
|
|
delete_file(ctx, p, block_buf);
|
1997-04-26 21:21:57 +08:00
|
|
|
else
|
|
|
|
ext2fs_unmark_valid(fs);
|
|
|
|
}
|
1997-11-04 03:42:40 +08:00
|
|
|
ext2fs_free_mem((void **) &shared);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
2001-07-08 01:20:34 +08:00
|
|
|
/*
|
|
|
|
* Drop the refcount on the dup_block structure, and clear the entry
|
|
|
|
* in the block_dup_map if appropriate.
|
|
|
|
*/
|
|
|
|
static void decrement_badcount(e2fsck_t ctx, struct dup_block *p)
|
|
|
|
{
|
|
|
|
p->num_bad--;
|
|
|
|
if (p->num_bad <= 0 ||
|
|
|
|
(p->num_bad == 1 && !check_if_fs_block(ctx, p->block)))
|
|
|
|
ext2fs_unmark_block_bitmap(ctx->block_dup_map, p->block);
|
|
|
|
}
|
|
|
|
|
1997-04-26 21:21:57 +08:00
|
|
|
static int delete_file_block(ext2_filsys fs,
|
|
|
|
blk_t *block_nr,
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
e2_blkcnt_t blockcnt,
|
|
|
|
blk_t ref_block,
|
|
|
|
int ref_offset,
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
void *priv_data)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
struct process_block_struct *pb;
|
1997-04-26 21:21:57 +08:00
|
|
|
struct dup_block *p;
|
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
|
|
|
e2fsck_t ctx;
|
|
|
|
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
pb = (struct process_block_struct *) priv_data;
|
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 = pb->ctx;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
Many files:
unix.c (main): If compression is enabled on the filesystem, print a
warning message (for now).
message.c: Add new compression shortcut: @c == compress
problem.c, problem.h (PR_1_COMPR_SET): Add new error code.
pass1.c (check_blocks): If the inode has EXT2_COMPRBLK_FL flag set,
check to see if the filesystem supports compression. If it does pass
this information down to process_block() so it can treat the
compressed block flag words correctly. If not, offer to clear the
flag, since it shouldn't be set.
(process_block): If an inode has the compressed inode flag set, allow
EXT2FS_COMPRESSED_BLKADDR.
pass1b.c (process_pass1b_block, delete_file_block, clone_file_block):
pass2.c (deallocate_inode_block): Use HOLE_BLKADDR to check to see if
the block can be skipped.
ChangeLog, Makefile.in:
Makefile.in: Exclude the internationalization files from being
distributed.
ChangeLog, configure, configure.in:
configure.in: Add support for --enable-compression. This is
experimental code only for now, which is why it's under --enable test.
Once it's stable, it will always be compiled in.
TODO:
Commit additional TODO items.
2000-02-11 23:55:07 +08:00
|
|
|
if (HOLE_BLKADDR(*block_nr))
|
1997-04-26 21:21:57 +08:00
|
|
|
return 0;
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (ext2fs_test_block_bitmap(ctx->block_dup_map, *block_nr)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
for (p = dup_blk; p; p = p->next_block)
|
|
|
|
if (p->block == *block_nr)
|
|
|
|
break;
|
|
|
|
if (p) {
|
2001-07-08 01:20:34 +08:00
|
|
|
decrement_badcount(ctx, p);
|
1997-04-26 21:21:57 +08:00
|
|
|
} else
|
|
|
|
com_err("delete_file_block", 0,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 11:11:03 +08:00
|
|
|
_("internal error; can't find dup_blk for %d\n"),
|
1997-04-26 21:21:57 +08:00
|
|
|
*block_nr);
|
|
|
|
} else {
|
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_unmark_block_bitmap(ctx->block_found_map, *block_nr);
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_unmark_block_bitmap(fs->block_map, *block_nr);
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static void delete_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
1997-04-26 21:21:57 +08:00
|
|
|
struct process_block_struct pb;
|
|
|
|
struct ext2_inode inode;
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
struct problem_context pctx;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
clear_problem_context(&pctx);
|
|
|
|
pctx.ino = pb.ino = dp->ino;
|
1997-04-26 21:21:57 +08:00
|
|
|
pb.dup_blocks = dp->num_dupblocks;
|
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
|
|
|
pb.ctx = ctx;
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
pctx.str = "delete_file";
|
|
|
|
|
|
|
|
pctx.errcode = ext2fs_block_iterate2(fs, dp->ino, 0, block_buf,
|
|
|
|
delete_file_block, &pb);
|
|
|
|
if (pctx.errcode)
|
|
|
|
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &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
|
|
|
ext2fs_unmark_inode_bitmap(ctx->inode_used_map, dp->ino);
|
|
|
|
ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, dp->ino);
|
|
|
|
if (ctx->inode_bad_map)
|
|
|
|
ext2fs_unmark_inode_bitmap(ctx->inode_bad_map, dp->ino);
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_unmark_inode_bitmap(fs->inode_map, dp->ino);
|
1997-04-26 21:21:57 +08:00
|
|
|
ext2fs_mark_ib_dirty(fs);
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
1997-11-04 03:42:40 +08:00
|
|
|
e2fsck_read_inode(ctx, dp->ino, &inode, "delete_file");
|
1997-04-26 21:21:57 +08:00
|
|
|
inode.i_links_count = 0;
|
|
|
|
inode.i_dtime = time(0);
|
2001-07-02 23:54:09 +08:00
|
|
|
if (inode.i_file_acl)
|
|
|
|
delete_file_block(fs, &inode.i_file_acl,
|
|
|
|
BLOCK_COUNT_EXTATTR, 0, 0, &pb);
|
1997-11-04 03:42:40 +08:00
|
|
|
e2fsck_write_inode(ctx, dp->ino, &inode, "delete_file");
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct clone_struct {
|
|
|
|
errcode_t errcode;
|
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 dir;
|
1997-04-26 21:21:57 +08:00
|
|
|
char *buf;
|
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
|
|
|
e2fsck_t ctx;
|
1997-04-26 21:21:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int clone_file_block(ext2_filsys fs,
|
|
|
|
blk_t *block_nr,
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
e2_blkcnt_t blockcnt,
|
|
|
|
blk_t ref_block,
|
|
|
|
int ref_offset,
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
void *priv_data)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
|
|
|
struct dup_block *p;
|
|
|
|
blk_t new_block;
|
|
|
|
errcode_t retval;
|
Many files:
e2fsck.h: If EXT2_FLAT_INCLUDES is defined, then assume all of
the ext2-specific header files are in a flat directory.
dirinfo.c, ehandler.c, pass1.c, pass1b.c, pass2.c, pass5.c,
super.c, swapfs.c, unix.c: Explicitly cast all assignments
from void * to be compatible with C++.
unix.c (sync_disk): Remove sync_disk and calls to that function,
since ext2fs_close() now takes care of this.
pass1.c, pass1b.c, pass2.c, pass3.c, swapfs, badblocks.c,
ehandler.c, unix.c: Change use of private to be priv_data, to
avoid C++ reserved name clash.
1998-01-19 22:50:49 +08:00
|
|
|
struct clone_struct *cs = (struct clone_struct *) priv_data;
|
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
|
|
|
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
|
|
|
ctx = cs->ctx;
|
|
|
|
|
Many files:
unix.c (main): If compression is enabled on the filesystem, print a
warning message (for now).
message.c: Add new compression shortcut: @c == compress
problem.c, problem.h (PR_1_COMPR_SET): Add new error code.
pass1.c (check_blocks): If the inode has EXT2_COMPRBLK_FL flag set,
check to see if the filesystem supports compression. If it does pass
this information down to process_block() so it can treat the
compressed block flag words correctly. If not, offer to clear the
flag, since it shouldn't be set.
(process_block): If an inode has the compressed inode flag set, allow
EXT2FS_COMPRESSED_BLKADDR.
pass1b.c (process_pass1b_block, delete_file_block, clone_file_block):
pass2.c (deallocate_inode_block): Use HOLE_BLKADDR to check to see if
the block can be skipped.
ChangeLog, Makefile.in:
Makefile.in: Exclude the internationalization files from being
distributed.
ChangeLog, configure, configure.in:
configure.in: Add support for --enable-compression. This is
experimental code only for now, which is why it's under --enable test.
Once it's stable, it will always be compiled in.
TODO:
Commit additional TODO items.
2000-02-11 23:55:07 +08:00
|
|
|
if (HOLE_BLKADDR(*block_nr))
|
1997-04-26 21:21:57 +08:00
|
|
|
return 0;
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
if (ext2fs_test_block_bitmap(ctx->block_dup_map, *block_nr)) {
|
1997-04-26 21:21:57 +08:00
|
|
|
for (p = dup_blk; p; p = p->next_block)
|
|
|
|
if (p->block == *block_nr)
|
|
|
|
break;
|
|
|
|
if (p) {
|
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
|
|
|
retval = ext2fs_new_block(fs, 0, ctx->block_found_map,
|
1997-04-26 21:21:57 +08:00
|
|
|
&new_block);
|
|
|
|
if (retval) {
|
|
|
|
cs->errcode = retval;
|
|
|
|
return BLOCK_ABORT;
|
|
|
|
}
|
2001-06-02 03:29:36 +08:00
|
|
|
if (cs->dir && (blockcnt >= 0)) {
|
1997-04-30 01:48:10 +08:00
|
|
|
retval = ext2fs_set_dir_block(fs->dblist,
|
|
|
|
cs->dir, new_block, blockcnt);
|
|
|
|
if (retval) {
|
|
|
|
cs->errcode = retval;
|
|
|
|
return BLOCK_ABORT;
|
|
|
|
}
|
|
|
|
}
|
1997-04-26 21:21:57 +08:00
|
|
|
retval = io_channel_read_blk(fs->io, *block_nr, 1,
|
|
|
|
cs->buf);
|
|
|
|
if (retval) {
|
|
|
|
cs->errcode = retval;
|
|
|
|
return BLOCK_ABORT;
|
|
|
|
}
|
|
|
|
retval = io_channel_write_blk(fs->io, new_block, 1,
|
|
|
|
cs->buf);
|
|
|
|
if (retval) {
|
|
|
|
cs->errcode = retval;
|
|
|
|
return BLOCK_ABORT;
|
|
|
|
}
|
2001-07-08 01:20:34 +08:00
|
|
|
decrement_badcount(ctx, p);
|
1997-04-26 21:21:57 +08:00
|
|
|
*block_nr = new_block;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2fs_mark_block_bitmap(ctx->block_found_map,
|
1997-04-26 21:21:57 +08:00
|
|
|
new_block);
|
1997-04-26 21:34:30 +08:00
|
|
|
ext2fs_mark_block_bitmap(fs->block_map, new_block);
|
1997-04-26 21:21:57 +08:00
|
|
|
return BLOCK_CHANGED;
|
|
|
|
} else
|
|
|
|
com_err("clone_file_block", 0,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 11:11:03 +08:00
|
|
|
_("internal error; can't find dup_blk for %d\n"),
|
1997-04-26 21:21:57 +08:00
|
|
|
*block_nr);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
static int clone_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf)
|
1997-04-26 21:21:57 +08:00
|
|
|
{
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
ext2_filsys fs = ctx->fs;
|
1997-04-26 21:21:57 +08:00
|
|
|
errcode_t retval;
|
|
|
|
struct clone_struct cs;
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
struct problem_context pctx;
|
2001-07-08 01:20:34 +08:00
|
|
|
blk_t blk;
|
1997-04-26 21:21:57 +08:00
|
|
|
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
clear_problem_context(&pctx);
|
1997-04-26 21:21:57 +08:00
|
|
|
cs.errcode = 0;
|
1997-04-30 01:48:10 +08:00
|
|
|
cs.dir = 0;
|
Many files:
pass*.c, super.c: Massive changes to avoid using printf and com_err
routines. All diagnostic messages are now routed through the
fix_problem interface.
pass2.c (check_dir_block): Check for duplicate '.' and '..' entries.
problem.c, problem.h: Add new problem codes PR_2_DUP_DOT and
PR_2_DUP_DOT_DOT.
problem.c: Added new problem codes for some of the superblock
corruption checks, and for the pass header messages. ("Pass
1: xxxxx")
util.c (print_resource_track): Now takes a description argument.
super.c, unix.c, e2fsck.c: New files to separate out the
operating-specific operations out from e2fsck.c. e2fsck.c now
contains the global e2fsck context management routines, and
super.c contains the "pass 0" initial validation of the
superblock and global block group descriptors.
pass1.c, pass2.c, pass3.c, pass4.c, pass5.c, util.c: Eliminate
(nearly) all global variables and moved them to the e2fsck
context structure.
problem.c, problem.h: Added new problem codes PR_0_SB_CORRUPT,
PR_0_FS_SIZE_WRONG, PR_0_NO_FRAGMENTS, PR_0_BLOCKS_PER_GROUP,
PR_0_FIRST_DATA_BLOCK
expect.1, expect.2:
Updated tests to align with e2fsck problem.c changes.
1997-10-04 01:48:10 +08:00
|
|
|
cs.ctx = ctx;
|
1997-11-04 03:42:40 +08:00
|
|
|
retval = ext2fs_get_mem(fs->blocksize, (void **) &cs.buf);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
1997-04-30 01:48:10 +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 (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dp->ino))
|
1997-04-30 01:48:10 +08:00
|
|
|
cs.dir = dp->ino;
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
|
|
|
|
pctx.ino = dp->ino;
|
|
|
|
pctx.str = "clone_file";
|
|
|
|
pctx.errcode = ext2fs_block_iterate2(fs, dp->ino, 0, block_buf,
|
1997-04-26 21:21:57 +08:00
|
|
|
clone_file_block, &cs);
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
ChangeLog, message.c, pass1b.c, pass2.c, pass3.c, problem.c, problem.h:
pass1b.c: Change routines to use PR_1B_BLOCK_ITERATE when reporting
problems rather than using com_err directly.
problem.c, problem.h (PR_1B_BLOCK_ITERATE): Add new problem code.
message.c (expand_percent_expression): Add safety check. If ctx->str
is NULL, print "NULL" instead of dereferencing the null pointer.
pass1b.c, pass2.c, pass3.c: Change calls to ext2fs_block_iterate to
ext2fs_block_iterate2, to support 64-bit filesizes and to speed things
up slightly by avoiding the use of the ext2fs_block_iterate's
compatibility shim layer.
version.h:
Update for WIP release.
2000-11-17 13:40:49 +08:00
|
|
|
if (pctx.errcode) {
|
|
|
|
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
|
2001-07-08 01:20:34 +08:00
|
|
|
retval = pctx.errcode;
|
|
|
|
goto errout;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
|
|
|
if (cs.errcode) {
|
1997-10-24 12:18:21 +08:00
|
|
|
com_err("clone_file", cs.errcode,
|
Many files:
badblocks.c, e2fsck.h, ehandler.c, emptydir.c, extend.c, flushb.c,
iscan.c, message.c, pass1.c, pass1b.c, pass3.c pass4.c, pass5.c,
problem.c, scantest.c, swapfs.c, unix.c, util.c: Add
Internationalization support as suggested by Marco d'Itri
<md@linux.it>.
2000-02-07 11:11:03 +08:00
|
|
|
_("returned from clone_file_block"));
|
2001-07-08 01:20:34 +08:00
|
|
|
retval = cs.errcode;
|
|
|
|
goto errout;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2001-07-08 01:20:34 +08:00
|
|
|
blk = dp->inode.i_file_acl;
|
|
|
|
if (blk && (clone_file_block(fs, &dp->inode.i_file_acl,
|
|
|
|
BLOCK_COUNT_EXTATTR, 0, 0, &cs) ==
|
|
|
|
BLOCK_CHANGED)) {
|
|
|
|
struct dup_block *p, *q;
|
|
|
|
struct dup_inode *r;
|
2001-07-02 23:54:09 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we cloned the EA block, find all other inodes
|
|
|
|
* which refered to that EA block, and modify
|
|
|
|
* them to point to the new EA block.
|
|
|
|
*/
|
|
|
|
for (p = dup_blk; p; p = p->next_block) {
|
2001-07-08 01:20:34 +08:00
|
|
|
if (p->block == blk)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (q = p; q ; q = q->next_inode) {
|
|
|
|
if (!(q->flags & FLAG_EXTATTR))
|
2001-07-02 23:54:09 +08:00
|
|
|
continue;
|
2001-07-08 01:20:34 +08:00
|
|
|
for (r = dup_ino; r; r = r->next)
|
|
|
|
if (r->ino == q->ino)
|
2001-07-02 23:54:09 +08:00
|
|
|
break;
|
2001-07-08 01:20:34 +08:00
|
|
|
if (r) {
|
|
|
|
r->inode.i_file_acl = dp->inode.i_file_acl;
|
|
|
|
e2fsck_write_inode(ctx, q->ino, &r->inode,
|
|
|
|
"clone file EA");
|
|
|
|
}
|
|
|
|
q->ino = 0; /* Should free the structure... */
|
|
|
|
decrement_badcount(ctx, p);
|
2001-07-02 23:54:09 +08:00
|
|
|
}
|
|
|
|
}
|
2001-07-08 01:20:34 +08:00
|
|
|
retval = 0;
|
|
|
|
errout:
|
|
|
|
ext2fs_free_mem((void **) &cs.buf);
|
|
|
|
return retval;
|
1997-04-26 21:21:57 +08:00
|
|
|
}
|
2000-02-09 07:19:32 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This routine returns 1 if a block overlaps with one of the superblocks,
|
|
|
|
* group descriptors, inode bitmaps, or block bitmaps.
|
|
|
|
*/
|
|
|
|
static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
|
|
|
|
{
|
|
|
|
ext2_filsys fs = ctx->fs;
|
|
|
|
blk_t block;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
block = fs->super->s_first_data_block;
|
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
|
|
|
|
|
|
|
/* Check superblocks/block group descriptros */
|
|
|
|
if (ext2fs_bg_has_super(fs, i)) {
|
|
|
|
if (test_block >= block &&
|
|
|
|
(test_block <= block + fs->desc_blocks))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the inode table */
|
|
|
|
if ((fs->group_desc[i].bg_inode_table) &&
|
|
|
|
(test_block >= fs->group_desc[i].bg_inode_table) &&
|
|
|
|
(test_block < (fs->group_desc[i].bg_inode_table +
|
|
|
|
fs->inode_blocks_per_group)))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Check the bitmap blocks */
|
|
|
|
if ((test_block == fs->group_desc[i].bg_block_bitmap) ||
|
|
|
|
(test_block == fs->group_desc[i].bg_inode_bitmap))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
block += fs->super->s_blocks_per_group;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|