static struct fsck_args_info conf;
-enum fsck_errors {
- E_RANGE_VIOLATION,
- E_INVALID_OBJECT,
- E_NOT_A_REGULAR_FILE,
- E_FSCK_SYNTAX,
+#define FSCK_ERRORS \
+ FSCK_ERROR(RANGE_VIOLATION, "range violation detected, very bad"), \
+ FSCK_ERROR(NOT_A_REGULAR_FILE, "not a regular file"), \
+ FSCK_ERROR(SYNTAX, "fsck syntax error"),
+
+#define FSCK_ERROR(num, txt) E_FSCK_ ## num
+enum {
+ FSCK_DUMMY = (1 << FSCK_ERROR_BIT) - 1,
+ FSCK_ERRORS
};
+#undef FSCK_ERROR
+#define FSCK_ERROR(num, txt) txt
+const char const *fsck_errors[] = {
+ FSCK_ERRORS
+};
+
+static const char *fsck_strerror(int num)
+{
+ if (num & (1 << FSCK_ERROR_BIT))
+ return fsck_errors[num & ((1 << FSCK_ERROR_BIT) - 1)];
+ return osl_strerror(num);
+}
__printf_2_3 void para_log(int ll, const char* fmt,...)
{
if (obj_start < map_start || obj_start + obj.size > map_start + col->data_map.size) {
CRIT_LOG("range violation in row %u, col %u\n", row_num,
col_num);
- return -E_RANGE_VIOLATION;
+ return -E_FSCK_RANGE_VIOLATION;
}
DEBUG_LOG("col %u: ok\n", col_num);
return 1;
continue;
ret = check_range(t, i, j);
if (ret < 0) {
- if (ret != -E_INVALID_OBJECT &&
- ret != -E_RANGE_VIOLATION)
+ if (ret != -E_OSL_INVALID_OBJECT &&
+ ret != -E_FSCK_RANGE_VIOLATION)
goto err;
- if (ret == -E_INVALID_OBJECT) {
+ if (ret == -E_OSL_INVALID_OBJECT) {
CRIT_LOG("row %d, col %d maps to an "
"invalid object\n", i, j);
}
loss[i] -= obj.size + 1; /* add one for header byte */
continue;
}
- if (ret != -E_INVALID_OBJECT)
+ if (ret != -E_OSL_INVALID_OBJECT)
goto err;
CRIT_LOG("row %d, col %d points to an invalid "
"mapped object, bad\n", j, i);
ret = osl_rename(new_col_filenames[i], col_filenames[i]);
if (ret < 0) { /* we're kinda screwed here */
CRIT_LOG("rename of col %i failed: %s\n", i,
- strerror(errno));
+ osl_strerror(errno));
goto out_free;
}
}
free(path);
if (ret < 0)
return ret;
- ret = -E_NOT_A_REGULAR_FILE;
+ ret = -E_FSCK_NOT_A_REGULAR_FILE;
if (!(S_IFREG & statbuf.st_mode))
return ret;
return 1;
}
out:
if (ret < 0) {
- /* FIXME: osl_strerror() is BAD!!! */
ERROR_LOG("%s%s: %s\n",
base_dir? "base_dir: " : "",
base_dir? base_dir : "",
- osl_strerror(-ret)
+ fsck_strerror(-ret)
);
if (conf.loglevel_arg > 1)
EMERG_LOG("re-run with \"--loglevel %d\" to increase verbosity\n",