mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2025-01-19 23:13:43 +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.
This commit is contained in:
parent
8ddaa66bfe
commit
133a56dc9d
@ -1,3 +1,19 @@
|
||||
2000-11-16 Theodore Ts'o <tytso@valinux.com>
|
||||
|
||||
* 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.
|
||||
|
||||
2000-10-30 <tytso@snap.thunk.org>
|
||||
|
||||
* util.c (get_backup_sb): Calculate backup superblock correctly
|
||||
|
@ -389,7 +389,7 @@ static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch,
|
||||
printf("%d", get_backup_sb(fs));
|
||||
break;
|
||||
case 's':
|
||||
printf("%s", ctx->str);
|
||||
printf("%s", ctx->str ? ctx->str : "NULL");
|
||||
break;
|
||||
case 'X':
|
||||
#ifdef EXT2_NO_64_TYPE
|
||||
|
@ -88,7 +88,8 @@ struct dup_inode {
|
||||
};
|
||||
|
||||
static int process_pass1b_block(ext2_filsys fs, blk_t *blocknr,
|
||||
int blockcnt, void *priv_data);
|
||||
e2_blkcnt_t blockcnt, blk_t ref_blk,
|
||||
int ref_offset, void *priv_data);
|
||||
static void delete_file(e2fsck_t ctx, struct dup_inode *dp,
|
||||
char *block_buf);
|
||||
static int clone_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf);
|
||||
@ -187,6 +188,7 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
|
||||
ctx->stashed_inode = &inode;
|
||||
pb.ctx = ctx;
|
||||
pb.pctx = &pctx;
|
||||
pctx.str = "pass1b";
|
||||
while (ino) {
|
||||
pctx.ino = ctx->stashed_ino = ino;
|
||||
if ((ino != EXT2_BAD_INO) &&
|
||||
@ -196,7 +198,7 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
|
||||
|
||||
pb.ino = ino;
|
||||
pb.dup_blocks = 0;
|
||||
retval = ext2fs_block_iterate(fs, ino, 0, block_buf,
|
||||
pctx.errcode = ext2fs_block_iterate2(fs, ino, 0, block_buf,
|
||||
process_pass1b_block, &pb);
|
||||
if (pb.dup_blocks) {
|
||||
end_problem_latch(ctx, PR_LATCH_DBLOCK);
|
||||
@ -212,10 +214,8 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
|
||||
if (ino != EXT2_BAD_INO)
|
||||
dup_inode_count++;
|
||||
}
|
||||
if (retval)
|
||||
com_err(ctx->program_name, retval,
|
||||
_("while calling ext2fs_block_iterate in pass1b"));
|
||||
|
||||
if (pctx.errcode)
|
||||
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
|
||||
next:
|
||||
pctx.errcode = ext2fs_get_next_inode(scan, &ino, &inode);
|
||||
if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
|
||||
@ -233,7 +233,9 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
|
||||
|
||||
int process_pass1b_block(ext2_filsys fs,
|
||||
blk_t *block_nr,
|
||||
int blockcnt,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk_t ref_blk,
|
||||
int ref_offset,
|
||||
void *priv_data)
|
||||
{
|
||||
struct process_block_struct *p;
|
||||
@ -483,7 +485,9 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
|
||||
|
||||
static int delete_file_block(ext2_filsys fs,
|
||||
blk_t *block_nr,
|
||||
int blockcnt,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk_t ref_block,
|
||||
int ref_offset,
|
||||
void *priv_data)
|
||||
{
|
||||
struct process_block_struct *pb;
|
||||
@ -523,17 +527,18 @@ static void delete_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf)
|
||||
errcode_t retval;
|
||||
struct process_block_struct pb;
|
||||
struct ext2_inode inode;
|
||||
struct problem_context pctx;
|
||||
|
||||
pb.ino = dp->ino;
|
||||
clear_problem_context(&pctx);
|
||||
pctx.ino = pb.ino = dp->ino;
|
||||
pb.dup_blocks = dp->num_dupblocks;
|
||||
pb.ctx = ctx;
|
||||
|
||||
retval = ext2fs_block_iterate(fs, dp->ino, 0, block_buf,
|
||||
delete_file_block, &pb);
|
||||
if (retval)
|
||||
com_err("delete_file", retval,
|
||||
_("while calling ext2fs_block_iterate for inode %d"),
|
||||
dp->ino);
|
||||
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);
|
||||
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)
|
||||
@ -556,7 +561,9 @@ struct clone_struct {
|
||||
|
||||
static int clone_file_block(ext2_filsys fs,
|
||||
blk_t *block_nr,
|
||||
int blockcnt,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk_t ref_block,
|
||||
int ref_offset,
|
||||
void *priv_data)
|
||||
{
|
||||
struct dup_block *p;
|
||||
@ -624,7 +631,9 @@ static int clone_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf)
|
||||
ext2_filsys fs = ctx->fs;
|
||||
errcode_t retval;
|
||||
struct clone_struct cs;
|
||||
struct problem_context pctx;
|
||||
|
||||
clear_problem_context(&pctx);
|
||||
cs.errcode = 0;
|
||||
cs.dir = 0;
|
||||
cs.ctx = ctx;
|
||||
@ -634,21 +643,21 @@ static int clone_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf)
|
||||
|
||||
if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dp->ino))
|
||||
cs.dir = dp->ino;
|
||||
|
||||
retval = ext2fs_block_iterate(fs, dp->ino, 0, block_buf,
|
||||
|
||||
pctx.ino = dp->ino;
|
||||
pctx.str = "clone_file";
|
||||
pctx.errcode = ext2fs_block_iterate2(fs, dp->ino, 0, block_buf,
|
||||
clone_file_block, &cs);
|
||||
ext2fs_mark_bb_dirty(fs);
|
||||
ext2fs_free_mem((void **) &cs.buf);
|
||||
if (retval) {
|
||||
com_err("clone_file", retval,
|
||||
_("while calling ext2fs_block_iterate for inode %d"),
|
||||
dp->ino);
|
||||
return retval;
|
||||
if (pctx.errcode) {
|
||||
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
|
||||
return pctx.errcode;
|
||||
}
|
||||
if (cs.errcode) {
|
||||
com_err("clone_file", cs.errcode,
|
||||
_("returned from clone_file_block"));
|
||||
return retval;
|
||||
return cs.errcode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -63,7 +63,9 @@ static int allocate_dir_block(e2fsck_t ctx,
|
||||
char *buf, struct problem_context *pctx);
|
||||
static int update_dir_block(ext2_filsys fs,
|
||||
blk_t *block_nr,
|
||||
int blockcnt,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk_t ref_block,
|
||||
int ref_offset,
|
||||
void *priv_data);
|
||||
|
||||
struct check_dir_struct {
|
||||
@ -599,9 +601,11 @@ static int check_dir_block(ext2_filsys fs,
|
||||
* functioned called by deallocate inode via ext2fs_iterate_block().
|
||||
*/
|
||||
static int deallocate_inode_block(ext2_filsys fs,
|
||||
blk_t *block_nr,
|
||||
int blockcnt,
|
||||
void *priv_data)
|
||||
blk_t *block_nr,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk_t ref_block,
|
||||
int ref_offset,
|
||||
void *priv_data)
|
||||
{
|
||||
e2fsck_t ctx = (e2fsck_t) priv_data;
|
||||
|
||||
@ -645,7 +649,7 @@ static void deallocate_inode(e2fsck_t ctx, ino_t ino,
|
||||
return;
|
||||
|
||||
ext2fs_mark_bb_dirty(fs);
|
||||
pctx.errcode = ext2fs_block_iterate(fs, ino, 0, block_buf,
|
||||
pctx.errcode = ext2fs_block_iterate2(fs, ino, 0, block_buf,
|
||||
deallocate_inode_block, ctx);
|
||||
if (pctx.errcode) {
|
||||
fix_problem(ctx, PR_2_DEALLOC_INODE, &pctx);
|
||||
@ -831,7 +835,7 @@ static int allocate_dir_block(e2fsck_t ctx,
|
||||
* Finally, update the block pointers for the inode
|
||||
*/
|
||||
db->blk = blk;
|
||||
pctx->errcode = ext2fs_block_iterate(fs, db->ino, BLOCK_FLAG_HOLE,
|
||||
pctx->errcode = ext2fs_block_iterate2(fs, db->ino, BLOCK_FLAG_HOLE,
|
||||
0, update_dir_block, db);
|
||||
if (pctx->errcode) {
|
||||
pctx->str = "ext2fs_block_iterate";
|
||||
@ -847,13 +851,15 @@ static int allocate_dir_block(e2fsck_t ctx,
|
||||
*/
|
||||
static int update_dir_block(ext2_filsys fs,
|
||||
blk_t *block_nr,
|
||||
int blockcnt,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk_t ref_block,
|
||||
int ref_offset,
|
||||
void *priv_data)
|
||||
{
|
||||
struct ext2_db_entry *db;
|
||||
|
||||
db = (struct ext2_db_entry *) priv_data;
|
||||
if (db->blockcnt == blockcnt) {
|
||||
if (db->blockcnt == (int) blockcnt) {
|
||||
*block_nr = db->blk;
|
||||
return BLOCK_CHANGED;
|
||||
}
|
||||
|
@ -680,7 +680,9 @@ struct expand_dir_struct {
|
||||
|
||||
static int expand_dir_proc(ext2_filsys fs,
|
||||
blk_t *blocknr,
|
||||
int blockcnt,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk_t ref_block,
|
||||
int ref_offset,
|
||||
void *priv_data)
|
||||
{
|
||||
struct expand_dir_struct *es = (struct expand_dir_struct *) priv_data;
|
||||
@ -761,8 +763,8 @@ static errcode_t expand_directory(e2fsck_t ctx, ino_t dir)
|
||||
es.newblocks = 0;
|
||||
es.ctx = ctx;
|
||||
|
||||
retval = ext2fs_block_iterate(fs, dir, BLOCK_FLAG_APPEND,
|
||||
0, expand_dir_proc, &es);
|
||||
retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND,
|
||||
0, expand_dir_proc, &es);
|
||||
|
||||
if (es.err)
|
||||
return es.err;
|
||||
|
@ -470,7 +470,7 @@ static const struct e2fsck_problem problem_table[] = {
|
||||
|
||||
/* Error while iterating over blocks */
|
||||
{ PR_1_BLOCK_ITERATE,
|
||||
N_("Error while iterating over blocks in @i %i: %m\n"),
|
||||
N_("Error while iterating over @bs in @i %i: %m\n"),
|
||||
PROMPT_NONE, PR_FATAL },
|
||||
|
||||
/* Error while storing inode count information */
|
||||
@ -551,7 +551,11 @@ static const struct e2fsck_problem problem_table[] = {
|
||||
N_("@A @i @B (inode_dup_map): %m\n"),
|
||||
PROMPT_NONE, PR_FATAL },
|
||||
|
||||
|
||||
/* Error while iterating over blocks */
|
||||
{ PR_1B_BLOCK_ITERATE,
|
||||
N_("Error while iterating over @bs in @i %i (%s): %m\n"),
|
||||
PROMPT_NONE, 0 },
|
||||
|
||||
/* Pass 1C: Scan directories for inodes with dup blocks. */
|
||||
{ PR_1C_PASS_HEADER,
|
||||
N_("Pass 1C: Scan directories for @is with dup @bs.\n"),
|
||||
|
@ -321,7 +321,10 @@ struct problem_context {
|
||||
/* Error allocating inode bitmap */
|
||||
#define PR_1B_ALLOCATE_IBITMAP_ERROR 0x011005
|
||||
|
||||
/* Error while iterating over blocks */
|
||||
#define PR_1B_BLOCK_ITERATE 0x0110006
|
||||
|
||||
|
||||
/* Pass 1C: Scan directories for inodes with dup blocks. */
|
||||
#define PR_1C_PASS_HEADER 0x012000
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user