fsck: Overwrite the backup index file if it exists.
[osl.git] / fsck.c
diff --git a/fsck.c b/fsck.c
index 246a0b6f3c5f38a881227958d7769eb12d18cc39..bc77424e30db1f7939ec6b084d707b283b0693ed 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -577,7 +577,8 @@ static int prune_objects(struct osl_table *t, uint32_t *lost_bytes)
 
        NOTICE_LOG("removing unreferenced objects from data files\n");
        /* first make a copy of the index */
-       ret = osl_open(old_idx_filename, O_WRONLY | O_CREAT | O_EXCL, 0644);
+       DEBUG_LOG("opening %s\n", old_idx_filename);
+       ret = osl_open(old_idx_filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
        if (ret < 0)
                goto out_free;
        fd = ret;
@@ -1169,7 +1170,8 @@ static int check_table(char *db_dir, char *table_name)
        ret = dump_table(conf.dump_dir_arg, &desc);
 out:
        if (ret < 0)
-               ERROR_LOG("failed to check table %s\n", table_name);
+               ERROR_LOG("failed to check table %s: %s\n", table_name,
+                       fsck_strerror(-ret));
        else
                NOTICE_LOG("successfully checked table %s\n", table_name);
        return ret;