aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2016-06-06 17:08:09 -0400
committerJeff Mahoney <jeffm@suse.com>2017-07-25 09:19:09 -0400
commit958ad8d8d16a152a2e83ee0b90e6a03ab73c3098 (patch)
tree2faeb99875bf8a0941ed6d5da7969a61d573ac67
parentb6d5dcb604699d27f4749f87c4dfc1367b886d96 (diff)
downloadreiserfsprogs-958ad8d8d16a152a2e83ee0b90e6a03ab73c3098.tar.gz
reiserfscore: reiserfs_flush_to_ondisk_bitmap shouldn't exit
Now that libreiserfscore is a shared library, consumers expect that it won't call exit() by itself anymore. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
-rw-r--r--fsck/check_tree.c4
-rw-r--r--fsck/lost+found.c5
-rw-r--r--fsck/pass1.c4
-rw-r--r--fsck/pass2.c5
-rw-r--r--fsck/pass4.c5
-rw-r--r--fsck/semantic_rebuild.c6
-rw-r--r--reiserfscore/bitmap.c17
7 files changed, 34 insertions, 12 deletions
diff --git a/fsck/check_tree.c b/fsck/check_tree.c
index ffe7cdc..af38987 100644
--- a/fsck/check_tree.c
+++ b/fsck/check_tree.c
@@ -1146,7 +1146,9 @@ static void before_check_fs_tree(reiserfs_filsys_t fs)
static void after_check_fs_tree(reiserfs_filsys_t fs)
{
if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
- reiserfs_flush_to_ondisk_bitmap(fs->fs_bitmap2, fs);
+ int ret = reiserfs_flush_to_ondisk_bitmap(fs->fs_bitmap2, fs);
+ if (ret < 0)
+ reiserfs_exit(1, "Exiting after unrecoverable error.");
reiserfs_flush(fs);
fs->fs_dirt = 1;
reiserfs_bitmap_delta(source_bitmap, control_bitmap);
diff --git a/fsck/lost+found.c b/fsck/lost+found.c
index da1f489..1c7867e 100644
--- a/fsck/lost+found.c
+++ b/fsck/lost+found.c
@@ -332,6 +332,7 @@ void load_lost_found_result(reiserfs_filsys_t fs)
static void after_lost_found(reiserfs_filsys_t fs)
{
+ int ret;
/* update super block: objectid map, fsck state */
set_sb_fs_state(fs->fs_ondisk_sb, LOST_FOUND_DONE);
mark_buffer_dirty(fs->fs_super_bh);
@@ -340,7 +341,9 @@ static void after_lost_found(reiserfs_filsys_t fs)
fsck_progress("Flushing..");
id_map_flush(proper_id_map(fs), fs);
fs->fs_dirt = 1;
- reiserfs_flush_to_ondisk_bitmap(fsck_new_bitmap(fs), fs);
+ ret = reiserfs_flush_to_ondisk_bitmap(fsck_new_bitmap(fs), fs);
+ if (ret < 0)
+ reiserfs_exit(1, "Exiting after unrecoverable error.");
reiserfs_flush(fs);
fsck_progress("finished\n");
diff --git a/fsck/pass1.c b/fsck/pass1.c
index 17dcbf7..39b4270 100644
--- a/fsck/pass1.c
+++ b/fsck/pass1.c
@@ -617,7 +617,9 @@ static void save_pass_1_result(reiserfs_filsys_t fs)
/* to be able to get a new bitmap on pass2 we should flush it on disk
new_bitmap should not be flushed on disk if run without -d option, as
if fsck fails on pass1 we get wrong bitmap on the next fsck start */
- reiserfs_flush_to_ondisk_bitmap(fsck_new_bitmap(fs), fs);
+ retval = reiserfs_flush_to_ondisk_bitmap(fsck_new_bitmap(fs), fs);
+ if (retval < 0)
+ reiserfs_exit(1, "Exiting after unrecoverable error.");
/* to be able to restart with pass 2 we need bitmap of
uninsertable blocks and bitmap of alocable blocks */
diff --git a/fsck/pass2.c b/fsck/pass2.c
index 60bccce..932d73b 100644
--- a/fsck/pass2.c
+++ b/fsck/pass2.c
@@ -555,6 +555,7 @@ cont:
static void after_pass_2(reiserfs_filsys_t fs)
{
time_t t;
+ int ret;
/* we can now flush new_bitmap on disk as tree is built and
contains all data, which were found on dik at start in
@@ -584,7 +585,9 @@ static void after_pass_2(reiserfs_filsys_t fs)
fsck_progress("Flushing..");
id_map_flush(proper_id_map(fs), fs);
fs->fs_dirt = 1;
- reiserfs_flush_to_ondisk_bitmap(fs->fs_bitmap2, fs);
+ ret = reiserfs_flush_to_ondisk_bitmap(fs->fs_bitmap2, fs);
+ if (ret < 0)
+ reiserfs_exit(1, "Exiting after unrecoverable error.");
reiserfs_flush(fs);
fsck_progress("finished\n");
diff --git a/fsck/pass4.c b/fsck/pass4.c
index 8a6cf5a..d183675 100644
--- a/fsck/pass4.c
+++ b/fsck/pass4.c
@@ -14,6 +14,7 @@ void pass_4_check_unaccessed_items(void)
struct item_head *ih;
unsigned long items;
const struct reiserfs_key *rdkey;
+ int ret;
path.path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
key = root_dir_key;
@@ -83,7 +84,9 @@ cont:
fsck_progress("Flushing..");
fs->fs_dirt = 1;
id_map_flush(proper_id_map(fs), fs);
- reiserfs_flush_to_ondisk_bitmap(fs->fs_bitmap2, fs);
+ ret = reiserfs_flush_to_ondisk_bitmap(fs->fs_bitmap2, fs);
+ if (ret < 0)
+ reiserfs_exit(1, "Exiting after unrecoverable error.");
reiserfs_flush(fs);
fsck_progress("finished\n");
diff --git a/fsck/semantic_rebuild.c b/fsck/semantic_rebuild.c
index 3cc00bb..6707a5e 100644
--- a/fsck/semantic_rebuild.c
+++ b/fsck/semantic_rebuild.c
@@ -1282,6 +1282,7 @@ static void before_pass_3(reiserfs_filsys_t fs)
static void after_pass_3(reiserfs_filsys_t fs)
{
+ int ret;
/* update super block: objectid map, fsck state */
set_sb_fs_state(fs->fs_ondisk_sb, SEMANTIC_DONE);
mark_buffer_dirty(fs->fs_super_bh);
@@ -1290,7 +1291,10 @@ static void after_pass_3(reiserfs_filsys_t fs)
fsck_progress("Flushing..");
id_map_flush(proper_id_map(fs), fs);
fs->fs_dirt = 1;
- reiserfs_flush_to_ondisk_bitmap(fsck_new_bitmap(fs), fs);
+ ret = reiserfs_flush_to_ondisk_bitmap(fsck_new_bitmap(fs), fs);
+ if (ret < 0)
+ reiserfs_exit(1, "Exiting after unrecoverable error.");
+
reiserfs_flush(fs);
fsck_progress("finished\n");
diff --git a/reiserfscore/bitmap.c b/reiserfscore/bitmap.c
index 46b90c9..1a2a065 100644
--- a/reiserfscore/bitmap.c
+++ b/reiserfscore/bitmap.c
@@ -260,9 +260,9 @@ static int reiserfs_fetch_ondisk_bitmap(reiserfs_bitmap_t *bm,
bh = getblk(fs->fs_dev, block, fs->fs_blocksize);
if (!bh) {
- reiserfs_exit(1,
- "reiserfs_fetch_ondisk_bitmap: "
- "getblk failed");
+ reiserfs_warning(stderr, "%s: getblk failed",
+ __func__);
+ return -1;
}
memset(bh->b_data, 0xff, bh->b_size);
@@ -316,7 +316,7 @@ static int reiserfs_fetch_ondisk_bitmap(reiserfs_bitmap_t *bm,
}
/* copy bitmap 'bm' to buffers which hold on-disk bitmap if bitmap was ever
- changed and return 1. Otherwise - return 0 */
+ changed and return 1. Otherwise - return 0. Returns -1 on error. */
int reiserfs_flush_to_ondisk_bitmap(reiserfs_bitmap_t *bm,
reiserfs_filsys_t fs)
{
@@ -354,7 +354,9 @@ int reiserfs_flush_to_ondisk_bitmap(reiserfs_bitmap_t *bm,
/* we bread to make sure that filesystem contains enough blocks */
bh = getblk(fs->fs_dev, block, fs->fs_blocksize);
if (!bh) {
- reiserfs_exit(1, "Getblk failed for (%lu)\n", block);
+ reiserfs_warning(stderr, "Getblk failed for (%lu)\n",
+ block);
+ return -1;
}
memset(bh->b_data, 0xff, bh->b_size);
@@ -746,8 +748,11 @@ int reiserfs_create_ondisk_bitmap(reiserfs_filsys_t fs)
void reiserfs_close_ondisk_bitmap(reiserfs_filsys_t fs)
{
+ int ret;
if (!fs->fs_bitmap2)
return;
- reiserfs_flush_to_ondisk_bitmap(fs->fs_bitmap2, fs);
+ ret = reiserfs_flush_to_ondisk_bitmap(fs->fs_bitmap2, fs);
+ if (ret < 0)
+ reiserfs_exit(1, "Exiting after unrecoverable error.");
reiserfs_free_ondisk_bitmap(fs);
}