aboutsummaryrefslogtreecommitdiff
path: root/e2fsck
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>1998-02-24 20:22:23 +0000
committerTheodore Ts'o <tytso@mit.edu>1998-02-24 20:22:23 +0000
commita02ce9df5ff5db2982462aec7162f7142dc18131 (patch)
treea6ce1c09cdc656322360b6286109433306978879 /e2fsck
parentc775256443ff12edef2b72f47dcdcf50d1dc3526 (diff)
downloade2fsprogs-a02ce9df5ff5db2982462aec7162f7142dc18131.tar.gz
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.
Diffstat (limited to 'e2fsck')
-rw-r--r--e2fsck/ChangeLog7
-rw-r--r--e2fsck/e2fsck.h4
-rw-r--r--e2fsck/pass1.c19
-rw-r--r--e2fsck/pass2.c9
-rw-r--r--e2fsck/pass3.c27
-rw-r--r--e2fsck/pass4.c6
-rw-r--r--e2fsck/pass5.c17
-rw-r--r--e2fsck/swapfs.c4
-rw-r--r--e2fsck/unix.c8
9 files changed, 61 insertions, 40 deletions
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index a77f197b..36dc54a8 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 140c0184..ca08fe39 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -131,8 +131,8 @@ struct e2fsck_struct {
#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 966c7e97..4832f697 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -241,7 +241,8 @@ void e2fsck_pass1(e2fsck_t ctx)
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 @@ void e2fsck_pass1(e2fsck_t ctx)
} 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 @@ static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
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 @@ static void process_inodes(e2fsck_t ctx, char *block_buf)
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 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
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 @@ int process_bad_block(ext2_filsys fs,
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 @@ int process_bad_block(ext2_filsys fs,
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 38d4424a..1507a973 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -117,7 +117,7 @@ void e2fsck_pass2(e2fsck_t ctx)
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 @@ static int check_dir_block(ext2_filsys fs,
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 @@ static int check_dir_block(ext2_filsys fs,
dir_modified++;
goto next;
}
- if (ctx->flags & E2F_FLAG_ABORT)
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return DIRENT_ABORT;
}
@@ -614,7 +615,7 @@ static int process_bad_inode(e2fsck_t ctx, ino_t dir, ino_t ino)
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 f4ab6123..00f081ca 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -52,8 +52,8 @@ static errcode_t expand_directory(e2fsck_t ctx, ino_t dir);
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 @@ 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);
@@ -96,7 +96,7 @@ void e2fsck_pass3(e2fsck_t ctx)
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 @@ void e2fsck_pass3(e2fsck_t ctx)
#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 @@ void e2fsck_pass3(e2fsck_t ctx)
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 c45ccd96..1cb7449f 100644
--- a/e2fsck/pass4.c
+++ b/e2fsck/pass4.c
@@ -103,13 +103,15 @@ void e2fsck_pass4(e2fsck_t ctx)
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 fd6b2c50..7561e792 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -39,28 +39,31 @@ void e2fsck_pass5(e2fsck_t ctx)
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 31c0d9fe..605b8e3c 100644
--- a/e2fsck/swapfs.c
+++ b/e2fsck/swapfs.c
@@ -160,7 +160,7 @@ static void swap_inodes(e2fsck_t ctx)
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 @@ void swap_filesys(e2fsck_t ctx)
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 10b3e8aa..5d36a756 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -567,14 +567,14 @@ restart:
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 @@ restart:
}
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 @@ restart:
}
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);