+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
#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 */
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;
} 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:
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;
}
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;
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)
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);
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;
}
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);
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
dir_modified++;
goto next;
}
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return DIRENT_ABORT;
}
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;
}
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)
{
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);
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)
#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);
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);
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)))
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;
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)
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;
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) {
}
if (swapfs) {
swap_filesys(ctx);
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
exit(FSCK_ERROR);
}
}
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);