diff options
author | Theodore Ts'o <tytso@mit.edu> | 1998-02-24 20:24:49 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 1998-02-24 20:24:49 +0000 |
commit | 3b627e8d6735fd81906117d580ee70292b2cfaaf (patch) | |
tree | 0ff2ce9099e1098d938ece7dd2a8883fc28ae5e5 /resize | |
parent | a02ce9df5ff5db2982462aec7162f7142dc18131 (diff) | |
download | e2fsprogs-3b627e8d6735fd81906117d580ee70292b2cfaaf.tar.gz |
ChangeLog, main.c, resize2fs.c, resize2fs.h:
Change the progress function to return an errcode_t; this allows the
progress function to return a error indicating a user-requested
cancel.
Diffstat (limited to 'resize')
-rw-r--r-- | resize/ChangeLog | 6 | ||||
-rw-r--r-- | resize/main.c | 7 | ||||
-rw-r--r-- | resize/resize2fs.c | 93 | ||||
-rw-r--r-- | resize/resize2fs.h | 6 |
4 files changed, 78 insertions, 34 deletions
diff --git a/resize/ChangeLog b/resize/ChangeLog index a4eabffa..a9b98033 100644 --- a/resize/ChangeLog +++ b/resize/ChangeLog @@ -1,3 +1,9 @@ +Tue Feb 24 15:22:52 1998 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * Change the progress function to return an errcode_t; this allows + the progress function to return a error indicating a + user-requested cancel. + 1998-02-20 Theodore Y. Ts'o <tytso@edt.mit.edu> * main.c (check_mount, main): Resize2fs now checks the size of the diff --git a/resize/main.c b/resize/main.c index 7e25a8a5..b2518869 100644 --- a/resize/main.c +++ b/resize/main.c @@ -28,8 +28,8 @@ static volatile void usage (char *prog) exit (1); } -static void resize_progress_func(ext2_resize_t rfs, int pass, - unsigned long cur, unsigned long max) +static errcode_t resize_progress_func(ext2_resize_t rfs, int pass, + unsigned long cur, unsigned long max) { ext2_sim_progmeter progress; const char *label; @@ -37,7 +37,7 @@ static void resize_progress_func(ext2_resize_t rfs, int pass, progress = (ext2_sim_progmeter) rfs->prog_data; if (max == 0) - return; + return 0; if (cur == 0) { if (progress) ext2fs_progress_close(progress); @@ -77,6 +77,7 @@ static void resize_progress_func(ext2_resize_t rfs, int pass, progress = 0; rfs->prog_data = 0; } + return 0; } static void check_mount(char *device_name) diff --git a/resize/resize2fs.c b/resize/resize2fs.c index 30b6c8d6..993f5346 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -63,7 +63,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs); * This is the top-level routine which does the dirty deed.... */ errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags, - void (*progress)(ext2_resize_t rfs, int pass, + errcode_t (*progress)(ext2_resize_t rfs, int pass, unsigned long cur, unsigned long max)) { @@ -327,9 +327,12 @@ retry: adj = rfs->old_fs->group_desc_count; max_group = fs->group_desc_count - adj; - if (rfs->progress) - rfs->progress(rfs, E2_RSZ_EXTEND_ITABLE_PASS, - 0, max_group); + if (rfs->progress) { + retval = rfs->progress(rfs, E2_RSZ_EXTEND_ITABLE_PASS, + 0, max_group); + if (retval) + goto errout; + } for (i = rfs->old_fs->group_desc_count; i < fs->group_desc_count; i++) { memset(&fs->group_desc[i], 0, @@ -375,10 +378,12 @@ retry: if (retval) goto errout; io_channel_flush(fs->io); - if (rfs->progress) - rfs->progress(rfs, E2_RSZ_EXTEND_ITABLE_PASS, - i - adj + 1, max_group); - + if (rfs->progress) { + retval = rfs->progress(rfs, E2_RSZ_EXTEND_ITABLE_PASS, + i - adj + 1, max_group); + if (retval) + goto errout; + } group_block += fs->super->s_blocks_per_group; } io_channel_flush(fs->io); @@ -779,9 +784,12 @@ static errcode_t block_mover(ext2_resize_t rfs) retval = ext2fs_iterate_extent(rfs->bmap, 0, 0, 0); if (retval) goto errout; - if (rfs->progress) - (rfs->progress)(rfs, E2_RSZ_BLOCK_RELOC_PASS, 0, to_move); - + if (rfs->progress) { + retval = (rfs->progress)(rfs, E2_RSZ_BLOCK_RELOC_PASS, + 0, to_move); + if (retval) + goto errout; + } while (1) { retval = ext2fs_iterate_extent(rfs->bmap, &old_blk, &new_blk, &size); if (retval) goto errout; @@ -808,8 +816,11 @@ static errcode_t block_mover(ext2_resize_t rfs) moved += c; if (rfs->progress) { io_channel_flush(fs->io); - (rfs->progress)(rfs, E2_RSZ_BLOCK_RELOC_PASS, + retval = (rfs->progress)(rfs, + E2_RSZ_BLOCK_RELOC_PASS, moved, to_move); + if (retval) + goto errout; } } while (size > 0); io_channel_flush(fs->io); @@ -880,6 +891,7 @@ static errcode_t progress_callback(ext2_filsys fs, ext2_inode_scan scan, dgrp_t group, void * priv_data) { ext2_resize_t rfs = (ext2_resize_t) priv_data; + errcode_t retval; /* * This check is to protect against old ext2 libraries. It @@ -890,8 +902,10 @@ static errcode_t progress_callback(ext2_filsys fs, ext2_inode_scan scan, if (rfs->progress) { io_channel_flush(fs->io); - (rfs->progress)(rfs, E2_RSZ_INODE_SCAN_PASS, - group+1, fs->group_desc_count); + retval = (rfs->progress)(rfs, E2_RSZ_INODE_SCAN_PASS, + group+1, fs->group_desc_count); + if (retval) + return retval; } return 0; @@ -925,10 +939,12 @@ static errcode_t inode_scan_and_fix(ext2_resize_t rfs) start_to_move = (rfs->new_fs->group_desc_count * rfs->new_fs->super->s_inodes_per_group); - if (rfs->progress) - (rfs->progress)(rfs, E2_RSZ_INODE_SCAN_PASS, - 0, rfs->old_fs->group_desc_count); - + if (rfs->progress) { + retval = (rfs->progress)(rfs, E2_RSZ_INODE_SCAN_PASS, + 0, rfs->old_fs->group_desc_count); + if (retval) + goto errout; + } ext2fs_set_inode_callback(scan, progress_callback, (void *) rfs); pb.rfs = rfs; pb.inode = &inode; @@ -1027,6 +1043,7 @@ errout: struct istruct { ext2_resize_t rfs; + errcode_t err; unsigned long max; int num; }; @@ -1036,12 +1053,15 @@ static int check_and_change_inodes(ino_t dir, int entry, int blocksize, char *buf, void *priv_data) { struct istruct *is = (struct istruct *) priv_data; - ino_t new_inode; + ino_t new_inode; if (is->rfs->progress && offset == 0) { io_channel_flush(is->rfs->old_fs->io); - (is->rfs->progress)(is->rfs, E2_RSZ_INODE_REF_UPD_PASS, - ++is->num, is->max); + is->err = (is->rfs->progress)(is->rfs, + E2_RSZ_INODE_REF_UPD_PASS, + ++is->num, is->max); + if (is->err) + return DIRENT_ABORT; } if (!dirent->inode) @@ -1078,15 +1098,26 @@ static errcode_t inode_ref_fix(ext2_resize_t rfs) is.num = 0; is.max = ext2fs_dblist_count(rfs->old_fs->dblist); is.rfs = rfs; + is.err = 0; - if (rfs->progress) - (rfs->progress)(rfs, E2_RSZ_INODE_REF_UPD_PASS, - 0, is.max); + if (rfs->progress) { + retval = (rfs->progress)(rfs, E2_RSZ_INODE_REF_UPD_PASS, + 0, is.max); + if (retval) + goto errout; + } retval = ext2fs_dblist_dir_iterate(rfs->old_fs->dblist, DIRENT_FLAG_INCLUDE_EMPTY, 0, check_and_change_inodes, &is); + if (retval) + goto errout; + if (is.err) { + retval = is.err; + goto errout; + } +errout: ext2fs_free_extent_table(rfs->imap); rfs->imap = 0; return retval; @@ -1145,8 +1176,12 @@ static errcode_t move_itables(ext2_resize_t rfs) if (to_move == 0) return 0; - if (rfs->progress) - rfs->progress(rfs, E2_RSZ_MOVE_ITABLE_PASS, 0, to_move); + if (rfs->progress) { + retval = rfs->progress(rfs, E2_RSZ_MOVE_ITABLE_PASS, + 0, to_move); + if (retval) + goto errout; + } rfs->old_fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; @@ -1209,8 +1244,10 @@ static errcode_t move_itables(ext2_resize_t rfs) ext2fs_mark_super_dirty(rfs->old_fs); if (rfs->progress) { ext2fs_flush(rfs->old_fs); - rfs->progress(rfs, E2_RSZ_MOVE_ITABLE_PASS, - ++moved, to_move); + retval = rfs->progress(rfs, E2_RSZ_MOVE_ITABLE_PASS, + ++moved, to_move); + if (retval) + goto errout; } } ext2fs_flush(fs); diff --git a/resize/resize2fs.h b/resize/resize2fs.h index 5d96353d..cc89f4f6 100644 --- a/resize/resize2fs.h +++ b/resize/resize2fs.h @@ -81,7 +81,7 @@ struct ext2_resize_struct { /* * For the progress meter */ - void (*progress)(ext2_resize_t rfs, int pass, + errcode_t (*progress)(ext2_resize_t rfs, int pass, unsigned long cur, unsigned long max); void *prog_data; @@ -99,8 +99,8 @@ struct ext2_resize_struct { /* prototypes */ extern errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags, - void (*progress)(ext2_resize_t rfs, int pass, - unsigned long cur, + errcode_t (*progress)(ext2_resize_t rfs, + int pass, unsigned long cur, unsigned long max)); /* extent.c */ |