#include "log.h"
#include "osl.h"
-#include "error.h"
#include "util.h"
#include "osl_core.h"
#include "fsck.cmdline.h"
FSCK_ERROR(CHDIR, "could not change directory"), \
FSCK_ERROR(OPENDIR, "could not open directory"),
+#define FSCK_ERROR_BIT 29
#define FSCK_ERROR(num, txt) E_FSCK_ ## num
enum {
FSCK_DUMMY = (1 << FSCK_ERROR_BIT) - 1,
return write_all(fd, buf, &len);
}
-/**
- * Paraslash's version of malloc().
+/*
+ * Wrapper for malloc().
*
* \param size The desired new size.
*
}
/**
- * Paraslash's version of calloc().
+ * Allocate memory and fill with zeros.
*
* \param size The desired new size.
*
}
/**
- * Paraslash's version of strdup().
+ * Save version of strdup().
*
* \param s The string to be duplicated.
*
ret = get_mapped_object(t, col_num, i, &obj);
if (ret < 0)
return ret;
- ret = _write_all(fd, (char *)(obj.data) - 1, obj.size + 1);
+ ret = _write_all(fd, (char *)(obj.data), obj.size);
if (ret < 0)
return ret;
- written += obj.size + 1;
+ written += obj.size;
ret = get_row_index(t, i, &index_entry);
if (ret < 0)
return ret;
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;
current_dir = make_message("%s/rows_%u-%u", dump_dir, i, i + 999);
NOTICE_LOG("dumping rows %u - %u\n", i, i + 999);
ret = osl_mkdir(current_dir, 0777);
- if (ret < 0 && !is_errno(-ret, EEXIST))
+ if (ret < 0 && ret != -E_OSL_DIR_EXISTS)
goto out;
}
row_dir = make_message("%s/row_%03u", current_dir, i);
ret = osl_mkdir(row_dir, 0777);
- if (ret < 0 && !is_errno(-ret, EEXIST)) {
+ if (ret < 0 && ret != -E_OSL_DIR_EXISTS) {
free(row_dir);
goto out;
}
if (ret < 0)
goto out;
ret = osl_mkdir(dump_dir, 0777);
- if (ret < 0 && !is_errno(-ret, EEXIST))
+ if (ret < 0 && ret != -E_OSL_DIR_EXISTS)
goto out;
table_dump_dir = make_message("%s/%s", dump_dir, desc->name);
ret = osl_mkdir(table_dump_dir, 0777);
- if (ret < 0 && !is_errno(-ret, EEXIST))
+ if (ret < 0 && ret != -E_OSL_DIR_EXISTS)
goto out;
desc_file = make_message("%s/table_description.c", table_dump_dir);
ret = osl_open(desc_file, O_WRONLY | O_CREAT | O_EXCL, 0644);
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;