Many files:
Change the progress function to return an integer; if returns 1, then
the progress function is expected to have set the e2fsck context flag
signalling a user abort, and the caller should also initiate a user
abort.
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index a77f197..36dc54a 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,10 @@
+Tue Feb 24 15:19:40 1998 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * Change the progress function to return an integer; if returns 1,
+ then the progress function is expected to have set the
+ e2fsck context flag signalling a user abort, and the
+ caller should also initiate a user abort.
+
Tue Feb 17 19:03:44 1998 Theodore Ts'o <tytso@rsts-11.mit.edu>
* pass5.c (check_block_bitmaps, check_inode_bitmaps): Don't call
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 140c018..ca08fe3 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -131,8 +131,8 @@
#endif
unsigned long abort_code;
- void (*progress)(e2fsck_t ctx, int pass, unsigned long cur,
- unsigned long max);
+ int (*progress)(e2fsck_t ctx, int pass, unsigned long cur,
+ unsigned long max);
ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */
ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 966c7e9..4832f69 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -241,7 +241,8 @@
scan_struct.block_buf = block_buf;
ext2fs_set_inode_callback(scan, scan_callback, &scan_struct);
if (ctx->progress)
- (ctx->progress)(ctx, 1, 0, ctx->fs->group_desc_count);
+ if ((ctx->progress)(ctx, 1, 0, ctx->fs->group_desc_count))
+ return;
while (ino) {
pctx.ino = ino;
pctx.inode = &inode;
@@ -430,13 +431,13 @@
} else
check_blocks(ctx, &pctx, block_buf);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
if (process_inode_count >= ctx->process_inode_size) {
process_inodes(ctx, block_buf);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
}
next:
@@ -506,7 +507,9 @@
process_inodes((e2fsck_t) fs->priv_data, scan_struct->block_buf);
if (ctx->progress)
- (ctx->progress)(ctx, 1, group+1, ctx->fs->group_desc_count);
+ if ((ctx->progress)(ctx, 1, group+1,
+ ctx->fs->group_desc_count))
+ return EXT2_ET_CANCEL_REQUESTED;
return 0;
}
@@ -543,7 +546,7 @@
ehandler_operation(buf);
check_blocks(ctx, &pctx, block_buf);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
}
ctx->stashed_inode = old_stashed_inode;
@@ -668,7 +671,7 @@
pctx->errcode = ext2fs_block_iterate2(fs, ino,
pb.is_dir ? BLOCK_FLAG_HOLE : 0,
block_buf, process_block, &pb);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
end_problem_latch(ctx, PR_LATCH_BLOCK);
if (pctx->errcode)
@@ -949,7 +952,7 @@
if (blockcnt < 0) {
if (ext2fs_test_block_bitmap(ctx->block_found_map, blk)) {
bad_block_indirect(ctx, blk);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return BLOCK_ABORT;
} else
mark_block_used(ctx, blk);
@@ -1041,7 +1044,7 @@
if ((blk == p->inode->i_block[EXT2_IND_BLOCK]) ||
p->inode->i_block[EXT2_DIND_BLOCK]) {
bad_block_indirect(ctx, blk);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return BLOCK_ABORT;
return 0;
}
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 38d4424..1507a97 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -117,7 +117,7 @@
cd.pctx.errcode = ext2fs_dblist_iterate(fs->dblist, check_dir_block,
&cd);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
if (cd.pctx.errcode) {
fix_problem(ctx, PR_2_DBLIST_ITERATE, &cd.pctx);
@@ -286,7 +286,8 @@
ctx = cd->ctx;
if (ctx->progress)
- (ctx->progress)(ctx, 2, cd->count++, cd->max);
+ if ((ctx->progress)(ctx, 2, cd->count++, cd->max))
+ return DIRENT_ABORT;
/*
* Make sure the inode is still in use (could have been
@@ -452,7 +453,7 @@
dir_modified++;
goto next;
}
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return DIRENT_ABORT;
}
@@ -614,7 +615,7 @@
if (problem) {
if (fix_problem(ctx, problem, &pctx)) {
deallocate_inode(ctx, ino, 0);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return 0;
return 1;
}
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index f4ab612..00f081c 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -52,8 +52,8 @@
static ino_t lost_and_found = 0;
static int bad_lost_and_found = 0;
-static ext2fs_inode_bitmap inode_loop_detect;
-static ext2fs_inode_bitmap inode_done_map;
+static ext2fs_inode_bitmap inode_loop_detect = 0;
+static ext2fs_inode_bitmap inode_done_map = 0;
void e2fsck_pass3(e2fsck_t ctx)
{
@@ -88,7 +88,7 @@
pctx.num = 1;
fix_problem(ctx, PR_3_ALLOCATE_IBITMAP_ERROR, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
- return;
+ goto abort_exit;
}
pctx.errcode = ext2fs_allocate_inode_bitmap(fs, "inode done bitmap",
&inode_done_map);
@@ -96,7 +96,7 @@
pctx.num = 2;
fix_problem(ctx, PR_3_ALLOCATE_IBITMAP_ERROR, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
- return;
+ goto abort_exit;
}
#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME)
@@ -104,8 +104,8 @@
#endif
check_root(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
- return;
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
+ goto abort_exit;
ext2fs_mark_inode_bitmap(inode_done_map, EXT2_ROOT_INO);
@@ -114,16 +114,21 @@
for (i=0; (dir = e2fsck_dir_info_iter(ctx, &i)) != 0;) {
if (ctx->progress)
- (ctx->progress)(ctx, 3, count++, max);
+ if ((ctx->progress)(ctx, 3, count++, max))
+ goto abort_exit;
if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dir->ino))
check_directory(ctx, dir, &pctx);
}
if (ctx->progress)
- (ctx->progress)(ctx, 3, max, max);
-
+ if ((ctx->progress)(ctx, 3, max, max))
+ goto abort_exit;
+
+abort_exit:
e2fsck_free_dir_info(ctx);
- ext2fs_free_inode_bitmap(inode_loop_detect);
- ext2fs_free_inode_bitmap(inode_done_map);
+ if (inode_loop_detect)
+ ext2fs_free_inode_bitmap(inode_loop_detect);
+ if (inode_done_map)
+ ext2fs_free_inode_bitmap(inode_done_map);
#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME2)
print_resource_track("Pass 3", &rtrack);
diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c
index c45ccd9..1cb7449 100644
--- a/e2fsck/pass4.c
+++ b/e2fsck/pass4.c
@@ -103,13 +103,15 @@
group = 0;
max = fs->group_desc_count;
if (ctx->progress)
- (ctx->progress)(ctx, 4, 0, max);
+ if ((ctx->progress)(ctx, 4, 0, max))
+ return;
for (i=1; i <= fs->super->s_inodes_count; i++) {
if ((i % fs->super->s_inodes_per_group) == 0) {
group++;
if (ctx->progress)
- (ctx->progress)(ctx, 4, group, max);
+ if ((ctx->progress)(ctx, 4, group, max))
+ return;
}
if (i == EXT2_BAD_INO ||
(i > EXT2_ROOT_INO && i < EXT2_FIRST_INODE(fs->super)))
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index fd6b2c5..7561e79 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -39,28 +39,31 @@
fix_problem(ctx, PR_5_PASS_HEADER, &pctx);
if (ctx->progress)
- (ctx->progress)(ctx, 5, 0, 3);
+ if ((ctx->progress)(ctx, 5, 0, 3))
+ return;
e2fsck_read_bitmaps(ctx);
if (ctx->progress)
- (ctx->progress)(ctx, 5, 2, 3);
+ if ((ctx->progress)(ctx, 5, 2, 3))
+ return;
check_block_bitmaps(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
check_inode_bitmaps(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
check_inode_end(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
check_block_end(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
if (ctx->progress)
- (ctx->progress)(ctx, 5, 3, 3);
+ if ((ctx->progress)(ctx, 5, 3, 3))
+ return;
ext2fs_free_inode_bitmap(ctx->inode_used_map);
ctx->inode_used_map = 0;
diff --git a/e2fsck/swapfs.c b/e2fsck/swapfs.c
index 31c0d9f..605b8e3 100644
--- a/e2fsck/swapfs.c
+++ b/e2fsck/swapfs.c
@@ -160,7 +160,7 @@
ext2fs_inode_has_valid_blocks(inode)))
swap_inode_blocks(ctx, ino, block_buf, inode);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
if (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)
@@ -216,7 +216,7 @@
fs->flags |= EXT2_FLAG_SWAP_BYTES_WRITE;
}
swap_inodes(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
if (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)
fs->flags |= EXT2_FLAG_SWAP_BYTES;
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 10b3e8a..5d36a75 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -567,14 +567,14 @@
if (ctx->superblock)
set_latch_flags(PR_LATCH_RELOC, PRL_LATCHED, 0);
check_super_block(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
exit(FSCK_ERROR);
check_if_skip(ctx);
if (bad_blocks_file)
read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks);
else if (cflag)
test_disk(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
exit(FSCK_ERROR);
if (normalize_swapfs) {
@@ -587,7 +587,7 @@
}
if (swapfs) {
swap_filesys(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
exit(FSCK_ERROR);
}
@@ -616,7 +616,7 @@
}
goto restart;
}
- if (run_result & E2F_FLAG_ABORT)
+ if (run_result & E2F_FLAG_SIGNAL_MASK)
exit(FSCK_ERROR);
if (run_result & E2F_FLAG_CANCEL)
ext2fs_unmark_valid(fs);