Put a clear separation between log and msg functions

This commit is contained in:
Andrea Mazzoleni 2015-04-20 22:07:42 +02:00
parent 966abd6f16
commit de0c437bd2
27 changed files with 1158 additions and 1131 deletions

View file

@ -112,7 +112,7 @@ static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned d
) {
/* if a hash doesn't match, fail the check */
if (blockcmp(state, rehash, failed[failed_map[j]].block, buffer[failed[failed_map[j]].index], buffer_zero) != 0) {
msg_tag("hash_error: Hash mismatch on entry %u\n", failed_map[j]);
log_tag("hash_error: Hash mismatch on entry %u\n", failed_map[j]);
return 0;
}
@ -223,13 +223,13 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
return 0;
/* log */
msg_tag("parity_error:%u:", pos);
log_tag("parity_error:%u:", pos);
for (i = 0; i < r; ++i) {
if (i != 0)
msg_tag("/");
msg_tag("%s", lev_config_name(ip[i]));
log_tag("/");
log_tag("%s", lev_config_name(ip[i]));
}
msg_tag(":parity: Parity mismatch\n");
log_tag(":parity: Parity mismatch\n");
++error;
} while (combination_next(r, n, ip));
}
@ -263,13 +263,13 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
return 0;
/* log */
msg_tag("parity_error:%u:", pos);
log_tag("parity_error:%u:", pos);
for (i = 0; i < r; ++i) {
if (i != 0)
msg_tag("/");
msg_tag("%s", lev_config_name(ip[i]));
log_tag("/");
log_tag("%s", lev_config_name(ip[i]));
}
msg_tag(":hash: Hash mismatch\n");
log_tag(":hash: Hash mismatch\n");
++error;
} while (combination_next(r, n, ip));
}
@ -278,7 +278,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
if (error)
return error;
msg_tag("strategy_error:%u: No strategy to recover from %u failures with %u parity %s hash\n",
log_tag("strategy_error:%u: No strategy to recover from %u failures with %u parity %s hash\n",
pos, failed_count, n, has_hash ? "with" : "without");
return -1;
}
@ -338,9 +338,9 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
disk = handle->disk->name;
sub = block_file_get(block)->sub;
msg_tag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, state, hash, data, disk, esc(sub), block_file_pos(block));
log_tag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, state, hash, data, disk, esc(sub), block_file_pos(block));
} else {
msg_tag("entry:%u:%s:%s:%s:\n", j, state, hash, data);
log_tag("entry:%u:%s:%s:%s:\n", j, state, hash, data);
}
}
@ -375,7 +375,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
|| state_search_fetch(state, rehash, failed[j].block, buffer[failed[j].index]) == 0)
) {
/* we already have corrected it! */
msg_tag("hash_import: Fixed entry %u\n", j);
log_tag("hash_import: Fixed entry %u\n", j);
} else {
/* otherwise try to recover it */
failed_map[n] = j;
@ -389,7 +389,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* if nothing to fix */
if (!something_to_recover) {
msg_tag("recover_sync:%u:%u: Skipped for already recovered\n", pos, n);
log_tag("recover_sync:%u:%u: Skipped for already recovered\n", pos, n);
/* recompute only the parity */
raid_gen(diskmax, state->level, state->block_size, buffer);
@ -423,7 +423,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* it may contain garbage */
failed[j].is_outofdate = 1;
msg_tag("hash_unknown: Unknown hash on entry %u\n", j);
log_tag("hash_unknown: Unknown hash on entry %u\n", j);
} else if (hash_is_zero(failed[j].block->hash)) {
/* if the block is not filled with 0, we are sure to have */
/* restored it to the state after the 'sync' */
@ -434,7 +434,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* it may contain garbage */
failed[j].is_outofdate = 1;
msg_tag("hash_unknown: Maybe old zero on entry %u\n", j);
log_tag("hash_unknown: Maybe old zero on entry %u\n", j);
}
} else {
/* if the hash is different than the previous one, we are sure to have */
@ -446,7 +446,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* it may contain garbage */
failed[j].is_outofdate = 1;
msg_tag("hash_unknown: Maybe old data on entry %u\n", j);
log_tag("hash_unknown: Maybe old data on entry %u\n", j);
}
}
}
@ -458,9 +458,9 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
error += ret;
if (ret < 0)
msg_tag("recover_sync:%u:%u: Failed with no attempts\n", pos, n);
log_tag("recover_sync:%u:%u: Failed with no attempts\n", pos, n);
else
msg_tag("recover_sync:%u:%u: Failed with %d attempts\n", pos, n, ret);
log_tag("recover_sync:%u:%u: Failed with %d attempts\n", pos, n, ret);
/* Now assume that the parity IS NOT updated at the current state, */
/* but still represent the state before the last 'sync' process. */
@ -556,7 +556,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* and we don't want to write it to the disk */
failed[j].is_outofdate = 1;
msg_tag("hash_unknown: Surely old data on entry %u\n", j);
log_tag("hash_unknown: Surely old data on entry %u\n", j);
}
}
}
@ -567,11 +567,11 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
error += ret;
if (ret < 0)
msg_tag("recover_unsync:%u:%u: Failed with no attempts\n", pos, n);
log_tag("recover_unsync:%u:%u: Failed with no attempts\n", pos, n);
else
msg_tag("recover_unsync:%u:%u: Failed with %d attempts\n", pos, n, ret);
log_tag("recover_unsync:%u:%u: Failed with %d attempts\n", pos, n, ret);
} else {
msg_tag("recover_unsync:%u:%u: Skipped for%s%s\n", pos, n,
log_tag("recover_unsync:%u:%u: Skipped for%s%s\n", pos, n,
!something_to_recover ? " nothing to recover" : "",
!something_unsynced ? " nothing unsynched" : ""
);
@ -636,7 +636,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
/* or at least pointing to NULL, in case it cannot be opened. */
if (handle[j].file != 0 && handle[j].file != file) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in opened file for block %u\n", block->parity_pos);
log_fatal("Internal inconsistency in opened file for block %u\n", block->parity_pos);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -658,8 +658,8 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
ret = handle_close(&handle[j]);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing '%s'. %s.\n", path, strerror(errno));
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Error closing '%s'. %s.\n", path, strerror(errno));
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
return -1;
/* LCOV_EXCL_STOP */
}
@ -667,13 +667,13 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
ret = rename(path, path_to);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error renaming '%s' to '%s'. %s.\n", path, path_to, strerror(errno));
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Error renaming '%s' to '%s'. %s.\n", path, path_to, strerror(errno));
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
return -1;
/* LCOV_EXCL_STOP */
}
msg_tag("status:unrecoverable:%s:%s\n", disk->name, esc(file->sub));
log_tag("status:unrecoverable:%s:%s\n", disk->name, esc(file->sub));
msg_info("unrecoverable %s\n", path);
/* and do not set the time if damaged */
@ -686,7 +686,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
goto close_and_continue;
}
msg_tag("status:recovered:%s:%s\n", disk->name, esc(file->sub));
log_tag("status:recovered:%s:%s\n", disk->name, esc(file->sub));
msg_info("recovered %s\n", path);
inode = handle[j].st.st_ino;
@ -714,29 +714,29 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
/* LCOV_EXCL_START */
/* mark the file as damaged */
file_flag_set(file, FILE_IS_DAMAGED);
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
return -1;
/* LCOV_EXCL_STOP */
}
} else {
msg_tag("collision:%s:%s:%s: Not setting modification time to avoid inode collision\n", disk->name, esc(file->sub), esc(collide_file->sub));
log_tag("collision:%s:%s:%s: Not setting modification time to avoid inode collision\n", disk->name, esc(file->sub), esc(collide_file->sub));
}
} else {
/* we are not fixing, but only checking */
/* print just the final status */
if (file_flag_has(file, FILE_IS_DAMAGED)) {
if (state->opt.auditonly) {
msg_tag("status:damaged:%s:%s\n", disk->name, esc(file->sub));
log_tag("status:damaged:%s:%s\n", disk->name, esc(file->sub));
msg_info("damaged %s\n", path);
} else {
msg_tag("status:unrecoverable:%s:%s\n", disk->name, esc(file->sub));
log_tag("status:unrecoverable:%s:%s\n", disk->name, esc(file->sub));
msg_info("unrecoverable %s\n", path);
}
} else if (file_flag_has(file, FILE_IS_FIXED)) {
msg_tag("status:recoverable:%s:%s\n", disk->name, esc(file->sub));
log_tag("status:recoverable:%s:%s\n", disk->name, esc(file->sub));
msg_info("recoverable %s\n", path);
} else {
msg_tag("status:correct:%s:%s\n", disk->name, esc(file->sub));
log_tag("status:correct:%s:%s\n", disk->name, esc(file->sub));
/* we don't use msg_verbose() because it also goes into the log */
if (msg_level >= MSG_VERBOSE)
msg_info("correct %s\n", path);
@ -752,8 +752,8 @@ close_and_continue:
ret = handle_close(&handle[j]);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing '%s'. %s.\n", path, strerror(errno));
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Error closing '%s'. %s.\n", path, strerror(errno));
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
return -1;
/* LCOV_EXCL_STOP */
}
@ -872,7 +872,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* post process the files */
ret = file_post(state, fix, i, handle, diskmax);
if (ret == -1) {
msg_error("Stopping at block %u\n", i);
log_fatal("Stopping at block %u\n", i);
++unrecoverable_error;
goto bail;
}
@ -967,8 +967,8 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("DANGER! Unexpected close error in a data disk, it isn't possible to check.\n");
msg_error("Stopping at block %u\n", i);
log_fatal("DANGER! Unexpected close error in a data disk, it isn't possible to check.\n");
log_fatal("Stopping at block %u\n", i);
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -981,11 +981,11 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
if (ret == -1) {
/* LCOV_EXCL_START */
if (errno == EACCES) {
msg_error("WARNING! Please give write permission to the file.\n");
log_fatal("WARNING! Please give write permission to the file.\n");
} else {
msg_error("DANGER! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("DANGER! Without a working data disk, it isn't possible to fix errors on it.\n");
}
msg_error("Stopping at block %u\n", i);
log_fatal("Stopping at block %u\n", i);
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1000,7 +1000,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
} else {
/* otherwise, open the file only for reading */
ret = handle_open(&handle[j], file, state->file_mode,
msg_warning, state->opt.expected_missing ? msg_expected : 0);
log_error, state->opt.expected_missing ? log_expected : 0);
if (ret == -1) {
/* save the failed block for the check/fix */
failed[failed_count].is_bad = 1;
@ -1010,7 +1010,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
failed[failed_count].handle = &handle[j];
++failed_count;
msg_tag("error:%u:%s:%s: Open error at position %u\n", i, disk->name, esc(file->sub), block_file_pos(block));
log_tag("error:%u:%s:%s: Open error at position %u\n", i, disk->name, esc(file->sub), block_file_pos(block));
++error;
continue;
}
@ -1037,22 +1037,22 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
&& !(state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED))
&& handle[j].st.st_size > file->size
) {
msg_warning("File '%s' is larger than expected.\n", handle[j].path);
msg_tag("error:%u:%s:%s: Size error\n", i, disk->name, esc(file->sub));
log_error("File '%s' is larger than expected.\n", handle[j].path);
log_tag("error:%u:%s:%s: Size error\n", i, disk->name, esc(file->sub));
++error;
if (fix) {
ret = handle_truncate(&handle[j], file);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("DANGER! Unexpected truncate error in a data disk, it isn't possible to fix.\n");
msg_error("Stopping at block %u\n", i);
log_fatal("DANGER! Unexpected truncate error in a data disk, it isn't possible to fix.\n");
log_fatal("Stopping at block %u\n", i);
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_tag("fixed:%u:%s:%s: Fixed size\n", i, disk->name, esc(file->sub));
log_tag("fixed:%u:%s:%s: Fixed size\n", i, disk->name, esc(file->sub));
++recovered_error;
}
}
@ -1065,7 +1065,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* read from the file */
read_size = handle_read(&handle[j], block, buffer[j], state->block_size,
msg_warning, state->opt.expected_missing ? msg_expected : 0);
log_error, state->opt.expected_missing ? log_expected : 0);
if (read_size == -1) {
/* save the failed block for the check/fix */
failed[failed_count].is_bad = 1; /* it's bad because we cannot read it */
@ -1075,7 +1075,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
failed[failed_count].handle = &handle[j];
++failed_count;
msg_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc(file->sub), block_file_pos(block));
log_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc(file->sub), block_file_pos(block));
++error;
continue;
}
@ -1116,7 +1116,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
failed[failed_count].handle = &handle[j];
++failed_count;
msg_tag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, esc(file->sub), block_file_pos(block));
log_tag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, esc(file->sub), block_file_pos(block));
++error;
continue;
}
@ -1152,11 +1152,11 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* read the parity */
for (l = 0; l < state->level; ++l) {
if (parity[l]) {
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, msg_warning);
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, log_error);
if (ret == -1) {
buffer_recov[l] = 0; /* no parity to use */
msg_tag("parity_error:%u:%s: Read error\n", i, lev_config_name(l));
log_tag("parity_error:%u:%s: Read error\n", i, lev_config_name(l));
++error;
}
} else {
@ -1175,7 +1175,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* print a list of all the errors in files */
for (j = 0; j < failed_count; ++j) {
if (failed[j].is_bad)
msg_tag("unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].handle->disk->name, esc(block_file_get(failed[j].block)->sub), block_file_pos(failed[j].block));
log_tag("unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].handle->disk->name, esc(block_file_get(failed[j].block)->sub), block_file_pos(failed[j].block));
}
/* keep track of damaged files */
@ -1193,7 +1193,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
for (j = 0; j < failed_count; ++j) {
if (failed[j].is_bad && failed[j].is_outofdate) {
++partial_recover_error;
msg_tag("unrecoverable:%u:%s:%s: Unrecoverable unsynced error at position %u\n", i, failed[j].handle->disk->name, esc(block_file_get(failed[j].block)->sub), block_file_pos(failed[j].block));
log_tag("unrecoverable:%u:%s:%s: Unrecoverable unsynced error at position %u\n", i, failed[j].handle->disk->name, esc(block_file_get(failed[j].block)->sub), block_file_pos(failed[j].block));
}
}
if (partial_recover_error != 0) {
@ -1210,7 +1210,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
if (buffer_recov[l] != 0 && memcmp(buffer_recov[l], buffer[diskmax + l], state->block_size) != 0) {
buffer_recov[l] = 0;
msg_tag("parity_error:%u:%s: Data error\n", i, lev_config_name(l));
log_tag("parity_error:%u:%s: Data error\n", i, lev_config_name(l));
++error;
}
}
@ -1236,12 +1236,12 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
file_flag_set(block_file_get(failed[j].block), FILE_IS_DAMAGED);
if (errno == EACCES) {
msg_error("WARNING! Please give write permission to the file.\n");
log_fatal("WARNING! Please give write permission to the file.\n");
} else {
/* we do not use DANGER because it could be ENOSPC which is not always correctly reported */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
}
msg_error("Stopping at block %u\n", i);
log_fatal("Stopping at block %u\n", i);
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1258,7 +1258,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* note that it could be also marked as damaged in other iterations */
file_flag_set(block_file_get(failed[j].block), FILE_IS_FIXED);
msg_tag("fixed:%u:%s:%s: Fixed data error at position %u\n", i, failed[j].handle->disk->name, esc(block_file_get(failed[j].block)->sub), block_file_pos(failed[j].block));
log_tag("fixed:%u:%s:%s: Fixed data error at position %u\n", i, failed[j].handle->disk->name, esc(block_file_get(failed[j].block)->sub), block_file_pos(failed[j].block));
++recovered_error;
}
@ -1273,14 +1273,14 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
if (ret == -1) {
/* LCOV_EXCL_START */
/* we do not use DANGER because it could be ENOSPC which is not always correctly reported */
msg_error("WARNING! Without a working %s disk, it isn't possible to fix errors on it.\n", lev_name(l));
msg_error("Stopping at block %u\n", i);
log_fatal("WARNING! Without a working %s disk, it isn't possible to fix errors on it.\n", lev_name(l));
log_fatal("Stopping at block %u\n", i);
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_tag("parity_fixed:%u:%s: Fixed data error\n", i, lev_config_name(l));
log_tag("parity_fixed:%u:%s: Fixed data error\n", i, lev_config_name(l));
++recovered_error;
}
}
@ -1308,7 +1308,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* post process the files */
ret = file_post(state, fix, i, handle, diskmax);
if (ret == -1) {
msg_error("Stopping at block %u\n", i);
log_fatal("Stopping at block %u\n", i);
++unrecoverable_error;
goto bail;
}
@ -1360,18 +1360,18 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
if (ret == -1) {
unsuccesful = 1;
msg_warning("Error stating empty file '%s'. %s.\n", path, strerror(errno));
msg_tag("error:%s:%s: Empty file stat error\n", disk->name, esc(file->sub));
log_error("Error stating empty file '%s'. %s.\n", path, strerror(errno));
log_tag("error:%s:%s: Empty file stat error\n", disk->name, esc(file->sub));
++error;
} else if (!S_ISREG(st.st_mode)) {
unsuccesful = 1;
msg_tag("error:%s:%s: Empty file error for not regular file\n", disk->name, esc(file->sub));
log_tag("error:%s:%s: Empty file error for not regular file\n", disk->name, esc(file->sub));
++error;
} else if (st.st_size != 0) {
unsuccesful = 1;
msg_tag("error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, esc(file->sub), st.st_size);
log_tag("error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, esc(file->sub), st.st_size);
++error;
}
@ -1382,8 +1382,8 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
ret = mkancestor(path);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
msg_error("Stopping\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1394,14 +1394,14 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
f = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NOFOLLOW, 0600);
if (f == -1) {
/* LCOV_EXCL_START */
msg_error("Error creating empty file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error creating empty file '%s'. %s.\n", path, strerror(errno));
if (errno == EACCES) {
msg_error("WARNING! Please give write permission to the file.\n");
log_fatal("WARNING! Please give write permission to the file.\n");
} else {
/* we do not use DANGER because it could be ENOSPC which is not always correctly reported */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
}
msg_error("Stopping\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1413,9 +1413,9 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* LCOV_EXCL_START */
close(f);
msg_error("Error timing file '%s'. %s.\n", file->sub, strerror(errno));
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
msg_error("Stopping\n");
log_fatal("Error timing file '%s'. %s.\n", file->sub, strerror(errno));
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1425,17 +1425,17 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
ret = close(f);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
msg_error("Stopping\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_tag("fixed:%s:%s: Fixed empty file\n", disk->name, esc(file->sub));
log_tag("fixed:%s:%s: Fixed empty file\n", disk->name, esc(file->sub));
++recovered_error;
msg_tag("status:recovered:%s:%s\n", disk->name, esc(file->sub));
log_tag("status:recovered:%s:%s\n", disk->name, esc(file->sub));
msg_info("recovered %s%s\n", disk->dir, file->sub);
}
}
@ -1468,13 +1468,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
if (ret == -1) {
unsuccesful = 1;
msg_warning("Error stating hardlink '%s'. %s.\n", path, strerror(errno));
msg_tag("hardlinkerror:%s:%s:%s: Hardlink stat error\n", disk->name, esc(link->sub), esc(link->linkto));
log_error("Error stating hardlink '%s'. %s.\n", path, strerror(errno));
log_tag("hardlinkerror:%s:%s:%s: Hardlink stat error\n", disk->name, esc(link->sub), esc(link->linkto));
++error;
} else if (!S_ISREG(st.st_mode)) {
unsuccesful = 1;
msg_tag("hardlinkerror:%s:%s:%s: Hardlink error for not regular file\n", disk->name, esc(link->sub), esc(link->linkto));
log_tag("hardlinkerror:%s:%s:%s: Hardlink error for not regular file\n", disk->name, esc(link->sub), esc(link->linkto));
++error;
}
@ -1498,19 +1498,19 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
}
}
msg_warning("Error stating hardlink-to '%s'. %s.\n", pathto, strerror(errno));
msg_tag("hardlinkerror:%s:%s:%s: Hardlink to stat error\n", disk->name, esc(link->sub), esc(link->linkto));
log_error("Error stating hardlink-to '%s'. %s.\n", pathto, strerror(errno));
log_tag("hardlinkerror:%s:%s:%s: Hardlink to stat error\n", disk->name, esc(link->sub), esc(link->linkto));
++error;
} else if (!S_ISREG(stto.st_mode)) {
unsuccesful = 1;
msg_tag("hardlinkerror:%s:%s:%s: Hardlink-to error for not regular file\n", disk->name, esc(link->sub), esc(link->linkto));
log_tag("hardlinkerror:%s:%s:%s: Hardlink-to error for not regular file\n", disk->name, esc(link->sub), esc(link->linkto));
++error;
} else if (!unsuccesful && st.st_ino != stto.st_ino) {
unsuccesful = 1;
msg_warning("Mismatch hardlink '%s' and '%s'. Different inode.\n", path, pathto);
msg_tag("hardlinkerror:%s:%s:%s: Hardlink mismatch for different inode\n", disk->name, esc(link->sub), esc(link->linkto));
log_error("Mismatch hardlink '%s' and '%s'. Different inode.\n", path, pathto);
log_tag("hardlinkerror:%s:%s:%s: Hardlink mismatch for different inode\n", disk->name, esc(link->sub), esc(link->linkto));
++error;
}
} else {
@ -1520,14 +1520,14 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
if (ret < 0) {
unsuccesful = 1;
msg_warning("Error reading symlink '%s'. %s.\n", path, strerror(errno));
msg_tag("symlinkerror:%s:%s: Symlink read error\n", disk->name, esc(link->sub));
log_error("Error reading symlink '%s'. %s.\n", path, strerror(errno));
log_tag("symlinkerror:%s:%s: Symlink read error\n", disk->name, esc(link->sub));
++error;
} else if (ret >= PATH_MAX) {
unsuccesful = 1;
msg_warning("Error reading symlink '%s'. Symlink too long.\n", path);
msg_tag("symlinkerror:%s:%s: Symlink read error\n", disk->name, esc(link->sub));
log_error("Error reading symlink '%s'. Symlink too long.\n", path);
log_tag("symlinkerror:%s:%s: Symlink read error\n", disk->name, esc(link->sub));
++error;
} else {
linkto[ret] = 0;
@ -1535,7 +1535,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
if (strcmp(linkto, link->linkto) != 0) {
unsuccesful = 1;
msg_tag("symlinkerror:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, esc(link->sub), linkto, link->linkto);
log_tag("symlinkerror:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, esc(link->sub), linkto, link->linkto);
++error;
}
}
@ -1546,8 +1546,8 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
ret = mkancestor(path);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
msg_error("Stopping\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1557,9 +1557,9 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
ret = remove(path);
if (ret != 0 && errno != ENOENT) {
/* LCOV_EXCL_START */
msg_error("Error removing '%s'. %s.\n", path, strerror(errno));
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
msg_error("Stopping\n");
log_fatal("Error removing '%s'. %s.\n", path, strerror(errno));
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1570,43 +1570,43 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
ret = hardlink(pathto, path);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error writing hardlink '%s' to '%s'. %s.\n", path, pathto, strerror(errno));
log_fatal("Error writing hardlink '%s' to '%s'. %s.\n", path, pathto, strerror(errno));
if (errno == EACCES) {
msg_error("WARNING! Please give write permission to the hardlink.\n");
log_fatal("WARNING! Please give write permission to the hardlink.\n");
} else {
/* we do not use DANGER because it could be ENOSPC which is not always correctly reported */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
}
msg_error("Stopping\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_tag("hardlinkfixed:%s:%s: Fixed hardlink error\n", disk->name, esc(link->sub));
log_tag("hardlinkfixed:%s:%s: Fixed hardlink error\n", disk->name, esc(link->sub));
++recovered_error;
} else {
ret = symlink(link->linkto, path);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error writing symlink '%s' to '%s'. %s.\n", path, link->linkto, strerror(errno));
log_fatal("Error writing symlink '%s' to '%s'. %s.\n", path, link->linkto, strerror(errno));
if (errno == EACCES) {
msg_error("WARNING! Please give write permission to the symlink.\n");
log_fatal("WARNING! Please give write permission to the symlink.\n");
} else {
/* we do not use DANGER because it could be ENOSPC which is not always correctly reported */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
}
msg_error("Stopping\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_tag("symlinkfixed:%s:%s: Fixed symlink error\n", disk->name, esc(link->sub));
log_tag("symlinkfixed:%s:%s: Fixed symlink error\n", disk->name, esc(link->sub));
++recovered_error;
}
msg_tag("status:recovered:%s:%s\n", disk->name, esc(link->sub));
log_tag("status:recovered:%s:%s\n", disk->name, esc(link->sub));
msg_info("recovered %s%s\n", disk->dir, link->sub);
}
}
@ -1634,13 +1634,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
if (ret == -1) {
unsuccesful = 1;
msg_warning("Error stating dir '%s'. %s.\n", path, strerror(errno));
msg_tag("dir_error:%s:%s: Dir stat error\n", disk->name, esc(dir->sub));
log_error("Error stating dir '%s'. %s.\n", path, strerror(errno));
log_tag("dir_error:%s:%s: Dir stat error\n", disk->name, esc(dir->sub));
++error;
} else if (!S_ISDIR(st.st_mode)) {
unsuccesful = 1;
msg_tag("dir_error:%s:%s: Dir error for not directory\n", disk->name, esc(dir->sub));
log_tag("dir_error:%s:%s: Dir error for not directory\n", disk->name, esc(dir->sub));
++error;
}
@ -1649,8 +1649,8 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
ret = mkancestor(path);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
msg_error("Stopping\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1660,23 +1660,23 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
ret = mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error creating dir '%s'. %s.\n", path, strerror(errno));
log_fatal("Error creating dir '%s'. %s.\n", path, strerror(errno));
if (errno == EACCES) {
msg_error("WARNING! Please give write permission to the dir.\n");
log_fatal("WARNING! Please give write permission to the dir.\n");
} else {
/* we do not use DANGER because it could be ENOSPC which is not always correctly reported */
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
}
msg_error("Stopping\n");
log_fatal("Stopping\n");
++unrecoverable_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_tag("dir_fixed:%s:%s: Fixed dir error\n", disk->name, esc(dir->sub));
log_tag("dir_fixed:%s:%s: Fixed dir error\n", disk->name, esc(dir->sub));
++recovered_error;
msg_tag("status:recovered:%s:%s\n", disk->name, esc(dir->sub));
log_tag("status:recovered:%s:%s\n", disk->name, esc(dir->sub));
msg_info("recovered %s%s\n", disk->dir, dir->sub);
}
}
@ -1690,7 +1690,7 @@ bail:
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("DANGER! Unexpected close error in a data disk.\n");
log_fatal("DANGER! Unexpected close error in a data disk.\n");
++unrecoverable_error;
/* continue, as we are already exiting */
/* LCOV_EXCL_STOP */
@ -1738,8 +1738,8 @@ bail:
ret = remove(path);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error removing '%s'. %s.\n", path, strerror(errno));
msg_error("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
log_fatal("Error removing '%s'. %s.\n", path, strerror(errno));
log_fatal("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
++unrecoverable_error;
/* continue, as we are already exiting */
/* LCOV_EXCL_STOP */
@ -1768,36 +1768,36 @@ bail:
}
if (error && !fix)
msg_error("WARNING! There are errors!\n");
log_fatal("WARNING! There are errors!\n");
if (unrecoverable_error)
msg_error("DANGER! There are unrecoverable errors!\n");
log_fatal("DANGER! There are unrecoverable errors!\n");
msg_tag("summary:error:%u\n", error);
log_tag("summary:error:%u\n", error);
if (fix)
msg_tag("summary:error_recovered:%u\n", recovered_error);
log_tag("summary:error_recovered:%u\n", recovered_error);
if (!state->opt.auditonly)
msg_tag("summary:error_unrecoverable:%u\n", unrecoverable_error);
log_tag("summary:error_unrecoverable:%u\n", unrecoverable_error);
if (fix) {
if (error + recovered_error + unrecoverable_error == 0)
msg_tag("summary:exit:ok\n");
log_tag("summary:exit:ok\n");
else if (unrecoverable_error == 0)
msg_tag("summary:exit:recovered\n");
log_tag("summary:exit:recovered\n");
else
msg_tag("summary:exit:unrecoverable\n");
log_tag("summary:exit:unrecoverable\n");
} else if (!state->opt.auditonly) {
if (error + unrecoverable_error == 0)
msg_tag("summary:exit:ok\n");
log_tag("summary:exit:ok\n");
else if (unrecoverable_error == 0)
msg_tag("summary:exit:recoverable\n");
log_tag("summary:exit:recoverable\n");
else
msg_tag("summary:exit:unrecoverable\n");
log_tag("summary:exit:unrecoverable\n");
} else { /* audit only */
if (error == 0)
msg_tag("summary:exit:ok\n");
log_tag("summary:exit:ok\n");
else
msg_tag("summary:exit:error\n");
log_tag("summary:exit:error\n");
}
msg_flush();
log_flush();
free(failed);
free(failed_map);
@ -1848,7 +1848,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
if (blockstart > blockmax) {
/* LCOV_EXCL_START */
msg_error("Error in the specified starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
log_fatal("Error in the specified starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1866,7 +1866,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
ret = parity_create(parity_ptr[l], state->parity[l].path, &out_size, state->file_mode);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("WARNING! Without an accessible %s file, it isn't possible to fix any error.\n", lev_name(l));
log_fatal("WARNING! Without an accessible %s file, it isn't possible to fix any error.\n", lev_name(l));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1874,7 +1874,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
ret = parity_chsize(parity_ptr[l], size, &out_size, state->opt.skip_fallocate);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
log_fatal("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1923,7 +1923,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
ret = parity_close(parity_ptr[l]);
/* LCOV_EXCL_START */
if (ret == -1) {
msg_error("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
log_fatal("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
++error;
/* continue, as we are already exiting */
}

View file

@ -794,22 +794,22 @@ static void state_smart(unsigned n, tommy_list* low)
printf("\n");
msg_tag("smart:%s:%s\n", devinfo->file, devinfo->name);
log_tag("smart:%s:%s\n", devinfo->file, devinfo->name);
if (devinfo->smart_serial[0])
msg_tag("attr:%s:%s:serial:%s\n", devinfo->file, devinfo->name, esc(devinfo->smart_serial));
log_tag("attr:%s:%s:serial:%s\n", devinfo->file, devinfo->name, esc(devinfo->smart_serial));
if (afr != 0)
msg_tag("attr:%s:%s:afr:%g\n", devinfo->file, devinfo->name, afr);
log_tag("attr:%s:%s:afr:%g\n", devinfo->file, devinfo->name, afr);
if (devinfo->smart[SMART_SIZE] != SMART_UNASSIGNED)
msg_tag("attr:%s:%s:size:%" PRIu64 "\n", devinfo->file, devinfo->name, devinfo->smart[SMART_SIZE]);
log_tag("attr:%s:%s:size:%" PRIu64 "\n", devinfo->file, devinfo->name, devinfo->smart[SMART_SIZE]);
if (devinfo->smart[SMART_ERROR] != SMART_UNASSIGNED)
msg_tag("attr:%s:%s:error:%" PRIu64 "\n", devinfo->file, devinfo->name, devinfo->smart[SMART_ERROR]);
log_tag("attr:%s:%s:error:%" PRIu64 "\n", devinfo->file, devinfo->name, devinfo->smart[SMART_ERROR]);
if (devinfo->smart[SMART_ROTATION_RATE] != SMART_UNASSIGNED)
msg_tag("attr:%s:%s:rotationrate:%" PRIu64 "\n", devinfo->file, devinfo->name, devinfo->smart[SMART_ROTATION_RATE]);
log_tag("attr:%s:%s:rotationrate:%" PRIu64 "\n", devinfo->file, devinfo->name, devinfo->smart[SMART_ROTATION_RATE]);
if (devinfo->smart[SMART_FLAGS] != SMART_UNASSIGNED)
msg_tag("attr:%s:%s:flags:%" PRIu64 ":%" PRIx64 "\n", devinfo->file, devinfo->name, devinfo->smart[SMART_FLAGS], devinfo->smart[SMART_FLAGS]);
log_tag("attr:%s:%s:flags:%" PRIu64 ":%" PRIx64 "\n", devinfo->file, devinfo->name, devinfo->smart[SMART_FLAGS], devinfo->smart[SMART_FLAGS]);
for (j = 0; j < 256; ++j)
if (devinfo->smart[j] != SMART_UNASSIGNED)
msg_tag("attr:%s:%s:%u:%" PRIu64 ":%" PRIx64 "\n", devinfo->file, devinfo->name, j, devinfo->smart[j], devinfo->smart[j]);
log_tag("attr:%s:%s:%u:%" PRIu64 ":%" PRIx64 "\n", devinfo->file, devinfo->name, j, devinfo->smart[j], devinfo->smart[j]);
}
printf("\n");
@ -826,7 +826,7 @@ static void state_smart(unsigned n, tommy_list* low)
p_at_least_one_failure = poisson_prob_n_or_more_failures(array_failure_rate, 1);
printf("Probability that at least one disk is going to fail in the next year is %.0f%%.\n", p_at_least_one_failure * 100);
msg_tag("summary:array_failure:%g:%g\n", array_failure_rate, p_at_least_one_failure);
log_tag("summary:array_failure:%g:%g\n", array_failure_rate, p_at_least_one_failure);
/* prints extra stats only in verbose mode */
if (msg_level < MSG_VERBOSE)
@ -988,7 +988,7 @@ void state_device(struct snapraid_state* state, int operation)
case DEVICE_LIST : ope = "List"; break;
case DEVICE_SMART : ope = "SMART"; break;
}
msg_error("%s unsupported in this platform.\n", ope);
log_fatal("%s unsupported in this platform.\n", ope);
} else {
if (operation == DEVICE_LIST) {
for (i = tommy_list_head(&low); i != 0; i = i->next) {

View file

@ -82,20 +82,20 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected close error in a data disk, it isn't possible to dry.\n");
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected close error in a data disk, it isn't possible to dry.\n");
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
}
/* open the file only for reading */
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, msg_error, 0);
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, log_fatal, 0);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("DANGER! Unexpected open error in a data disk, it isn't possible to dry.\n");
msg_error("Stopping at block %u\n", i);
log_fatal("DANGER! Unexpected open error in a data disk, it isn't possible to dry.\n");
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -103,9 +103,9 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
}
/* read from the file */
read_size = handle_read(&handle[j], block, buffer_aligned, state->block_size, msg_warning, 0);
read_size = handle_read(&handle[j], block, buffer_aligned, state->block_size, log_error, 0);
if (read_size == -1) {
msg_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc(block_file_get(block)->sub), block_file_pos(block));
log_tag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, esc(block_file_get(block)->sub), block_file_pos(block));
++error;
continue;
}
@ -122,9 +122,9 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
/* until now is CPU */
state_usage_cpu(state);
ret = parity_read(parity[l], i, buffer_aligned, state->block_size, msg_warning);
ret = parity_read(parity[l], i, buffer_aligned, state->block_size, log_error);
if (ret == -1) {
msg_tag("parity_error:%u:%s: Read error\n", i, lev_config_name(l));
log_tag("parity_error:%u:%s: Read error\n", i, lev_config_name(l));
++error;
}
@ -156,8 +156,8 @@ bail:
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected close error in a data disk.\n");
log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected close error in a data disk.\n");
++error;
/* continue, as we are already exiting */
/* LCOV_EXCL_STOP */
@ -172,7 +172,7 @@ bail:
}
if (error)
msg_error("DANGER! Unexpected errors!\n");
log_fatal("DANGER! Unexpected errors!\n");
free(handle);
free(buffer_alloc);
@ -199,7 +199,7 @@ void state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t
if (blockstart > blockmax) {
/* LCOV_EXCL_START */
msg_error("Error in the specified starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
log_fatal("Error in the specified starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -125,7 +125,7 @@ void state_dup(struct snapraid_state* state)
if (dup) {
++count;
size += dup->file->size;
msg_tag("dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, esc(file->sub), dup->disk->name, esc(dup->file->sub), dup->file->size);
log_tag("dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, esc(file->sub), dup->disk->name, esc(dup->file->sub), dup->file->size);
printf("%12" PRIu64 " %s%s = %s%s\n", file->size, disk->dir, file->sub, dup->disk->dir, dup->file->sub);
hash_free(hash);
} else {
@ -144,13 +144,13 @@ void state_dup(struct snapraid_state* state)
else
msg_status("No duplicates\n");
msg_tag("summary:dup_count:%u\n", count);
msg_tag("summary:dup_size:%" PRIu64 "\n", size);
log_tag("summary:dup_count:%u\n", count);
log_tag("summary:dup_size:%" PRIu64 "\n", size);
if (count == 0) {
msg_tag("summary:exit:unique\n");
log_tag("summary:exit:unique\n");
} else {
msg_tag("summary:exit:dup\n");
log_tag("summary:exit:dup\n");
}
msg_flush();
log_flush();
}

View file

@ -277,7 +277,7 @@ int filter_existence(int filter_missing, const char* dir, const char* sub)
if (errno == ENOENT)
return 0;
/* LCOV_EXCL_START */
msg_error("Error in stat file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error in stat file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -342,7 +342,7 @@ block_off_t block_file_pos(struct snapraid_block* block)
if (block < file->blockvec || block >= file->blockvec + file->blockmax) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in block %u ownership\n", block->parity_pos);
log_fatal("Internal inconsistency in block %u ownership\n", block->parity_pos);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -456,21 +456,21 @@ void file_copy(struct snapraid_file* src_file, struct snapraid_file* dst_file)
if (src_file->size != dst_file->size) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in copy file with different size\n");
log_fatal("Internal inconsistency in copy file with different size\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (src_file->mtime_sec != dst_file->mtime_sec) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in copy file with different mtime_sec\n");
log_fatal("Internal inconsistency in copy file with different mtime_sec\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (src_file->mtime_nsec != dst_file->mtime_nsec) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in copy file with different mtime_nsec\n");
log_fatal("Internal inconsistency in copy file with different mtime_nsec\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -748,7 +748,7 @@ int disk_is_empty(struct snapraid_disk* disk, block_off_t blockmax)
return 0;
default :
/* LCOV_EXCL_START */
msg_error("Internal inconsistency for used block in disk '%s' without files\n", disk->name);
log_fatal("Internal inconsistency for used block in disk '%s' without files\n", disk->name);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -498,7 +498,7 @@ static inline void block_file_set(struct snapraid_block* block, struct snapraid_
/* ensure that the pointer doesn't use the flag space */
if ((ptr & (uintptr_t)BLOCK_STATE_MASK) != 0) {
/* LCOV_EXCL_START */
msg_error("Internal error for pointer not aligned\n");
log_fatal("Internal error for pointer not aligned\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -525,7 +525,7 @@ static inline void block_state_set(struct snapraid_block* block, unsigned state)
/* ensure that the state can be stored inside the file pointer */
if ((state & BLOCK_STATE_MASK) != state) {
/* LCOV_EXCL_START */
msg_error("Internal error when setting the block state %u\n", state);
log_fatal("Internal error when setting the block state %u\n", state);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -90,7 +90,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
handle->f = -1;
handle->valid_size = 0;
msg_error("Error opening file '%s'. %s.\n", handle->path, strerror(errno));
log_fatal("Error opening file '%s'. %s.\n", handle->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -102,7 +102,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
ret = fstat(handle->f, &handle->st);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
log_fatal("Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -116,7 +116,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error advising file '%s'. %s.\n", handle->path, strerror(ret));
log_fatal("Error advising file '%s'. %s.\n", handle->path, strerror(ret));
return -1;
/* LCOV_EXCL_STOP */
}
@ -134,9 +134,9 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file)
if (ret != 0) {
/* LCOV_EXCL_START */
if (errno == EACCES) {
msg_error("Failed to truncate file '%s' for missing write permission.\n", handle->path);
log_fatal("Failed to truncate file '%s' for missing write permission.\n", handle->path);
} else {
msg_error("Error truncating file '%s'. %s.\n", handle->path, strerror(errno));
log_fatal("Error truncating file '%s'. %s.\n", handle->path, strerror(errno));
}
return -1;
/* LCOV_EXCL_STOP */
@ -229,7 +229,7 @@ int handle_close(struct snapraid_handle* handle)
ret = close(handle->f);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file '%s'. %s.\n", handle->file->sub, strerror(errno));
log_fatal("Error closing file '%s'. %s.\n", handle->file->sub, strerror(errno));
/* invalidate for error */
handle->file = 0;
@ -338,7 +338,7 @@ int handle_write(struct snapraid_handle* handle, struct snapraid_block* block, u
#else
if (lseek(handle->f, offset, SEEK_SET) != offset) {
/* LCOV_EXCL_START */
msg_error("Error seeking file '%s'. %s.\n", handle->path, strerror(errno));
log_fatal("Error seeking file '%s'. %s.\n", handle->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -347,7 +347,7 @@ int handle_write(struct snapraid_handle* handle, struct snapraid_block* block, u
#endif
if (write_ret != (ssize_t)write_size) { /* conversion is safe because block_size is always small */
/* LCOV_EXCL_START */
msg_error("Error writing file '%s'. %s.\n", handle->path, strerror(errno));
log_fatal("Error writing file '%s'. %s.\n", handle->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -375,7 +375,7 @@ int handle_utime(struct snapraid_handle* handle)
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error timing file '%s'. %s.\n", handle->file->sub, strerror(errno));
log_fatal("Error timing file '%s'. %s.\n", handle->file->sub, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -423,7 +423,7 @@ struct snapraid_handle* handle_map(struct snapraid_state* state, unsigned* handl
}
if (k == 0) {
/* LCOV_EXCL_START */
msg_error("Internal error for inconsistent disk mapping.\n");
log_fatal("Internal error for inconsistent disk mapping.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -78,7 +78,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
f = open(path, flags);
if (f == -1) {
/* LCOV_EXCL_START */
msg_error("Error opening file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -89,7 +89,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
ret = posix_fadvise(f, 0, 0, POSIX_FADV_SEQUENTIAL);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error advising file '%s'. %s.\n", path, strerror(ret));
log_fatal("Error advising file '%s'. %s.\n", path, strerror(ret));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -106,7 +106,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
ret = read(f, buffer, read_size);
if (ret < 0 || (unsigned)ret != read_size) {
/* LCOV_EXCL_START */
msg_error("Error reading file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error reading file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -132,7 +132,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
ret = close(f);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -174,14 +174,14 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
f = open(path, O_RDONLY | O_BINARY);
if (f == -1) {
/* LCOV_EXCL_START */
msg_error("Error opening file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (lseek(f, block->offset, SEEK_SET) != block->offset) {
/* LCOV_EXCL_START */
msg_error("Error seeking file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error seeking file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -189,7 +189,7 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
ret = read(f, buffer, read_size);
if (ret < 0 || (unsigned)ret != read_size) {
/* LCOV_EXCL_START */
msg_error("Error reading file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error reading file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -197,7 +197,7 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
ret = close(f);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -215,8 +215,8 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
if (memcmp(buffer_hash, hash, HASH_SIZE) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in data reading file '%s'.\n", path);
msg_error("Please don't change imported files while running.\n");
log_fatal("Error in data reading file '%s'.\n", path);
log_fatal("Please don't change imported files while running.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -231,7 +231,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
d = opendir(dir);
if (!d) {
/* LCOV_EXCL_START */
msg_error("Error opening directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error opening directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -247,7 +247,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
dd = readdir(d);
if (dd == 0 && errno != 0) {
/* LCOV_EXCL_START */
msg_error("Error reading directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -274,7 +274,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
if (st.st_mode == 0) {
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -283,7 +283,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
/* get lstat info about the file */
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -299,7 +299,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
if (closedir(d) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error closing directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -59,7 +59,7 @@ void state_list(struct snapraid_state* state)
++file_count;
file_size += file->size;
msg_tag("file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, esc(file->sub), file->size, file->mtime_sec, file->mtime_nsec, file->inode);
log_tag("file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, esc(file->sub), file->size, file->mtime_sec, file->mtime_nsec, file->inode);
t = file->mtime_sec;
#if HAVE_LOCALTIME_R
@ -98,7 +98,7 @@ void state_list(struct snapraid_state* state)
++link_count;
msg_tag("link_%s:%s:%s:%s\n", type, disk->name, esc(link->sub), esc(link->linkto));
log_tag("link_%s:%s:%s:%s\n", type, disk->name, esc(link->sub), esc(link->linkto));
printf("%12s ", type);
printf(" ");
@ -112,10 +112,10 @@ void state_list(struct snapraid_state* state)
msg_status("%8u files, for %" PRIu64 " GB\n", file_count, file_size / GIGA);
msg_status("%8u links\n", link_count);
msg_tag("summary:file_count:%u\n", file_count);
msg_tag("summary:file_size:%" PRIu64 "\n", file_size);
msg_tag("summary:link_count:%u\n", link_count);
msg_tag("summary:exit:ok\n");
msg_flush();
log_tag("summary:file_count:%u\n", file_count);
log_tag("summary:file_size:%" PRIu64 "\n", file_size);
log_tag("summary:link_count:%u\n", link_count);
log_tag("summary:exit:ok\n");
log_flush();
}

View file

@ -185,19 +185,19 @@ void os_init(int opt)
ntdll = GetModuleHandle("NTDLL.DLL");
if (!ntdll) {
msg_error("Error loading the NTDLL module.\n");
log_fatal("Error loading the NTDLL module.\n");
exit(EXIT_FAILURE);
}
kernel32 = GetModuleHandle("KERNEL32.DLL");
if (!kernel32) {
msg_error("Error loading the KERNEL32 module.\n");
log_fatal("Error loading the KERNEL32 module.\n");
exit(EXIT_FAILURE);
}
dll_advapi32 = LoadLibrary("ADVAPI32.DLL");
if (!dll_advapi32) {
msg_error("Error loading the ADVAPI32 module.\n");
log_fatal("Error loading the ADVAPI32 module.\n");
exit(EXIT_FAILURE);
}
@ -210,7 +210,7 @@ void os_init(int opt)
ptr_RtlGenRandom = (void*)GetProcAddress(dll_advapi32, "SystemFunction036");
if (!ptr_RtlGenRandom) {
msg_error("Error loading RtlGenRandom() from the ADVAPI32 module.\n");
log_fatal("Error loading RtlGenRandom() from the ADVAPI32 module.\n");
exit(EXIT_FAILURE);
}
@ -275,7 +275,7 @@ static wchar_t* u8tou16(const char* src)
ret = MultiByteToWideChar(CP_UTF8, 0, src, -1, conv_utf16_buffer[roll], sizeof(conv_utf16_buffer[0]) / sizeof(wchar_t));
if (ret <= 0) {
msg_error("Error converting name '%s' from UTF-8 to UTF-16\n", src);
log_fatal("Error converting name '%s' from UTF-8 to UTF-16\n", src);
exit(EXIT_FAILURE);
}
@ -298,7 +298,7 @@ static char* u16tou8ex(const wchar_t* src, size_t number_of_wchar, size_t* resul
ret = WideCharToMultiByte(CP_UTF8, 0, src, number_of_wchar, conv_utf8_buffer[roll], sizeof(conv_utf8_buffer[0]), 0, 0);
if (ret <= 0) {
msg_error("Error converting from UTF-16 to UTF-8\n");
log_fatal("Error converting from UTF-16 to UTF-8\n");
exit(EXIT_FAILURE);
}
@ -393,7 +393,7 @@ static wchar_t* convert_arg(const char* src, int only_if_required)
ret = MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, sizeof(conv_utf16_buffer[0]) / sizeof(wchar_t) - count);
if (ret <= 0) {
msg_error("Error converting name '%s' from UTF-8 to UTF-16\n", src);
log_fatal("Error converting name '%s' from UTF-8 to UTF-16\n", src);
exit(EXIT_FAILURE);
}
@ -627,7 +627,7 @@ static void windows_finddata2dirent(const WIN32_FIND_DATAW* info, struct windows
name = u16tou8ex(info->cFileName, wcslen(info->cFileName), &len);
if (len + 1 >= sizeof(dirent->d_name)) {
msg_error("Name too long\n");
log_fatal("Name too long\n");
exit(EXIT_FAILURE);
}
@ -645,7 +645,7 @@ static void windows_stream2dirent(const BY_HANDLE_FILE_INFORMATION* info, const
name = u16tou8ex(stream->FileName, stream->FileNameLength / 2, &len);
if (len + 1 >= sizeof(dirent->d_name)) {
msg_error("Name too long\n");
log_fatal("Name too long\n");
exit(EXIT_FAILURE);
}
@ -696,7 +696,7 @@ static void windows_errno(DWORD error)
errno = EPERM;
break;
default :
msg_error("Unexpected Windows error %d.\n", (int)error);
log_fatal("Unexpected Windows error %d.\n", (int)error);
errno = EIO;
break;
}
@ -1000,8 +1000,8 @@ int windows_fsync(int fd)
* this error, but not enough sure to ignore it.
* So, we use now an extended error reporting.
*/
msg_error("Unexpected Windows INVALID_HANDLE error in FlushFileBuffers().\n");
msg_error("Are you using ATA-over-Ethernet ? Please report it.\n");
log_fatal("Unexpected Windows INVALID_HANDLE error in FlushFileBuffers().\n");
log_fatal("Are you using ATA-over-Ethernet ? Please report it.\n");
/* normal error processing */
windows_errno(error);
@ -1132,7 +1132,7 @@ static windows_dir* windows_opendir_find(const char* dir)
dirstream = malloc(sizeof(windows_dir));
if (!dirstream) {
msg_error("Low memory\n");
log_fatal("Low memory\n");
exit(EXIT_FAILURE);
}
@ -1269,7 +1269,7 @@ static windows_dir* windows_opendir_stream(const char* dir)
dirstream = malloc(sizeof(windows_dir));
if (!dirstream) {
msg_error("Low memory\n");
log_fatal("Low memory\n");
exit(EXIT_FAILURE);
}
@ -1279,7 +1279,7 @@ static windows_dir* windows_opendir_stream(const char* dir)
dirstream->buffer_size = 64 * 1024;
dirstream->buffer = malloc(dirstream->buffer_size);
if (!dirstream->buffer) {
msg_error("Low memory\n");
log_fatal("Low memory\n");
exit(EXIT_FAILURE);
}
@ -1756,7 +1756,7 @@ retry:
* https://sourceforge.net/p/snapraid/discussion/1677233/thread/a7c25ba9/
*/
if (err == ERROR_NO_SYSTEM_RESOURCES) {
msg_error("Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pread(), retrying...\n");
log_fatal("Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pread(), retrying...\n");
Sleep(50);
goto retry;
}
@ -1796,7 +1796,7 @@ retry:
DWORD err = GetLastError();
/* See windows_pread() for comments on this error management */
if (err == ERROR_NO_SYSTEM_RESOURCES) {
msg_error("Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pwrite(), retrying...\n");
log_fatal("Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pwrite(), retrying...\n");
Sleep(50);
goto retry;
}
@ -1971,7 +1971,7 @@ static int smartctl_scan(FILE* f, tommy_list* list)
/* remove extraneous chars */
s = polish(buf);
msg_tag("smartctl:scan::text: %s\n", s);
log_tag("smartctl:scan::text: %s\n", s);
if (*s == '/') {
char* sep = strchr(s, ' ');
@ -2029,12 +2029,12 @@ static int devscan(tommy_list* list)
snwprintf(cmd, sizeof(cmd), L"\"%lssmartctl.exe\" --scan-open -d pd", exedir);
msg_tag("smartctl:scan::run: %s\n", u16tou8(cmd));
log_tag("smartctl:scan::run: %s\n", u16tou8(cmd));
f = _wpopen(cmd, L"rt");
if (!f) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from popen).\n", u16tou8(cmd));
log_fatal("Failed to run '%s' (from popen).\n", u16tou8(cmd));
return -1;
/* LCOV_EXCL_STOP */
}
@ -2048,17 +2048,17 @@ static int devscan(tommy_list* list)
ret = pclose(f);
msg_tag("smartctl:scan::ret: %x\n", ret);
log_tag("smartctl:scan::ret: %x\n", ret);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from pclose).\n", u16tou8(cmd));
log_fatal("Failed to run '%s' (from pclose).\n", u16tou8(cmd));
return -1;
/* LCOV_EXCL_STOP */
}
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' with return code %xh.\n", u16tou8(cmd), ret);
log_fatal("Failed to run '%s' with return code %xh.\n", u16tou8(cmd), ret);
return -1;
/* LCOV_EXCL_STOP */
}
@ -2091,12 +2091,12 @@ static int devsmart(uint64_t device, const char* name, const char* custom, uint6
count = 0;
retry:
msg_tag("smartctl:%s:%s:run: %s\n", file, name, u16tou8(cmd));
log_tag("smartctl:%s:%s:run: %s\n", file, name, u16tou8(cmd));
f = _wpopen(cmd, L"rt");
if (!f) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from popen).\n", u16tou8(cmd));
log_fatal("Failed to run '%s' (from popen).\n", u16tou8(cmd));
return -1;
/* LCOV_EXCL_STOP */
}
@ -2110,11 +2110,11 @@ retry:
ret = pclose(f);
msg_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
log_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from pclose).\n", u16tou8(cmd));
log_fatal("Failed to run '%s' (from pclose).\n", u16tou8(cmd));
return -1;
/* LCOV_EXCL_STOP */
}
@ -2176,12 +2176,12 @@ static int devdown(uint64_t device, const char* name, const char* custom)
count = 0;
retry:
msg_tag("smartctl:%s:%s:run: %s\n", file, name, u16tou8(cmd));
log_tag("smartctl:%s:%s:run: %s\n", file, name, u16tou8(cmd));
f = _wpopen(cmd, L"rt");
if (!f) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from popen).\n", u16tou8(cmd));
log_fatal("Failed to run '%s' (from popen).\n", u16tou8(cmd));
return -1;
/* LCOV_EXCL_STOP */
}
@ -2195,11 +2195,11 @@ retry:
ret = pclose(f);
msg_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
log_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from pclose).\n", u16tou8(cmd));
log_fatal("Failed to run '%s' (from pclose).\n", u16tou8(cmd));
return -1;
/* LCOV_EXCL_STOP */
}
@ -2225,7 +2225,7 @@ retry:
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' with return code %xh.\n", u16tou8(cmd), ret);
log_fatal("Failed to run '%s' with return code %xh.\n", u16tou8(cmd), ret);
return -1;
/* LCOV_EXCL_STOP */
}
@ -2274,7 +2274,7 @@ static void* thread_spinup(void* arg)
/* we cannot use FindFirstFile because it doesn't allow to open the root dir */
if (lstat_sync(devinfo->mount, &st, 0) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to stat path '%s'. %s.\n", devinfo->mount, strerror(errno));
log_fatal("Failed to stat path '%s'. %s.\n", devinfo->mount, strerror(errno));
return (void*)-1;
/* LCOV_EXCL_STOP */
}
@ -2284,7 +2284,7 @@ static void* thread_spinup(void* arg)
if (devresolve(devinfo->mount, devinfo->file, sizeof(devinfo->file), devinfo->wfile, sizeof(devinfo->wfile)) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to resolve path '%s'.\n", devinfo->mount);
log_fatal("Failed to resolve path '%s'.\n", devinfo->mount);
return (void*)-1;
/* LCOV_EXCL_STOP */
}
@ -2348,7 +2348,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
if (pthread_create(&devinfo->thread, 0, func, devinfo) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to create thread.\n");
log_fatal("Failed to create thread.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -2361,7 +2361,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
if (pthread_join(devinfo->thread, &retval) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to join thread.\n");
log_fatal("Failed to join thread.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -2391,7 +2391,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
if (devresolve(devinfo->mount, devinfo->file, sizeof(devinfo->file), devinfo->wfile, sizeof(devinfo->wfile)) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to resolve path '%s'.\n", devinfo->mount);
log_fatal("Failed to resolve path '%s'.\n", devinfo->mount);
return -1;
/* LCOV_EXCL_STOP */
}
@ -2399,7 +2399,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
/* expand the tree of devices */
if (devtree(devinfo->name, devinfo->smartctl, devinfo->wfile, devinfo, low) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to expand device '%s'.\n", devinfo->file);
log_fatal("Failed to expand device '%s'.\n", devinfo->file);
return -1;
/* LCOV_EXCL_STOP */
}
@ -2427,7 +2427,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
if (operation == DEVICE_SMART) {
if (devscan(low) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to list other devices.\n");
log_fatal("Failed to list other devices.\n");
return -1;
/* LCOV_EXCL_STOP */
}

View file

@ -149,7 +149,7 @@ void cmd_generate_file(const char* path, int size)
if (remove(path) != 0) {
if (errno != ENOENT) {
/* LCOV_EXCL_START */
msg_error("Error removing file %s\n", path);
log_fatal("Error removing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -171,21 +171,21 @@ void cmd_generate_file(const char* path, int size)
f = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NOFOLLOW, 0600);
if (f < 0) {
/* LCOV_EXCL_START */
msg_error("Error creating file %s\n", path);
log_fatal("Error creating file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (write(f, data, size) != size) {
/* LCOV_EXCL_START */
msg_error("Error writing file %s\n", path);
log_fatal("Error writing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (close(f) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file %s\n", path);
log_fatal("Error closing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -203,7 +203,7 @@ void cmd_generate_symlink(const char* path, const char* linkto)
if (remove(path) != 0) {
if (errno != ENOENT) {
/* LCOV_EXCL_START */
msg_error("Error removing file %s\n", path);
log_fatal("Error removing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -211,7 +211,7 @@ void cmd_generate_symlink(const char* path, const char* linkto)
if (symlink(linkto, path) != 0) {
/* LCOV_EXCL_START */
msg_error("Error writing symlink %s\n", path);
log_fatal("Error writing symlink %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -236,7 +236,7 @@ void cmd_generate(int disk, int size)
if (mkdir(path, 0777) != 0) {
if (errno != EEXIST) {
/* LCOV_EXCL_START */
msg_error("Error creating directory %s\n", path);
log_fatal("Error creating directory %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -294,7 +294,7 @@ void cmd_write(const char* path, int size)
if (lstat(path, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing %s\n", path);
log_fatal("Error accessing %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -321,28 +321,28 @@ void cmd_write(const char* path, int size)
f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW);
if (f < 0) {
/* LCOV_EXCL_START */
msg_error("Error creating file %s\n", path);
log_fatal("Error creating file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (lseek(f, off, SEEK_SET) != off) {
/* LCOV_EXCL_START */
msg_error("Error seeking file %s\n", path);
log_fatal("Error seeking file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (write(f, data, size) != size) {
/* LCOV_EXCL_START */
msg_error("Error writing file %s\n", path);
log_fatal("Error writing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (close(f) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file %s\n", path);
log_fatal("Error closing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -370,7 +370,7 @@ void cmd_damage(const char* path, int size)
if (lstat(path, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing %s\n", path);
log_fatal("Error accessing %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -398,21 +398,21 @@ void cmd_damage(const char* path, int size)
f = open(path, O_RDWR | O_BINARY | O_NOFOLLOW);
if (f < 0) {
/* LCOV_EXCL_START */
msg_error("Error creating file %s\n", path);
log_fatal("Error creating file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (lseek(f, off, SEEK_SET) != off) {
/* LCOV_EXCL_START */
msg_error("Error seeking file %s\n", path);
log_fatal("Error seeking file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (read(f, data, size) != size) {
/* LCOV_EXCL_START */
msg_error("Error writing file %s\n", path);
log_fatal("Error writing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -421,28 +421,28 @@ void cmd_damage(const char* path, int size)
if (lseek(f, off, SEEK_SET) != off) {
/* LCOV_EXCL_START */
msg_error("Error seeking file %s\n", path);
log_fatal("Error seeking file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (write(f, data, size) != size) {
/* LCOV_EXCL_START */
msg_error("Error writing file %s\n", path);
log_fatal("Error writing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (fallback(f, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error setting time for file %s\n", path);
log_fatal("Error setting time for file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (close(f) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file %s\n", path);
log_fatal("Error closing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -462,7 +462,7 @@ void cmd_append(const char* path, int size)
if (lstat(path, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing %s\n", path);
log_fatal("Error accessing %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -478,21 +478,21 @@ void cmd_append(const char* path, int size)
f = open(path, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW);
if (f < 0) {
/* LCOV_EXCL_START */
msg_error("Error opening file %s\n", path);
log_fatal("Error opening file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (write(f, data, size) != size) {
/* LCOV_EXCL_START */
msg_error("Error writing file %s\n", path);
log_fatal("Error writing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (close(f) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file %s\n", path);
log_fatal("Error closing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -513,7 +513,7 @@ void cmd_truncate(const char* path, int size)
if (lstat(path, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing %s\n", path);
log_fatal("Error accessing %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -536,21 +536,21 @@ void cmd_truncate(const char* path, int size)
f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW);
if (f < 0) {
/* LCOV_EXCL_START */
msg_error("Error opening file %s\n", path);
log_fatal("Error opening file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (ftruncate(f, off) != 0) {
/* LCOV_EXCL_START */
msg_error("Error truncating file %s\n", path);
log_fatal("Error truncating file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (close(f) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file %s\n", path);
log_fatal("Error closing file %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -565,7 +565,7 @@ void cmd_delete(const char* path)
{
if (remove(path) != 0) {
/* LCOV_EXCL_START */
msg_error("Error removing %s\n", path);
log_fatal("Error removing %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -584,7 +584,7 @@ void cmd_change(const char* path, int size)
if (lstat(path, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing %s\n", path);
log_fatal("Error accessing %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -595,7 +595,7 @@ void cmd_change(const char* path, int size)
/* delete */
if (remove(path) != 0) {
/* LCOV_EXCL_START */
msg_error("Error removing %s\n", path);
log_fatal("Error removing %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -605,7 +605,7 @@ void cmd_change(const char* path, int size)
if (remove(path) != 0) {
/* LCOV_EXCL_START */
msg_error("Error removing %s\n", path);
log_fatal("Error removing %s\n", path);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -56,7 +56,7 @@ void state_nano(struct snapraid_state* state)
/* get a random nanosecond value */
if (randomize(&nano, sizeof(nano)) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to get random values.\n");
log_fatal("Failed to get random values.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -69,7 +69,7 @@ void state_nano(struct snapraid_state* state)
f = open(path, O_RDONLY | O_BINARY | O_NOFOLLOW);
if (f == -1) {
/* LCOV_EXCL_START */
msg_error("Error opening file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
continue;
/* LCOV_EXCL_STOP */
}
@ -80,7 +80,7 @@ void state_nano(struct snapraid_state* state)
if (ret == -1) {
/* LCOV_EXCL_START */
close(f);
msg_error("Error accessing file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error accessing file '%s'. %s.\n", path, strerror(errno));
continue;
/* LCOV_EXCL_STOP */
}
@ -90,7 +90,7 @@ void state_nano(struct snapraid_state* state)
if (ret != 0) {
/* LCOV_EXCL_START */
close(f);
msg_error("Error timing file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error timing file '%s'. %s.\n", path, strerror(errno));
continue;
/* LCOV_EXCL_STOP */
}
@ -102,7 +102,7 @@ void state_nano(struct snapraid_state* state)
if (ret == -1) {
/* LCOV_EXCL_START */
close(f);
msg_error("Error accessing file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error accessing file '%s'. %s.\n", path, strerror(errno));
continue;
/* LCOV_EXCL_STOP */
}
@ -111,7 +111,7 @@ void state_nano(struct snapraid_state* state)
ret = close(f);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno));
continue;
/* LCOV_EXCL_STOP */
}
@ -125,7 +125,7 @@ void state_nano(struct snapraid_state* state)
/* state changed, we need to update it */
state->need_write = 1;
msg_tag("nano:%s:%s\n", disk->name, esc(file->sub));
log_tag("nano:%s:%s\n", disk->name, esc(file->sub));
msg_info("nano %s%s\n", disk->dir, file->sub);
}
}

View file

@ -135,14 +135,13 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
if (file->blockmax > 0) {
if (file->blockvec[file->blockmax - 1].parity_pos >= blockalloc) {
msg_tag("outofparity:%s:%s\n", disk->name, esc(file->sub));
log_tag("outofparity:%s:%s\n", disk->name, esc(file->sub));
if (first) {
first = 0;
msg_error("\nYour data requires more parity than the available space.\n");
msg_error("Please move the files 'outofparity' to another data disk:\n");
log_fatal("\nYour data requires more parity than the available space.\n");
log_fatal("Please move the files 'outofparity' to another data disk:\n");
}
msg_error("outofparity %s%s\n", disk->dir, file->sub);
msg_flush();
log_fatal("outofparity %s%s\n", disk->dir, file->sub);
}
}
}
@ -164,7 +163,7 @@ int parity_create(struct snapraid_parity_handle* parity, const char* path, data_
parity->f = open(parity->path, flags, 0600);
if (parity->f == -1) {
/* LCOV_EXCL_START */
msg_error("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -173,7 +172,7 @@ int parity_create(struct snapraid_parity_handle* parity, const char* path, data_
ret = fstat(parity->f, &parity->st);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
goto bail;
/* LCOV_EXCL_STOP */
}
@ -184,7 +183,7 @@ int parity_create(struct snapraid_parity_handle* parity, const char* path, data_
ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
log_fatal("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
goto bail;
/* LCOV_EXCL_STOP */
}
@ -260,7 +259,7 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
ret = fstat(parity->f, &parity->st);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
goto bail;
/* LCOV_EXCL_STOP */
}
@ -272,9 +271,9 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
if (f_ret != 0) {
/* LCOV_EXCL_START */
if (f_errno == ENOSPC) {
msg_error("Failed to grow parity file '%s' to size %" PRIu64 " using %s due lack of space.\n", parity->path, size, call);
log_fatal("Failed to grow parity file '%s' to size %" PRIu64 " using %s due lack of space.\n", parity->path, size, call);
} else {
msg_error("Error growing parity file '%s' to size %" PRIu64 " using %s. Do you have enough space? %s.\n", parity->path, size, call, strerror(f_errno));
log_fatal("Error growing parity file '%s' to size %" PRIu64 " using %s. Do you have enough space? %s.\n", parity->path, size, call, strerror(f_errno));
}
goto bail;
/* LCOV_EXCL_STOP */
@ -294,7 +293,7 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
ret = fstat(parity->f, &parity->st);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
goto bail;
/* LCOV_EXCL_STOP */
}
@ -305,7 +304,7 @@ int parity_chsize(struct snapraid_parity_handle* parity, data_off_t size, data_o
/* now check the error */
if (f_ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", parity->path, size, strerror(f_errno));
log_fatal("Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", parity->path, size, strerror(f_errno));
goto bail;
/* LCOV_EXCL_STOP */
}
@ -338,7 +337,7 @@ int parity_open(struct snapraid_parity_handle* parity, const char* path, int mod
flags |= O_SEQUENTIAL;
parity->f = open_noatime(parity->path, flags);
if (parity->f == -1) {
msg_error("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
return -1;
}
@ -346,7 +345,7 @@ int parity_open(struct snapraid_parity_handle* parity, const char* path, int mod
ret = fstat(parity->f, &parity->st);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
goto bail;
/* LCOV_EXCL_STOP */
}
@ -360,7 +359,7 @@ int parity_open(struct snapraid_parity_handle* parity, const char* path, int mod
ret = posix_fadvise(parity->f, 0, 0, POSIX_FADV_SEQUENTIAL);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
log_fatal("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
goto bail;
/* LCOV_EXCL_STOP */
}
@ -389,7 +388,7 @@ int parity_sync(struct snapraid_parity_handle* parity)
ret = fsync(parity->f);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error synching parity file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error synching parity file '%s'. %s.\n", parity->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -412,7 +411,7 @@ int parity_close(struct snapraid_parity_handle* parity)
/* This is a serious error, as it may be the result of a failed write */
/* identified at later time. */
/* In a normal filesystem (not NFS) it should never happen */
msg_error("Error closing parity file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error closing parity file '%s'. %s.\n", parity->path, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -437,9 +436,9 @@ int parity_write(struct snapraid_parity_handle* parity, block_off_t pos, unsigne
if (lseek(parity->f, offset, SEEK_SET) != offset) {
/* LCOV_EXCL_START */
if (errno == ENOSPC) {
msg_error("Failed to grow parity file '%s' using lseek due lack of space.\n", parity->path);
log_fatal("Failed to grow parity file '%s' using lseek due lack of space.\n", parity->path);
} else {
msg_error("Error seeking file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error seeking file '%s'. %s.\n", parity->path, strerror(errno));
}
return -1;
/* LCOV_EXCL_STOP */
@ -450,9 +449,9 @@ int parity_write(struct snapraid_parity_handle* parity, block_off_t pos, unsigne
if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */
/* LCOV_EXCL_START */
if (errno == ENOSPC) {
msg_error("Failed to grow parity file '%s' using write due lack of space.\n", parity->path);
log_fatal("Failed to grow parity file '%s' using write due lack of space.\n", parity->path);
} else {
msg_error("Error writing file '%s'. %s.\n", parity->path, strerror(errno));
log_fatal("Error writing file '%s'. %s.\n", parity->path, strerror(errno));
}
return -1;
/* LCOV_EXCL_STOP */

View file

@ -33,7 +33,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
d = opendir(dir);
if (!d) {
/* LCOV_EXCL_START */
msg_error("Error opening pool directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error opening pool directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -49,7 +49,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
dd = readdir(d);
if (dd == 0 && errno != 0) {
/* LCOV_EXCL_START */
msg_error("Error reading pool directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error reading pool directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -73,7 +73,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
if (st.st_mode == 0) {
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -82,7 +82,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
/* get lstat info about the file */
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -95,7 +95,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
ret = remove(path_next);
if (ret < 0) {
/* LCOV_EXCL_START */
msg_error("Error removing symlink '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error removing symlink '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -113,13 +113,13 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
/* in Windows just ignore EACCES errors removing directories */
/* because it could happen that the directory is in use */
/* and it cannot be removed */
msg_error("Directory '%s' not removed because it's in use.\n", path_next);
log_fatal("Directory '%s' not removed because it's in use.\n", path_next);
ignored = 1;
} else
#endif
{
/* LCOV_EXCL_START */
msg_error("Error removing pool directory '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error removing pool directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -136,7 +136,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
if (closedir(d) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -181,17 +181,17 @@ static void make_link(const char* pool_dir, const char* share_dir, struct snapra
ret = symlink(linkto_exported, path);
if (ret != 0) {
if (errno == EEXIST) {
msg_error("WARNING! Duplicate pooling for '%s'\n", path);
log_fatal("WARNING! Duplicate pooling for '%s'\n", path);
#ifdef _WIN32
} else if (errno == EPERM) {
/* LCOV_EXCL_START */
msg_error("You must run as Adminstrator to be able to create symlinks.\n");
log_fatal("You must run as Adminstrator to be able to create symlinks.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
#endif
} else {
/* LCOV_EXCL_START */
msg_error("Error writing symlink '%s'. %s.\n", path, strerror(errno));
log_fatal("Error writing symlink '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -207,7 +207,7 @@ void state_pool(struct snapraid_state* state)
if (state->pool[0] == 0) {
/* LCOV_EXCL_START */
msg_error("To use the 'pool' command you must set the pool directory in the configuration file\n");
log_fatal("To use the 'pool' command you must set the pool directory in the configuration file\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -255,8 +255,8 @@ void state_pool(struct snapraid_state* state)
else
msg_status("No link created\n");
msg_tag("summary:link_count::%u\n", count);
msg_tag("summary:exit:ok\n");
msg_flush();
log_tag("summary:link_count::%u\n", count);
log_tag("summary:exit:ok\n");
log_flush();
}

View file

@ -38,14 +38,14 @@ void state_rehash(struct snapraid_state* state)
/* check if a rehash is already in progress */
if (state->prevhash != HASH_UNDEFINED) {
/* LCOV_EXCL_START */
msg_error("You already have a rehash in progress.\n");
log_fatal("You already have a rehash in progress.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (state->hash == state->besthash) {
/* LCOV_EXCL_START */
msg_error("You are already using the best hash for your platform.\n");
log_fatal("You are already using the best hash for your platform.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -58,7 +58,7 @@ void state_rehash(struct snapraid_state* state)
state->hash = state->besthash;
if (randomize(state->hashseed, HASH_SIZE) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to get random values.\n");
log_fatal("Failed to get random values.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -76,7 +76,7 @@ void state_rehash(struct snapraid_state* state)
if (info_get_rehash(info)) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency for a rehash already in progress\n");
log_fatal("Internal inconsistency for a rehash already in progress\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -95,7 +95,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
/* check if multiple files have the same name */
if (link_flag_has(link, FILE_IS_PRESENT)) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency for link '%s%s'\n", disk->dir, sub);
log_fatal("Internal inconsistency for link '%s%s'\n", disk->dir, sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -109,7 +109,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
++scan->count_equal;
if (state->opt.gui) {
msg_tag("scan:equal:%s:%s\n", disk->name, esc(link->sub));
log_tag("scan:equal:%s:%s\n", disk->name, esc(link->sub));
}
} else {
/* it's an update */
@ -119,7 +119,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
++scan->count_change;
msg_tag("scan:update:%s:%s\n", disk->name, esc(link->sub));
log_tag("scan:update:%s:%s\n", disk->name, esc(link->sub));
if (is_diff) {
printf("update %s%s\n", disk->dir, link->sub);
}
@ -136,7 +136,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
/* create the new link */
++scan->count_insert;
msg_tag("scan:add:%s:%s\n", disk->name, esc(sub));
log_tag("scan:add:%s:%s\n", disk->name, esc(sub));
if (is_diff) {
printf("add %s%s\n", disk->dir, sub);
}
@ -214,7 +214,7 @@ static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_fil
break;
default :
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in deallocating for block %u state %u\n", block->parity_pos, block_state);
log_fatal("Internal inconsistency in deallocating for block %u state %u\n", block->parity_pos, block_state);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -306,7 +306,7 @@ static void scan_file_delayed_insert(struct snapraid_scan* scan, struct snapraid
if (filephy(path_next, file->size, &file->physical) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in getting the physical offset of file '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in getting the physical offset of file '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -348,7 +348,7 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc
if (lstat_sync(path_next, &synced_st, physical) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -366,8 +366,8 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc
* Why is the file size reported incorrectly for files that are still being written to?
* http://blogs.msdn.com/b/oldnewthing/archive/2011/12/26/10251026.aspx
*/
msg_error("WARNING! Detected uncached time change for file '%s'\n", sub);
msg_error("It's better if you run SnapRAID without other processes running.\n");
log_fatal("WARNING! Detected uncached time change for file '%s'\n", sub);
log_fatal("It's better if you run SnapRAID without other processes running.\n");
#endif
st->st_mtime = synced_st.st_mtime;
st->st_mtimensec = synced_st.st_mtimensec;
@ -375,15 +375,15 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc
if (st->st_size != synced_st.st_size) {
#ifndef _WIN32
msg_error("WARNING! Detected uncached size change for file '%s'\n", sub);
msg_error("It's better if you run SnapRAID without other processes running.\n");
log_fatal("WARNING! Detected uncached size change for file '%s'\n", sub);
log_fatal("It's better if you run SnapRAID without other processes running.\n");
#endif
st->st_size = synced_st.st_size;
}
if (st->st_ino != synced_st.st_ino) {
msg_error("DANGER! Detected uncached inode change for file '%s'\n", sub);
msg_error("Please ensure to run SnapRAID without other processes running.\n");
log_fatal("DANGER! Detected uncached inode change for file '%s'\n", sub);
log_fatal("Please ensure to run SnapRAID without other processes running.\n");
/* at this point, it's too late to change inode */
/* and having inconsistent inodes may result to internal failures */
/* so, it's better to abort */
@ -611,7 +611,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
#if HAVE_STRUCT_STAT_ST_NLINK
if (st->st_nlink <= 1) {
/* LCOV_EXCL_START */
msg_error("Internal inode '%" PRIu64 "' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub);
log_fatal("Internal inode '%" PRIu64 "' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -639,7 +639,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* if the path is different, it means a moved file with the same inode */
++scan->count_move;
msg_tag("scan:move:%s:%s:%s\n", disk->name, esc(file->sub), esc(sub));
log_tag("scan:move:%s:%s:%s\n", disk->name, esc(file->sub), esc(sub));
if (is_diff) {
printf("move %s%s -> %s%s\n", disk->dir, file->sub, disk->dir, sub);
}
@ -660,7 +660,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
++scan->count_equal;
if (state->opt.gui) {
msg_tag("scan:equal:%s:%s\n", disk->name, esc(file->sub));
log_tag("scan:equal:%s:%s\n", disk->name, esc(file->sub));
}
}
@ -679,7 +679,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* for sure it cannot be already present */
if (file_flag_has(file, FILE_IS_PRESENT)) {
/* LCOV_EXCL_START */
msg_error("Internal inode '%" PRIu64 "' inconsistency for files '%s%s' and '%s%s' matching and already present but different\n", file->inode, disk->dir, sub, disk->dir, file->sub);
log_fatal("Internal inode '%" PRIu64 "' inconsistency for files '%s%s' and '%s%s' matching and already present but different\n", file->inode, disk->dir, sub, disk->dir, file->sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -729,7 +729,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* here the inode has to be different, otherwise we would have found it before */
if (file->inode == st->st_ino) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub);
log_fatal("Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -738,7 +738,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* for sure it cannot be already present */
if (file_flag_has(file, FILE_IS_PRESENT)) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub);
log_fatal("Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -776,7 +776,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* like when restoring a backup that restores also the timestamp */
++scan->count_restore;
msg_tag("scan:restore:%s:%s\n", disk->name, esc(sub));
log_tag("scan:restore:%s:%s\n", disk->name, esc(sub));
if (is_diff) {
printf("restore %s%s\n", disk->dir, sub);
}
@ -799,7 +799,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
++scan->count_equal;
if (state->opt.gui) {
msg_tag("scan:equal:%s:%s\n", disk->name, esc(file->sub));
log_tag("scan:equal:%s:%s\n", disk->name, esc(file->sub));
}
}
@ -831,11 +831,11 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
if (is_original_file_size_different_than_zero && st->st_size == 0) {
if (!state->opt.force_zero) {
/* LCOV_EXCL_START */
msg_error("The file '%s%s' has unexpected zero size!\n", disk->dir, sub);
msg_error("It's possible that after a kernel crash this file was lost,\n");
msg_error("and you can use 'snapraid --filter %s fix' to recover it.\n", sub);
log_fatal("The file '%s%s' has unexpected zero size!\n", disk->dir, sub);
log_fatal("It's possible that after a kernel crash this file was lost,\n");
log_fatal("and you can use 'snapraid --filter %s fix' to recover it.\n", sub);
if (!is_diff) {
msg_error("If this an expected condition you can '%s' anyway using 'snapraid --force-zero %s'\n", state->command, state->command);
log_fatal("If this an expected condition you can '%s' anyway using 'snapraid --force-zero %s'\n", state->command, state->command);
exit(EXIT_FAILURE);
}
/* LCOV_EXCL_STOP */
@ -876,7 +876,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* revert old counter and use the copy one */
++scan->count_copy;
msg_tag("scan:copy:%s:%s:%s:%s\n", other_disk->name, esc(other_file->sub), disk->name, esc(file->sub));
log_tag("scan:copy:%s:%s:%s:%s\n", other_disk->name, esc(other_file->sub), disk->name, esc(file->sub));
if (is_diff) {
printf("copy %s%s -> %s%s\n", other_disk->dir, other_file->sub, disk->dir, file->sub);
}
@ -895,14 +895,14 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
if (is_file_already_present) {
++scan->count_change;
msg_tag("scan:update:%s:%s\n", disk->name, esc(sub));
log_tag("scan:update:%s:%s\n", disk->name, esc(sub));
if (is_diff) {
printf("update %s%s\n", disk->dir, sub);
}
} else {
++scan->count_insert;
msg_tag("scan:add:%s:%s\n", disk->name, esc(sub));
log_tag("scan:add:%s:%s\n", disk->name, esc(sub));
if (is_diff) {
printf("add %s%s\n", disk->dir, sub);
}
@ -967,7 +967,7 @@ static void scan_emptydir(struct snapraid_scan* scan, const char* sub)
/* check if multiple files have the same name */
if (dir_flag_has(dir, FILE_IS_PRESENT)) {
/* LCOV_EXCL_START */
msg_error("Internal inconsistency for dir '%s%s'\n", disk->dir, sub);
log_fatal("Internal inconsistency for dir '%s%s'\n", disk->dir, sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1045,7 +1045,7 @@ struct stat* dstat(const char* file, struct stat* st)
{
if (lstat(file, st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file/directory '%s'. %s.\n", file, strerror(errno));
log_fatal("Error in stat file/directory '%s'. %s.\n", file, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1071,8 +1071,8 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
d = opendir(dir);
if (!d) {
/* LCOV_EXCL_START */
msg_error("Error opening directory '%s'. %s.\n", dir, strerror(errno));
msg_error("You can exclude it in the config file with:\n\texclude /%s\n", sub);
log_fatal("Error opening directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("You can exclude it in the config file with:\n\texclude /%s\n", sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1091,8 +1091,8 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
dd = readdir(d);
if (dd == 0 && errno != 0) {
/* LCOV_EXCL_START */
msg_error("Error reading directory '%s'. %s.\n", dir, strerror(errno));
msg_error("You can exclude it in the config file with:\n\texclude /%s\n", sub);
log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("You can exclude it in the config file with:\n\texclude /%s\n", sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1111,7 +1111,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
/* check for not supported file names */
if (name[0] == 0) {
/* LCOV_EXCL_START */
msg_error("Unsupported name '%s' in file '%s'.\n", name, path_next);
log_fatal("Unsupported name '%s' in file '%s'.\n", name, path_next);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1152,7 +1152,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
if (closedir(d) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error closing directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1219,7 +1219,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
if (st->st_mode == 0) {
if (lstat(path_next, st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1249,7 +1249,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
if (st->st_ino == 0) {
if (lstat_sync(path_next, st, 0) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1269,13 +1269,13 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
ret = readlink(path_next, subnew, sizeof(subnew));
if (ret >= PATH_MAX) {
/* LCOV_EXCL_START */
msg_error("Error in readlink file '%s'. Symlink too long.\n", path_next);
log_fatal("Error in readlink file '%s'. Symlink too long.\n", path_next);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (ret < 0) {
/* LCOV_EXCL_START */
msg_error("Error in readlink file '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in readlink file '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1299,7 +1299,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
/* in Unix don't follow mount points in different devices */
/* in Windows we are already skipping them reporting them as special files */
if ((uint64_t)st->st_dev != disk->device) {
msg_error("WARNING! Ignoring mount point '%s' because it appears to be in a different device\n", path_next);
log_fatal("WARNING! Ignoring mount point '%s' because it appears to be in a different device\n", path_next);
} else
#endif
{
@ -1325,7 +1325,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
if (!st)
st = DSTAT(path_next, dd, &st_buf);
msg_error("WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next);
log_fatal("WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next);
} else {
msg_verbose("Excluding special file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
}
@ -1387,7 +1387,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
ret = fsinfo(disk->dir, &has_persistent_inode, 0, 0);
if (ret < 0) {
/* LCOV_EXCL_START */
msg_error("Error accessing disk '%s' to get filesystem info. %s.\n", disk->dir, strerror(errno));
log_fatal("Error accessing disk '%s' to get filesystem info. %s.\n", disk->dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1447,7 +1447,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
if (!file_flag_has(file, FILE_IS_PRESENT)) {
++scan->count_remove;
msg_tag("scan:remove:%s:%s\n", disk->name, esc(file->sub));
log_tag("scan:remove:%s:%s\n", disk->name, esc(file->sub));
if (is_diff) {
printf("remove %s%s\n", disk->dir, file->sub);
}
@ -1468,7 +1468,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
if (!link_flag_has(link, FILE_IS_PRESENT)) {
++scan->count_remove;
msg_tag("scan:remove:%s:%s\n", disk->name, esc(link->sub));
log_tag("scan:remove:%s:%s\n", disk->name, esc(link->sub));
if (is_diff) {
printf("remove %s%s\n", disk->dir, link->sub);
}
@ -1529,7 +1529,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
/* if verbose, prints the list of duplicates real offsets */
/* other cases are for offsets not supported, so we don't need to report them file by file */
if (phy_last >= FILEPHY_REAL_OFFSET) {
msg_error("WARNING! Files '%s%s' and '%s%s' have the same physical offset %" PRId64 ".\n", disk->dir, phy_file_last->sub, disk->dir, file->sub, phy_last);
log_fatal("WARNING! Files '%s%s' and '%s%s' have the same physical offset %" PRId64 ".\n", disk->dir, phy_file_last->sub, disk->dir, file->sub, phy_last);
}
++phy_dup;
}
@ -1586,20 +1586,20 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
if (scan->count_equal == 0 && scan->count_move == 0 && scan->count_restore == 0 && (scan->count_remove != 0 || scan->count_change != 0)) {
if (!done) {
done = 1;
msg_error("WARNING! All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir);
log_fatal("WARNING! All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir);
} else {
msg_error(", disk '%s' at dir '%s'", disk->name, disk->dir);
log_fatal(", disk '%s' at dir '%s'", disk->name, disk->dir);
}
}
}
if (done) {
msg_error("\nare now missing or rewritten!\n");
msg_error("This could happen when deleting all the files from a disk,\n");
msg_error("and restoring them with a program that it's not setting\n");
msg_error("correctly the timestamps.\n");
msg_error("It's also possible that you have some disks not mounted.\n");
log_fatal("\nare now missing or rewritten!\n");
log_fatal("This could happen when deleting all the files from a disk,\n");
log_fatal("and restoring them with a program that it's not setting\n");
log_fatal("correctly the timestamps.\n");
log_fatal("It's also possible that you have some disks not mounted.\n");
if (!is_diff) {
msg_error("If you want to '%s' anyway, use 'snapraid --force-empty %s'.", state->command, state->command);
log_fatal("If you want to '%s' anyway, use 'snapraid --force-empty %s'.", state->command, state->command);
exit(EXIT_FAILURE);
}
}
@ -1614,14 +1614,14 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
if (disk->has_unreliable_physical) {
if (!done) {
done = 1;
msg_error("WARNING! Physical offsets not supported for disk '%s'", disk->name);
log_fatal("WARNING! Physical offsets not supported for disk '%s'", disk->name);
} else {
msg_error(", '%s'", disk->name);
log_fatal(", '%s'", disk->name);
}
}
}
if (done) {
msg_error(". Files order won't be optimal.\n");
log_fatal(". Files order won't be optimal.\n");
}
}
@ -1633,14 +1633,14 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
if (disk->has_volatile_inodes) {
if (!done) {
done = 1;
msg_error("WARNING! Inodes are not persistent for disks: '%s'", disk->name);
log_fatal("WARNING! Inodes are not persistent for disks: '%s'", disk->name);
} else {
msg_error(", '%s'", disk->name);
log_fatal(", '%s'", disk->name);
}
}
}
if (done) {
msg_error(". Move operations won't be optimal.\n");
log_fatal(". Move operations won't be optimal.\n");
}
/* checks for disks with changed UUID */
@ -1655,14 +1655,14 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
if (disk->has_different_uuid && !disk->had_empty_uuid) {
if (!done) {
done = 1;
msg_error("WARNING! UUID is changed for disks: '%s'", disk->name);
log_fatal("WARNING! UUID is changed for disks: '%s'", disk->name);
} else {
msg_error(", '%s'", disk->name);
log_fatal(", '%s'", disk->name);
}
}
}
if (done) {
msg_error(". Move operations won't be optimal.\n");
log_fatal(". Move operations won't be optimal.\n");
}
/* checks for disks with unsupported UUID */
@ -1673,14 +1673,14 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
if (disk->has_unsupported_uuid) {
if (!done) {
done = 1;
msg_error("WARNING! UUID is unsupported for disks: '%s'", disk->name);
log_fatal("WARNING! UUID is unsupported for disks: '%s'", disk->name);
} else {
msg_error(", '%s'", disk->name);
log_fatal(", '%s'", disk->name);
}
}
}
if (done) {
msg_error(". Move operations won't be optimal.\n");
log_fatal(". Move operations won't be optimal.\n");
}
total.count_equal = 0;
@ -1717,13 +1717,13 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
msg("%8u removed\n", total.count_remove);
msg("%8u added\n", total.count_insert);
msg_tag("summary:equal:%u\n", total.count_equal);
msg_tag("summary:moved:%u\n", total.count_move);
msg_tag("summary:copied:%u\n", total.count_copy);
msg_tag("summary:restored:%u\n", total.count_restore);
msg_tag("summary:updated:%u\n", total.count_change);
msg_tag("summary:removed:%u\n", total.count_remove);
msg_tag("summary:added:%u\n", total.count_insert);
log_tag("summary:equal:%u\n", total.count_equal);
log_tag("summary:moved:%u\n", total.count_move);
log_tag("summary:copied:%u\n", total.count_copy);
log_tag("summary:restored:%u\n", total.count_restore);
log_tag("summary:updated:%u\n", total.count_change);
log_tag("summary:removed:%u\n", total.count_remove);
log_tag("summary:added:%u\n", total.count_insert);
no_difference = !total.count_move && !total.count_copy && !total.count_restore
&& !total.count_change && !total.count_remove && !total.count_insert;
@ -1737,11 +1737,11 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
}
if (no_difference) {
msg_tag("summary:exit:equal\n");
log_tag("summary:exit:equal\n");
} else {
msg_tag("summary:exit:diff\n");
log_tag("summary:exit:diff\n");
}
msg_flush();
log_flush();
tommy_list_foreach(&scanlist, (tommy_foreach_func*)free);

View file

@ -228,40 +228,40 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
/* This one is really an unexpected error, because we are only reading */
/* and closing a descriptor should never fail */
if (errno == EIO) {
msg_tag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected input/output close error in a data disk, it isn't possible to scrub.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected input/output close error in a data disk, it isn't possible to scrub.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
}
msg_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("WARNING! Unexpected close error in a data disk, it isn't possible to scrub.\n");
msg_error("Ensure that file '%s' can be accessed.\n", handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("WARNING! Unexpected close error in a data disk, it isn't possible to scrub.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle[j].path);
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
}
}
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, msg_warning, 0);
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, log_error, 0);
if (ret == -1) {
/* file we have tried to open for error reporting */
struct snapraid_file* file = block_file_get(block);
if (errno == EIO) {
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected input/output open error in a data disk, it isn't possible to scrub.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected input/output open error in a data disk, it isn't possible to scrub.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_tag("error:%u:%s:%s: Open error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_tag("error:%u:%s:%s: Open error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
++error;
error_on_this_block = 1;
continue;
@ -283,29 +283,29 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
/* from the last sync, as we are expected to return errors if running */
/* in an unsynced array. This is just like the check command. */
read_size = handle_read(&handle[j], block, buffer[j], state->block_size, msg_warning, 0);
read_size = handle_read(&handle[j], block, buffer[j], state->block_size, log_error, 0);
if (read_size == -1) {
/* file we are processing for error reporting */
struct snapraid_file* file = block_file_get(block);
if (errno == EIO) {
msg_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
if (io_error >= state->opt.io_error_limit) {
/* LCOV_EXCL_START */
msg_error("DANGER! Too many input/output read error in a data disk, it isn't possible to scrub.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_fatal("DANGER! Too many input/output read error in a data disk, it isn't possible to scrub.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_warning("Input/Output error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
log_error("Input/Output error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
++io_error;
io_error_on_this_block = 1;
continue;
}
msg_tag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
log_tag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
++error;
error_on_this_block = 1;
continue;
@ -330,14 +330,14 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
if (block_has_updated_hash(block)) {
/* compare the hash */
if (memcmp(hash, block->hash, HASH_SIZE) != 0) {
msg_tag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, esc(handle[j].file->sub), block_file_pos(block));
log_tag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, esc(handle[j].file->sub), block_file_pos(block));
/* it's a silent error only if we are dealing with synced files */
if (file_is_unsynced) {
++error;
error_on_this_block = 1;
} else {
msg_warning("Data error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
log_error("Data error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
++silent_error;
silent_error_on_this_block = 1;
}
@ -361,29 +361,29 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
/* read the parity */
for (l = 0; l < state->level; ++l) {
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, msg_warning);
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, log_error);
if (ret == -1) {
buffer_recov[l] = 0;
if (errno == EIO) {
msg_tag("parity_error:%u:%s: Read EIO error. %s\n", i, lev_config_name(l), strerror(errno));
log_tag("parity_error:%u:%s: Read EIO error. %s\n", i, lev_config_name(l), strerror(errno));
if (io_error >= state->opt.io_error_limit) {
/* LCOV_EXCL_START */
msg_error("DANGER! Too many input/output read error in the %s disk, it isn't possible to scrub.\n", lev_name(l));
msg_error("Ensure that disk '%s' is sane and can be read.\n", lev_config_name(l));
msg_error("Stopping at block %u\n", i);
log_fatal("DANGER! Too many input/output read error in the %s disk, it isn't possible to scrub.\n", lev_name(l));
log_fatal("Ensure that disk '%s' is sane and can be read.\n", lev_config_name(l));
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
/* LCOV_EXCL_STOP */
}
msg_warning("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
log_error("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
++io_error;
io_error_on_this_block = 1;
continue;
}
msg_tag("parity_error:%u:%s: Read error. %s\n", i, lev_config_name(l), strerror(errno));
log_tag("parity_error:%u:%s: Read error. %s\n", i, lev_config_name(l), strerror(errno));
++error;
error_on_this_block = 1;
continue;
@ -399,14 +399,14 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
/* compare the parity */
for (l = 0; l < state->level; ++l) {
if (buffer_recov[l] && memcmp(buffer[diskmax + l], buffer_recov[l], state->block_size) != 0) {
msg_tag("parity_error:%u:%s: Data error\n", i, lev_config_name(l));
log_tag("parity_error:%u:%s: Data error\n", i, lev_config_name(l));
/* it's a silent error only if we are dealing with synced blocks */
if (block_is_unsynced) {
++error;
error_on_this_block = 1;
} else {
msg_error("Data error in parity '%s' at position '%u'\n", lev_config_name(l), i);
log_fatal("Data error in parity '%s' at position '%u'\n", lev_config_name(l), i);
++silent_error;
silent_error_on_this_block = 1;
}
@ -486,24 +486,24 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
}
if (error)
msg_error("WARNING! Unexpected file errors!\n");
log_fatal("WARNING! Unexpected file errors!\n");
if (io_error)
msg_error("DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
log_fatal("DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
if (silent_error)
msg_error("DANGER! Unexpected data errors! The failing blocks are now marked as bad!\n");
log_fatal("DANGER! Unexpected data errors! The failing blocks are now marked as bad!\n");
if (io_error || silent_error) {
msg_error("Use 'snapraid status' to list the bad blocks.\n");
msg_error("Use 'snapraid -e fix' to recover.\n");
log_fatal("Use 'snapraid status' to list the bad blocks.\n");
log_fatal("Use 'snapraid -e fix' to recover.\n");
}
msg_tag("summary:error_file:%u\n", error);
msg_tag("summary:error_io:%u\n", io_error);
msg_tag("summary:error_data:%u\n", silent_error);
log_tag("summary:error_file:%u\n", error);
log_tag("summary:error_io:%u\n", io_error);
log_tag("summary:error_data:%u\n", silent_error);
if (error + silent_error + io_error == 0)
msg_tag("summary:exit:ok\n");
log_tag("summary:exit:ok\n");
else
msg_tag("summary:exit:error\n");
msg_flush();
log_tag("summary:exit:error\n");
log_flush();
bail:
for (j = 0; j < diskmax; ++j) {
@ -512,8 +512,8 @@ bail:
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected close error in a data disk.\n");
log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected close error in a data disk.\n");
++error;
/* continue, as we are already exiting */
/* LCOV_EXCL_STOP */
@ -602,7 +602,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
/* copy the info in the temp vector */
count = 0;
msg_tag("block_count:%u\n", blockmax);
log_tag("block_count:%u\n", blockmax);
for (i = 0; i < blockmax; ++i) {
snapraid_info info = info_get(&state->infoarr, i);
@ -615,7 +615,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
if (!count) {
/* LCOV_EXCL_START */
msg_error("The array appears to be empty.\n");
log_fatal("The array appears to be empty.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -625,12 +625,12 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
/* output the info map */
i = 0;
msg_tag("info_count:%u\n", count);
log_tag("info_count:%u\n", count);
while (i < count) {
unsigned j = i + 1;
while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j]))
++j;
msg_tag("info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
log_tag("info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
i = j;
}
@ -658,9 +658,9 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
lastlimit = 0;
}
msg_tag("count_limit:%u\n", countlimit);
msg_tag("time_limit:%" PRIu64 "\n", (uint64_t)timelimit);
msg_tag("last_limit:%u\n", lastlimit);
log_tag("count_limit:%u\n", countlimit);
log_tag("time_limit:%" PRIu64 "\n", (uint64_t)timelimit);
log_tag("last_limit:%u\n", lastlimit);
/* free the temp vector */
free(infomap);
@ -671,7 +671,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
ret = parity_open(parity_ptr[l], state->parity[l].path, state->file_mode);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("WARNING! Without an accessible %s file, it isn't possible to scrub.\n", lev_name(l));
log_fatal("WARNING! Without an accessible %s file, it isn't possible to scrub.\n", lev_name(l));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -691,7 +691,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
ret = parity_close(parity_ptr[l]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
log_fatal("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
++error;
/* continue, as we are already exiting */
/* LCOV_EXCL_STOP */

View file

@ -79,14 +79,14 @@ int search_file_compare(const void* void_arg, const void* void_data)
f = open(path, O_RDONLY | O_BINARY);
if (f == -1) {
/* LCOV_EXCL_START */
msg_error("Error opening file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (lseek(f, arg->offset, SEEK_SET) != arg->offset) {
/* LCOV_EXCL_START */
msg_error("Error seeking file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error seeking file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -94,7 +94,7 @@ int search_file_compare(const void* void_arg, const void* void_data)
ret = read(f, arg->buffer, arg->read_size);
if (ret < 0 || (unsigned)ret != arg->read_size) {
/* LCOV_EXCL_START */
msg_error("Error reading file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error reading file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -102,7 +102,7 @@ int search_file_compare(const void* void_arg, const void* void_data)
ret = close(f);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -157,7 +157,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
d = opendir(dir);
if (!d) {
/* LCOV_EXCL_START */
msg_error("Error opening directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error opening directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -176,7 +176,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
dd = readdir(d);
if (dd == 0 && errno != 0) {
/* LCOV_EXCL_START */
msg_error("Error reading directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -216,7 +216,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
if (st.st_mode == 0) {
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -225,7 +225,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
/* get lstat info about the file */
if (lstat(path_next, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -250,7 +250,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
if (closedir(d) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error closing directory '%s'. %s.\n", dir, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -160,7 +160,7 @@ static void test_hash(void)
digest = tommy_hash_u32(seed32, buffer_aligned, TEST_MURMUR3[i].len);
if (digest != TEST_HASH32[i].digest) {
/* LCOV_EXCL_START */
msg_error("Failed hash32 test\n");
log_fatal("Failed hash32 test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -172,7 +172,7 @@ static void test_hash(void)
digest = tommy_hash_u64(seed64, buffer_aligned, TEST_MURMUR3[i].len);
if (digest != TEST_HASH64[i].digest) {
/* LCOV_EXCL_START */
msg_error("Failed hash64 test\n");
log_fatal("Failed hash64 test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -185,7 +185,7 @@ static void test_hash(void)
memhash(HASH_MURMUR3, seed_aligned, digest, buffer_aligned, TEST_MURMUR3[i].len);
if (memcmp(digest, TEST_MURMUR3[i].digest, HASH_SIZE) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed Murmur3 test\n");
log_fatal("Failed Murmur3 test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -197,7 +197,7 @@ static void test_hash(void)
memhash(HASH_SPOOKY2, seed_aligned, digest, buffer_aligned, TEST_SPOOKY2[i].len);
if (memcmp(digest, TEST_SPOOKY2[i].digest, HASH_SIZE) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed Spooky2 test\n");
log_fatal("Failed Spooky2 test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -246,7 +246,7 @@ static void test_crc32c(void)
digest = crc32c(0, (const unsigned char*)TEST_CRC32C[i].data, TEST_CRC32C[i].len);
if (digest != TEST_CRC32C[i].digest) {
/* LCOV_EXCL_START */
msg_error("Failed CRC32C test\n");
log_fatal("Failed CRC32C test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -373,22 +373,22 @@ static void test_tommy(void)
return;
bail:
/* LCOV_EXCL_START */
msg_error("Failed tommy test\n");
log_fatal("Failed tommy test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
void selftest(void)
{
msg_tag("selftest:\n");
msg_flush();
log_tag("selftest:\n");
log_flush();
msg_progress("Self test...\n");
/* large file check */
if (sizeof(off_t) < sizeof(uint64_t)) {
/* LCOV_EXCL_START */
msg_error("Missing support for large files\n");
log_fatal("Missing support for large files\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -398,55 +398,55 @@ void selftest(void)
test_tommy();
if (raid_selftest() != 0) {
/* LCOV_EXCL_START */
msg_error("Failed SELF test\n");
log_fatal("Failed SELF test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_sort() != 0) {
/* LCOV_EXCL_START */
msg_error("Failed SORT test\n");
log_fatal("Failed SORT test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_insert() != 0) {
/* LCOV_EXCL_START */
msg_error("Failed INSERT test\n");
log_fatal("Failed INSERT test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_combo() != 0) {
/* LCOV_EXCL_START */
msg_error("Failed COMBO test\n");
log_fatal("Failed COMBO test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_par(RAID_MODE_VANDERMONDE, 32, 256) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed GEN Vandermonde test\n");
log_fatal("Failed GEN Vandermonde test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_rec(RAID_MODE_VANDERMONDE, 12, 256) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed REC Vandermonde test\n");
log_fatal("Failed REC Vandermonde test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_par(RAID_MODE_CAUCHY, 32, 256) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed GEN Cauchy test\n");
log_fatal("Failed GEN Cauchy test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_rec(RAID_MODE_CAUCHY, 12, 256) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed REC Cauchy test\n");
log_fatal("Failed REC Cauchy test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_par(RAID_MODE_CAUCHY, 1, 256) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed GEN Cauchy test sigle data disk\n");
log_fatal("Failed GEN Cauchy test sigle data disk\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -76,13 +76,13 @@ void usage(void)
void memory(void)
{
msg_tag("memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter());
log_tag("memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter());
/* size of the block + the size of the blockarr pointer to it */
msg_tag("memory:block:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_block) + sizeof(void*)));
log_tag("memory:block:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_block) + sizeof(void*)));
/* size of the file + the size of the 3 hashtables pointers to it, * 2 for the hashtable grow factor */
msg_tag("memory:file:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_file) + 3*2*sizeof(void*)));
log_tag("memory:file:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_file) + 3*2*sizeof(void*)));
msg_progress("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / (1024 * 1024)));
@ -154,7 +154,7 @@ void log_open(const char* log)
break;
default :
/* LCOV_EXCL_START */
msg_error("Invalid type specifier '%c' in the log file.\n", *log);
log_fatal("Invalid type specifier '%c' in the log file.\n", *log);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -169,7 +169,7 @@ void log_open(const char* log)
stdlog = fopen(path, mode);
if (!stdlog) {
/* LCOV_EXCL_START */
msg_error("Error opening the log file '%s'. %s.\n", path, strerror(errno));
log_fatal("Error opening the log file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -180,7 +180,7 @@ void log_close(const char* log)
if (stdlog != stdout && stdlog != stderr && stdlog != 0) {
if (fclose(stdlog) != 0) {
/* LCOV_EXCL_START */
msg_error("Error closing the log file '%s'. %s.\n", log, strerror(errno));
log_fatal("Error closing the log file '%s'. %s.\n", log, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -463,7 +463,7 @@ int main(int argc, char* argv[])
struct snapraid_filter* filter = filter_alloc_file(1, optarg);
if (!filter) {
/* LCOV_EXCL_START */
msg_error("Invalid filter specification '%s'\n", optarg);
log_fatal("Invalid filter specification '%s'\n", optarg);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -473,7 +473,7 @@ int main(int argc, char* argv[])
struct snapraid_filter* filter = filter_alloc_disk(1, optarg);
if (!filter) {
/* LCOV_EXCL_START */
msg_error("Invalid filter specification '%s'\n", optarg);
log_fatal("Invalid filter specification '%s'\n", optarg);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -494,7 +494,7 @@ int main(int argc, char* argv[])
percentage = strtoul(optarg, &e, 10);
if (!e || *e || percentage > 100) {
/* LCOV_EXCL_START */
msg_error("Invalid percentage '%s'\n", optarg);
log_fatal("Invalid percentage '%s'\n", optarg);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -503,7 +503,7 @@ int main(int argc, char* argv[])
olderthan = strtoul(optarg, &e, 10);
if (!e || *e || olderthan > 1000) {
/* LCOV_EXCL_START */
msg_error("Invalid number of days '%s'\n", optarg);
log_fatal("Invalid number of days '%s'\n", optarg);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -512,7 +512,7 @@ int main(int argc, char* argv[])
blockstart = strtoul(optarg, &e, 0);
if (!e || *e) {
/* LCOV_EXCL_START */
msg_error("Invalid start position '%s'\n", optarg);
log_fatal("Invalid start position '%s'\n", optarg);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -521,7 +521,7 @@ int main(int argc, char* argv[])
blockcount = strtoul(optarg, &e, 0);
if (!e || *e) {
/* LCOV_EXCL_START */
msg_error("Invalid count number '%s'\n", optarg);
log_fatal("Invalid count number '%s'\n", optarg);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -530,7 +530,7 @@ int main(int argc, char* argv[])
opt.io_error_limit = strtoul(optarg, &e, 0);
if (!e || *e) {
/* LCOV_EXCL_START */
msg_error("Invalid error limit number '%s'\n", optarg);
log_fatal("Invalid error limit number '%s'\n", optarg);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -538,7 +538,7 @@ int main(int argc, char* argv[])
case 'i' :
if (import_timestamp) {
/* LCOV_EXCL_START */
msg_error("Import directory '%s' already specified as '%s'\n", optarg, import_timestamp);
log_fatal("Import directory '%s' already specified as '%s'\n", optarg, import_timestamp);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -547,7 +547,7 @@ int main(int argc, char* argv[])
case OPT_TEST_IMPORT_CONTENT :
if (import_content) {
/* LCOV_EXCL_START */
msg_error("Import directory '%s' already specified as '%s'\n", optarg, import_content);
log_fatal("Import directory '%s' already specified as '%s'\n", optarg, import_content);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -556,7 +556,7 @@ int main(int argc, char* argv[])
case 'l' :
if (log) {
/* LCOV_EXCL_START */
msg_error("Log file '%s' already specified as '%s'\n", optarg, log);
log_fatal("Log file '%s' already specified as '%s'\n", optarg, log);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -696,7 +696,7 @@ int main(int argc, char* argv[])
break;
default :
/* LCOV_EXCL_START */
msg_error("Unknown option '%c'\n", (char)c);
log_fatal("Unknown option '%c'\n", (char)c);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -762,7 +762,7 @@ int main(int argc, char* argv[])
operation = OPERATION_SMART;
} else {
/* LCOV_EXCL_START */
msg_error("Unknown command '%s'\n", argv[optind]);
log_fatal("Unknown command '%s'\n", argv[optind]);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -774,7 +774,7 @@ int main(int argc, char* argv[])
default :
if (opt.auditonly) {
/* LCOV_EXCL_START */
msg_error("You cannot use -a, --audit-only with the '%s' command\n", command);
log_fatal("You cannot use -a, --audit-only with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -788,7 +788,7 @@ int main(int argc, char* argv[])
default :
if (opt.force_nocopy) {
/* LCOV_EXCL_START */
msg_error("You cannot use -N, --force-nocopy with the '%s' command\n", command);
log_fatal("You cannot use -N, --force-nocopy with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -800,14 +800,14 @@ int main(int argc, char* argv[])
default :
if (opt.prehash) {
/* LCOV_EXCL_START */
msg_error("You cannot use -h, --pre-hash with the '%s' command\n", command);
log_fatal("You cannot use -h, --pre-hash with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (opt.force_full) {
/* LCOV_EXCL_START */
msg_error("You cannot use -F, --force-full with the '%s' command\n", command);
log_fatal("You cannot use -F, --force-full with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -815,14 +815,14 @@ int main(int argc, char* argv[])
if (opt.force_full && opt.force_nocopy) {
/* LCOV_EXCL_START */
msg_error("You cannot use the -F, --force-full and -N, --force-nocopy options at the same time\n");
log_fatal("You cannot use the -F, --force-full and -N, --force-nocopy options at the same time\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (opt.prehash && opt.force_nocopy) {
/* LCOV_EXCL_START */
msg_error("You cannot use the -h, --pre-hash and -N, --force-nocopy options at the same time\n");
log_fatal("You cannot use the -h, --pre-hash and -N, --force-nocopy options at the same time\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -835,25 +835,25 @@ int main(int argc, char* argv[])
default :
if (!tommy_list_empty(&filterlist_file)) {
/* LCOV_EXCL_START */
msg_error("You cannot use -f, --filter with the '%s' command\n", command);
log_fatal("You cannot use -f, --filter with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (!tommy_list_empty(&filterlist_disk)) {
/* LCOV_EXCL_START */
msg_error("You cannot use -d, --filter-disk with the '%s' command\n", command);
log_fatal("You cannot use -d, --filter-disk with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (filter_missing != 0) {
/* LCOV_EXCL_START */
msg_error("You cannot use -m, --filter-missing with the '%s' command\n", command);
log_fatal("You cannot use -m, --filter-missing with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (filter_error != 0) {
/* LCOV_EXCL_START */
msg_error("You cannot use -e, --filter-error with the '%s' command\n", command);
log_fatal("You cannot use -e, --filter-error with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -866,7 +866,7 @@ int main(int argc, char* argv[])
default :
if (import_timestamp != 0 || import_content != 0) {
/* LCOV_EXCL_START */
msg_error("You cannot import with the '%s' command\n", command);
log_fatal("You cannot import with the '%s' command\n", command);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -927,17 +927,17 @@ int main(int argc, char* argv[])
/* print generic info into the log */
t = time(0);
tm = localtime(&t);
msg_tag("version:%s\n", PACKAGE_VERSION);
msg_tag("unixtime:%" PRIi64 "\n", (int64_t)t);
log_tag("version:%s\n", PACKAGE_VERSION);
log_tag("unixtime:%" PRIi64 "\n", (int64_t)t);
if (tm) {
char datetime[64];
strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm);
msg_tag("time:%s\n", datetime);
log_tag("time:%s\n", datetime);
}
msg_tag("command:%s\n", command);
log_tag("command:%s\n", command);
for (i = 0; i < argc; ++i)
msg_tag("argv:%u:%s\n", i, argv[i]);
msg_flush();
log_tag("argv:%u:%s\n", i, argv[i]);
log_flush();
if (!opt.skip_self)
selftest();
@ -957,10 +957,10 @@ int main(int argc, char* argv[])
if (lock == -1) {
/* LCOV_EXCL_START */
if (errno != EWOULDBLOCK) {
msg_error("Error creating the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
log_fatal("Error creating the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
} else {
msg_error("The lock file '%s' is already locked!\n", state.lockfile);
msg_error("SnapRAID is already in use!\n");
log_fatal("The lock file '%s' is already locked!\n", state.lockfile);
log_fatal("SnapRAID is already in use!\n");
}
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
@ -1025,7 +1025,7 @@ int main(int argc, char* argv[])
ret = system(run); /* ignore error */
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Error in running command '%s'.\n", run);
log_fatal("Error in running command '%s'.\n", run);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1181,7 +1181,7 @@ int main(int argc, char* argv[])
if (!opt.skip_lock) {
if (lock_unlock(lock) == -1) {
/* LCOV_EXCL_START */
msg_error("Error closing the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
log_fatal("Error closing the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

File diff suppressed because it is too large Load diff

View file

@ -81,20 +81,20 @@ int state_status(struct snapraid_state* state)
blockmax = parity_allocated_size(state);
msg_tag("summary:block_size:%u\n", state->block_size);
msg_tag("summary:parity_block_count:%u\n", blockmax);
log_tag("summary:block_size:%u\n", state->block_size);
log_tag("summary:parity_block_count:%u\n", blockmax);
/* get the minimum parity free space */
parity_block_free = state->parity[0].free_blocks;
for (l = 0; l < state->level; ++l) {
msg_tag("summary:parity_block_total:%s:%u\n", lev_config_name(l), state->parity[l].total_blocks);
msg_tag("summary:parity_block_free:%s:%u\n", lev_config_name(l), state->parity[l].free_blocks);
log_tag("summary:parity_block_total:%s:%u\n", lev_config_name(l), state->parity[l].total_blocks);
log_tag("summary:parity_block_free:%s:%u\n", lev_config_name(l), state->parity[l].free_blocks);
if (state->parity[l].free_blocks < parity_block_free)
parity_block_free = state->parity[l].free_blocks;
if (state->parity[l].free_blocks != 0)
free_not_zero = 1;
}
msg_tag("summary:parity_block_free_min:%u\n", parity_block_free);
log_tag("summary:parity_block_free_min:%u\n", parity_block_free);
printf("SnapRAID status report:\n");
printf("\n");
@ -216,18 +216,18 @@ int state_status(struct snapraid_state* state)
}
printf(" %s\n", disk->name);
msg_tag("summary:disk_file_count:%s:%u\n", disk->name, disk_file_count);
msg_tag("summary:disk_block_count:%s:%u\n", disk->name, disk_block_count);
msg_tag("summary:disk_fragmented_file_count:%s:%u\n", disk->name, disk_file_fragmented);
msg_tag("summary:disk_excess_fragment_count:%s:%u\n", disk->name, disk_extra_fragment);
msg_tag("summary:disk_file_size:%s:%" PRIu64 "\n", disk->name, disk_file_size);
msg_tag("summary:disk_block_allocated:%s:%u\n", disk->name, disk_block_latest_used + 1);
msg_tag("summary:disk_block_total:%s:%u\n", disk->name, disk->total_blocks);
msg_tag("summary:disk_block_free:%s:%u\n", disk->name, disk->free_blocks);
msg_tag("summary:disk_block_max_by_space:%s:%u\n", disk->name, disk_block_max_by_space);
msg_tag("summary:disk_block_max_by_parity:%s:%u\n", disk->name, disk_block_max_by_parity);
msg_tag("summary:disk_block_max:%s:%u\n", disk->name, disk_block_max);
msg_tag("summary:disk_space_wasted:%s:%" PRId64 "\n", disk->name, wasted);
log_tag("summary:disk_file_count:%s:%u\n", disk->name, disk_file_count);
log_tag("summary:disk_block_count:%s:%u\n", disk->name, disk_block_count);
log_tag("summary:disk_fragmented_file_count:%s:%u\n", disk->name, disk_file_fragmented);
log_tag("summary:disk_excess_fragment_count:%s:%u\n", disk->name, disk_extra_fragment);
log_tag("summary:disk_file_size:%s:%" PRIu64 "\n", disk->name, disk_file_size);
log_tag("summary:disk_block_allocated:%s:%u\n", disk->name, disk_block_latest_used + 1);
log_tag("summary:disk_block_total:%s:%u\n", disk->name, disk->total_blocks);
log_tag("summary:disk_block_free:%s:%u\n", disk->name, disk->free_blocks);
log_tag("summary:disk_block_max_by_space:%s:%u\n", disk->name, disk_block_max_by_space);
log_tag("summary:disk_block_max_by_parity:%s:%u\n", disk->name, disk_block_max_by_parity);
log_tag("summary:disk_block_max:%s:%u\n", disk->name, disk_block_max);
log_tag("summary:disk_space_wasted:%s:%" PRId64 "\n", disk->name, wasted);
}
/* totals */
@ -245,17 +245,17 @@ int state_status(struct snapraid_state* state)
if (!free_not_zero)
printf("\nWARNING! Free space info will be valid after the first sync.\n");
msg_tag("summary:file_count:%u\n", file_count);
msg_tag("summary:file_block_count:%" PRIu64 "\n", file_block_count);
msg_tag("summary:fragmented_file_count:%u\n", file_fragmented);
msg_tag("summary:excess_fragment_count:%u\n", extra_fragment);
msg_tag("summary:file_size:%" PRIu64 "\n", file_size);
msg_tag("summary:parity_size:%" PRIu64 "\n", blockmax * (uint64_t)state->block_size);
msg_tag("summary:parity_size_max:%" PRIu64 "\n", (blockmax + parity_block_free) * (uint64_t)state->block_size);
msg_tag("summary:hash:%s\n", hash_config_name(state->hash));
msg_tag("summary:prev_hash:%s\n", hash_config_name(state->prevhash));
msg_tag("summary:best_hash:%s\n", hash_config_name(state->besthash));
msg_flush();
log_tag("summary:file_count:%u\n", file_count);
log_tag("summary:file_block_count:%" PRIu64 "\n", file_block_count);
log_tag("summary:fragmented_file_count:%u\n", file_fragmented);
log_tag("summary:excess_fragment_count:%u\n", extra_fragment);
log_tag("summary:file_size:%" PRIu64 "\n", file_size);
log_tag("summary:parity_size:%" PRIu64 "\n", blockmax * (uint64_t)state->block_size);
log_tag("summary:parity_size_max:%" PRIu64 "\n", (blockmax + parity_block_free) * (uint64_t)state->block_size);
log_tag("summary:hash:%s\n", hash_config_name(state->hash));
log_tag("summary:prev_hash:%s\n", hash_config_name(state->prevhash));
log_tag("summary:best_hash:%s\n", hash_config_name(state->besthash));
log_flush();
/* copy the info a temp vector, and count bad/rehash/unsynced blocks */
infomap = malloc_nofail(blockmax * sizeof(snapraid_info));
@ -265,7 +265,7 @@ int state_status(struct snapraid_state* state)
count = 0;
rehash = 0;
unsynced_blocks = 0;
msg_tag("block_count:%u\n", blockmax);
log_tag("block_count:%u\n", blockmax);
for (i = 0; i < blockmax; ++i) {
int one_invalid;
int one_valid;
@ -307,19 +307,19 @@ int state_status(struct snapraid_state* state)
if (state->opt.gui) {
if (info != 0)
msg_tag("block:%u:%" PRIu64 ":%s:%s:%s:%s\n", i, (uint64_t)info_get_time(info), one_valid ? "used" : "", one_invalid ? "unsynced" : "", info_get_bad(info) ? "bad" : "", info_get_rehash(info) ? "rehash" : "");
log_tag("block:%u:%" PRIu64 ":%s:%s:%s:%s\n", i, (uint64_t)info_get_time(info), one_valid ? "used" : "", one_invalid ? "unsynced" : "", info_get_bad(info) ? "bad" : "", info_get_rehash(info) ? "rehash" : "");
else
msg_tag("block_noinfo:%u:%s:%s\n", i, one_valid ? "used" : "", one_invalid ? "unsynced" : "");
log_tag("block_noinfo:%u:%s:%s\n", i, one_valid ? "used" : "", one_invalid ? "unsynced" : "");
}
}
msg_tag("summary:has_unsynced:%u\n", unsynced_blocks);
msg_tag("summary:has_rehash:%u\n", rehash);
msg_tag("summary:has_bad:%u:%u:%u\n", bad, bad_first, bad_last);
msg_flush();
log_tag("summary:has_unsynced:%u\n", unsynced_blocks);
log_tag("summary:has_rehash:%u\n", rehash);
log_tag("summary:has_bad:%u:%u:%u\n", bad, bad_first, bad_last);
log_flush();
if (!count) {
msg_error("The array is empty.\n");
log_fatal("The array is empty.\n");
free(infomap);
return 0;
}
@ -329,12 +329,12 @@ int state_status(struct snapraid_state* state)
/* output the info map */
i = 0;
msg_tag("info_count:%u\n", count);
log_tag("info_count:%u\n", count);
while (i < count) {
unsigned j = i + 1;
while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j]))
++j;
msg_tag("info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
log_tag("info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
i = j;
}

View file

@ -50,11 +50,11 @@ static pthread_mutex_t msg_lock = PTHREAD_MUTEX_INITIALIZER;
* The buffering is similar at the "line buffered" one, that
* is not available on Windows, so we emulate it in this way.
*
* For stdlog the flush is only limited.
* To ensure flushing the caller should use msg_flush().
* For stdlog flushing is limited. To ensure flushing the
* caller should use log_flush().
*/
void msg_error(const char* format, ...)
void log_fatal(const char* format, ...)
{
va_list ap;
@ -62,7 +62,7 @@ void msg_error(const char* format, ...)
if (stdlog) {
va_start(ap, format);
fprintf(stdlog, "msg:error: ");
fprintf(stdlog, "msg:fatal: ");
vfprintf(stdlog, format, ap);
fflush(stdlog);
va_end(ap);
@ -76,7 +76,7 @@ void msg_error(const char* format, ...)
pthread_mutex_unlock(&msg_lock);
}
void msg_warning(const char* format, ...)
void log_error(const char* format, ...)
{
va_list ap;
@ -84,7 +84,7 @@ void msg_warning(const char* format, ...)
if (stdlog) {
va_start(ap, format);
fprintf(stdlog, "msg:warning: ");
fprintf(stdlog, "msg:error: ");
vfprintf(stdlog, format, ap);
fflush(stdlog);
va_end(ap);
@ -98,7 +98,7 @@ void msg_warning(const char* format, ...)
pthread_mutex_unlock(&msg_lock);
}
void msg_expected(const char* format, ...)
void log_expected(const char* format, ...)
{
va_list ap;
@ -106,7 +106,7 @@ void msg_expected(const char* format, ...)
if (stdlog) {
va_start(ap, format);
fprintf(stdlog, "msg:warning: ");
fprintf(stdlog, "msg:expected: ");
vfprintf(stdlog, format, ap);
fflush(stdlog);
va_end(ap);
@ -115,7 +115,7 @@ void msg_expected(const char* format, ...)
pthread_mutex_unlock(&msg_lock);
}
void msg_tag(const char* format, ...)
void log_tag(const char* format, ...)
{
va_list ap;
@ -124,12 +124,26 @@ void msg_tag(const char* format, ...)
if (stdlog) {
va_start(ap, format);
vfprintf(stdlog, format, ap);
/* here we intentionally don't flush */
/* to make the output faster */
va_end(ap);
}
pthread_mutex_unlock(&msg_lock);
}
void log_flush(void)
{
pthread_mutex_lock(&msg_lock);
if (stdlog)
fflush(stdlog);
fflush(stdout);
fflush(stderr);
pthread_mutex_unlock(&msg_lock);
}
void msg_status(const char* format, ...)
{
va_list ap;
@ -244,8 +258,6 @@ void msg_flush(void)
{
pthread_mutex_lock(&msg_lock);
if (stdlog)
fflush(stdlog);
fflush(stdout);
fflush(stderr);
@ -316,7 +328,7 @@ const char* esc(const char* str)
bail:
/* LCOV_EXCL_START */
msg_error("Escape too long\n");
log_fatal("Escape too long\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -343,7 +355,7 @@ void pathcpy(char* dst, size_t size, const char* src)
if (len + 1 > size) {
/* LCOV_EXCL_START */
msg_error("Path too long\n");
log_fatal("Path too long\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -358,7 +370,7 @@ void pathcat(char* dst, size_t size, const char* src)
if (dst_len + src_len + 1 > size) {
/* LCOV_EXCL_START */
msg_error("Path too long\n");
log_fatal("Path too long\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -372,7 +384,7 @@ void pathcatc(char* dst, size_t size, char c)
if (dst_len + 2 > size) {
/* LCOV_EXCL_START */
msg_error("Path too long\n");
log_fatal("Path too long\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -420,7 +432,7 @@ void pathprint(char* dst, size_t size, const char* format, ...)
if (len >= size) {
/* LCOV_EXCL_START */
msg_error("Path too long\n");
log_fatal("Path too long\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -433,7 +445,7 @@ void pathslash(char* dst, size_t size)
if (len > 0 && dst[len - 1] != '/') {
if (len + 2 >= size) {
/* LCOV_EXCL_START */
msg_error("Path too long\n");
log_fatal("Path too long\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -528,7 +540,7 @@ int mkancestor(const char* file)
/* create it */
if (mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) {
/* LCOV_EXCL_START */
msg_error("Error creating directory '%s'. %s.\n", dir, strerror(errno));
log_fatal("Error creating directory '%s'. %s.\n", dir, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -760,7 +772,7 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, uint64_t* sm
/* remove extraneous chars */
s = polish(buf);
msg_tag("smartctl:%s:%s:out: %s\n", file, name, s);
log_tag("smartctl:%s:%s:out: %s\n", file, name, s);
/* skip initial spaces */
while (isspace(*s))
@ -789,14 +801,14 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, uint64_t* sm
} else if (inside) {
if (sscanf(s, "%u %*s %*s %*s %*s %*s %*s %*s %*s %" SCNu64, &id, &raw) != 2) {
/* LCOV_EXCL_START */
msg_error("Invalid smartctl line '%s'.\n", s);
log_fatal("Invalid smartctl line '%s'.\n", s);
return -1;
/* LCOV_EXCL_STOP */
}
if (id >= 256) {
/* LCOV_EXCL_START */
msg_error("Invalid SMART id '%u'.\n", id);
log_fatal("Invalid SMART id '%u'.\n", id);
return -1;
/* LCOV_EXCL_STOP */
}
@ -822,7 +834,7 @@ int smartctl_flush(FILE* f, const char* file, const char* name)
/* remove extraneous chars */
s = polish(buf);
msg_tag("smartctl:%s:%s:out: %s\n", file, name, s);
log_tag("smartctl:%s:%s:out: %s\n", file, name, s);
}
return 0;

View file

@ -22,32 +22,37 @@
/* log */
/**
* Fatal messages.
* Fatal error messages.
*
* Messages printed before an early termination.
*
* These messages go in the log file and in stderr inconditionally.
*/
void msg_error(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
void log_fatal(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
/**
* Warning messages.
* Unexpected error messages.
*
* Messages reporting warnings or error conditions that don't prevent the program to run.
* Messages reporting error conditions that don't prevent the program to run.
*
* Some of them could be also serious errors, like "silent errors".
* The summary results is anyway always printed with as errors.
* In such case, the summary result is always printed as error,
* and we are sure to notify the user in some way.
*
* These messages go in the log file if specified, otherwise they go in stderr.
*/
void msg_warning(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
void log_error(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
/**
* Warning messages, without fallback to stderr.
* Expected error messages, without fallback to stderr.
*
* These errors are "someway" expected, and then they never go to screen.
* For example, when undeleting missing files, the messages for missing files
* are not shown.
*
* These messages go in the log file if specified, otherwise they are lost.
*/
void msg_expected(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
void log_expected(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
/**
* Tag messages.
@ -60,13 +65,26 @@ void msg_expected(const char* format, ...) __attribute__((format(attribute_print
*
* These messages are buffered. Use msg_flush() to flush them.
*/
void msg_tag(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
void log_tag(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
/**
* Flush the log.
*/
void log_flush(void);
/**
* Pointer to log function.
*/
typedef void fptr(const char* format, ...);
/****************************************************************************/
/* message */
/**
* Message levels.
*
* The levels control the amount of information printed on the screen.
* Note that msg_error(), msg_warning() and msg_tag() are not influenced by this option.
* Note that log_fatal(), log_error(), log_expected() and log_tag() are not affected by this option.
*
* From the most quiet to the most verbose.
*/
@ -96,7 +114,7 @@ void msg_status(const char* format, ...) __attribute__((format(attribute_printf,
* Potentially a lot of messages are possible. They can still be on the screen,
* as losing them we don't lose information.
*
* These messages never go in the log file, becauae there is always a corresponding msg_tag().
* These messages never go in the log file, becauae there is always a corresponding log_tag().
*/
void msg_info(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
@ -134,10 +152,8 @@ void msg_verbose(const char* format, ...) __attribute__((format(attribute_printf
*/
void msg_flush(void);
/**
* Pointer to log function.
*/
typedef void fptr(const char* format, ...);
/****************************************************************************/
/* escape */
/**
* Escape a string.

View file

@ -132,44 +132,44 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
/* This one is really an unexpected error, because we are only reading */
/* and closing a descriptor should never fail */
if (errno == EIO) {
msg_tag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
}
msg_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that file '%s' can be accessed.\n", handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle[j].path);
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
}
}
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, msg_warning, 0);
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, log_error, 0);
if (ret == -1) {
/* file we have tried to open for error reporting */
struct snapraid_file* file = block_file_get(block);
if (errno == EIO) {
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected input/output open error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected input/output open error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
/* LCOV_EXCL_STOP */
}
if (errno == ENOENT) {
msg_tag("error:%u:%s:%s: Open ENOENT error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_warning("Missing file '%s'.\n", handle[j].path);
msg_warning("WARNING! You cannot modify data disk during a sync.\n");
msg_warning("Rerun the sync command when finished.\n");
log_tag("error:%u:%s:%s: Open ENOENT error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_error("Missing file '%s'.\n", handle[j].path);
log_error("WARNING! You cannot modify data disk during a sync.\n");
log_error("Rerun the sync command when finished.\n");
++error;
/* if the file is missing, it means that it was removed during sync */
/* this isn't a serious error, so we skip this block, and continue with others */
@ -177,20 +177,20 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
}
if (errno == EACCES) {
msg_tag("error:%u:%s:%s: Open EACCES error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_warning("No access at file '%s'.\n", handle[j].path);
msg_warning("WARNING! Please fix the access permission in the data disk.\n");
msg_warning("Rerun the sync command when finished.\n");
log_tag("error:%u:%s:%s: Open EACCES error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_error("No access at file '%s'.\n", handle[j].path);
log_error("WARNING! Please fix the access permission in the data disk.\n");
log_error("Rerun the sync command when finished.\n");
++error;
/* this isn't a serious error, so we skip this block, and continue with others */
continue;
}
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Open error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that file '%s' can be accessed.\n", handle[j].path);
msg_error("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
log_tag("error:%u:%s:%s: Open error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle[j].path);
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -204,41 +204,41 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
) {
/* file we are processing for error reporting */
struct snapraid_file* file = block_file_get(block);
msg_tag("error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, esc(file->sub));
log_tag("error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, esc(file->sub));
if (handle[j].st.st_size != file->size) {
msg_warning("Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, handle[j].st.st_size);
log_error("Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, handle[j].st.st_size);
} else if (handle[j].st.st_mtime != file->mtime_sec
|| STAT_NSEC(&handle[j].st) != file->mtime_nsec) {
msg_warning("Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, (uint32_t)STAT_NSEC(&handle[j].st));
log_error("Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, (uint32_t)STAT_NSEC(&handle[j].st));
} else {
msg_warning("Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
log_error("Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
}
msg_warning("WARNING! You cannot modify files during a sync.\n");
msg_warning("Rerun the sync command when finished.\n");
log_error("WARNING! You cannot modify files during a sync.\n");
log_error("Rerun the sync command when finished.\n");
++error;
/* if the file is changed, it means that it was modified during sync */
/* this isn't a serious error, so we skip this block, and continue with others */
continue;
}
read_size = handle_read(&handle[j], block, buffer, state->block_size, msg_error, 0);
read_size = handle_read(&handle[j], block, buffer, state->block_size, log_fatal, 0);
if (read_size == -1) {
/* LCOV_EXCL_START */
/* file we are processing for error reporting */
struct snapraid_file* file = block_file_get(block);
if (errno == EIO) {
msg_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
msg_error("DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
log_fatal("DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
}
msg_tag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
msg_error("WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that file '%s' can be read.\n", handle[j].path);
msg_error("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
log_tag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
log_fatal("WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be read.\n", handle[j].path);
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -287,18 +287,18 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
/* This one is really an unexpected error, because we are only reading */
/* and closing a descriptor should never fail */
if (errno == EIO) {
msg_tag("error:%u:%s:%s: Close EIO error. %s\n", blockmax, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", blockmax);
log_tag("error:%u:%s:%s: Close EIO error. %s\n", blockmax, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", blockmax);
++io_error;
goto bail;
}
msg_tag("error:%u:%s:%s: Close error. %s\n", blockmax, disk->name, esc(file->sub), strerror(errno));
msg_error("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that file '%s' can be accessed.\n", handle[j].path);
msg_error("Stopping at block %u\n", blockmax);
log_tag("error:%u:%s:%s: Close error. %s\n", blockmax, disk->name, esc(file->sub), strerror(errno));
log_fatal("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle[j].path);
log_fatal("Stopping at block %u\n", blockmax);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -323,9 +323,9 @@ end:
}
if (error)
msg_error("WARNING! Unexpected file errors!\n");
log_fatal("WARNING! Unexpected file errors!\n");
msg_tag("hash_summary:error_file:%u\n", error);
log_tag("hash_summary:error_file:%u\n", error);
/* proceed without bailing out */
goto finish;
@ -340,8 +340,8 @@ bail:
struct snapraid_disk* disk = handle[j].disk;
ret = handle_close(&handle[j]);
if (ret == -1) {
msg_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected close error in a data disk.\n");
log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected close error in a data disk.\n");
++error;
/* continue, as we are already exiting */
}
@ -606,44 +606,44 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* This one is really an unexpected error, because we are only reading */
/* and closing a descriptor should never fail */
if (errno == EIO) {
msg_tag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
}
msg_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that file '%s' can be accessed.\n", handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle[j].path);
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
}
}
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, msg_warning, 0);
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, log_error, 0);
if (ret == -1) {
/* file we have tried to open for error reporting */
struct snapraid_file* file = block_file_get(block);
if (errno == EIO) {
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected input/output open error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_tag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected input/output open error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
/* LCOV_EXCL_STOP */
}
if (errno == ENOENT) {
msg_tag("error:%u:%s:%s: Open ENOENT error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_warning("Missing file '%s'.\n", handle[j].path);
msg_warning("WARNING! You cannot modify data disk during a sync.\n");
msg_warning("Rerun the sync command when finished.\n");
log_tag("error:%u:%s:%s: Open ENOENT error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_error("Missing file '%s'.\n", handle[j].path);
log_error("WARNING! You cannot modify data disk during a sync.\n");
log_error("Rerun the sync command when finished.\n");
++error;
/* if the file is missing, it means that it was removed during sync */
/* this isn't a serious error, so we skip this block, and continue with others */
@ -652,10 +652,10 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
}
if (errno == EACCES) {
msg_tag("error:%u:%s:%s: Open EACCES error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_warning("No access at file '%s'.\n", handle[j].path);
msg_warning("WARNING! Please fix the access permission in the data disk.\n");
msg_warning("Rerun the sync command when finished.\n");
log_tag("error:%u:%s:%s: Open EACCES error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_error("No access at file '%s'.\n", handle[j].path);
log_error("WARNING! Please fix the access permission in the data disk.\n");
log_error("Rerun the sync command when finished.\n");
++error;
/* this isn't a serious error, so we skip this block, and continue with others */
error_on_this_block = 1;
@ -663,10 +663,10 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
}
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Open error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that file '%s' can be accessed.\n", handle[j].path);
msg_error("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
log_tag("error:%u:%s:%s: Open error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle[j].path);
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -680,17 +680,17 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
) {
/* file we are processing for error reporting */
struct snapraid_file* file = block_file_get(block);
msg_tag("error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, esc(file->sub));
log_tag("error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, esc(file->sub));
if (handle[j].st.st_size != file->size) {
msg_warning("Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, handle[j].st.st_size);
log_error("Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, handle[j].st.st_size);
} else if (handle[j].st.st_mtime != file->mtime_sec
|| STAT_NSEC(&handle[j].st) != file->mtime_nsec) {
msg_warning("Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, (uint32_t)STAT_NSEC(&handle[j].st));
log_error("Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, (uint32_t)STAT_NSEC(&handle[j].st));
} else {
msg_warning("Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
log_error("Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
}
msg_warning("WARNING! You cannot modify files during a sync.\n");
msg_warning("Rerun the sync command when finished.\n");
log_error("WARNING! You cannot modify files during a sync.\n");
log_error("Rerun the sync command when finished.\n");
++error;
/* if the file is changed, it means that it was modified during sync */
/* this isn't a serious error, so we skip this block, and continue with others */
@ -698,31 +698,31 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
continue;
}
read_size = handle_read(&handle[j], block, buffer[j], state->block_size, msg_warning, 0);
read_size = handle_read(&handle[j], block, buffer[j], state->block_size, log_error, 0);
if (read_size == -1) {
/* LCOV_EXCL_START */
/* file we are processing for error reporting */
struct snapraid_file* file = block_file_get(block);
if (errno == EIO) {
msg_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
if (io_error >= state->opt.io_error_limit) {
msg_error("DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle[j].path);
msg_error("Stopping at block %u\n", i);
log_fatal("DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle[j].path);
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
}
msg_warning("Input/Output error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
log_error("Input/Output error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
++io_error;
io_error_on_this_block = 1;
continue;
}
msg_tag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
msg_error("WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
msg_error("Ensure that file '%s' can be read.\n", handle[j].path);
msg_error("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
log_tag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, esc(file->sub), block_file_pos(block), strerror(errno));
log_fatal("WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be read.\n", handle[j].path);
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -752,17 +752,17 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* if the file has invalid parity, it's a REP changed during the sync */
if (block_has_invalid_parity(block)) {
msg_tag("error:%u:%s:%s: Unexpected data change\n", i, disk->name, esc(file->sub));
msg_warning("Data change at file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
msg_warning("WARNING! Unexpected data modification of a file without parity!\n");
log_tag("error:%u:%s:%s: Unexpected data change\n", i, disk->name, esc(file->sub));
log_error("Data change at file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
log_error("WARNING! Unexpected data modification of a file without parity!\n");
if (file_flag_has(file, FILE_IS_COPY)) {
msg_warning("This file was detected as a copy of another file with the same name, size,\n");
msg_warning("and timestamp, but the file data isn't matching the assumed copy.\n");
msg_warning("If this is a false positive, and the files are expected to be different,\n");
msg_warning("you can 'sync' anyway using 'snapraid --force-nocopy sync'\n");
log_error("This file was detected as a copy of another file with the same name, size,\n");
log_error("and timestamp, but the file data isn't matching the assumed copy.\n");
log_error("If this is a false positive, and the files are expected to be different,\n");
log_error("you can 'sync' anyway using 'snapraid --force-nocopy sync'\n");
} else {
msg_warning("Try removing the file from the array and rerun the 'sync' command!\n");
log_error("Try removing the file from the array and rerun the 'sync' command!\n");
}
++error;
@ -772,8 +772,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
error_on_this_block = 1;
continue;
} else { /* otherwise it's a BLK with silent error */
msg_tag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, esc(file->sub), block_file_pos(block));
msg_warning("Data error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
log_tag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, esc(file->sub), block_file_pos(block));
log_error("Data error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
/* save the failed block for the fix */
failed[failed_count].index = j;
@ -866,29 +866,29 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* we are sure that parity exists because */
/* we have at least one BLK block */
for (l = 0; l < state->level; ++l) {
ret = parity_read(parity[l], i, buffer[diskmax + l], state->block_size, msg_warning);
ret = parity_read(parity[l], i, buffer[diskmax + l], state->block_size, log_error);
if (ret == -1) {
/* LCOV_EXCL_START */
if (errno == EIO) {
msg_tag("parity_error:%u:%s: Read EIO error. %s\n", i, lev_config_name(l), strerror(errno));
log_tag("parity_error:%u:%s: Read EIO error. %s\n", i, lev_config_name(l), strerror(errno));
if (io_error >= state->opt.io_error_limit) {
msg_error("DANGER! Unexpected input/output read error in the %s disk, it isn't possible to sync.\n", lev_name(l));
msg_error("Ensure that disk '%s' is sane and can be read.\n", lev_config_name(l));
msg_error("Stopping at block %u\n", i);
log_fatal("DANGER! Unexpected input/output read error in the %s disk, it isn't possible to sync.\n", lev_name(l));
log_fatal("Ensure that disk '%s' is sane and can be read.\n", lev_config_name(l));
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
}
msg_warning("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
log_error("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
++io_error;
io_error_on_this_block = 1;
continue;
}
msg_tag("parity_error:%u:%s: Read error. %s\n", i, lev_config_name(l), strerror(errno));
msg_error("WARNING! Unexpected read error in the %s disk, it isn't possible to sync.\n", lev_name(l));
msg_error("Ensure that disk '%s' can be read.\n", lev_config_name(l));
msg_error("Stopping at block %u\n", i);
log_tag("parity_error:%u:%s: Read error. %s\n", i, lev_config_name(l), strerror(errno));
log_fatal("WARNING! Unexpected read error in the %s disk, it isn't possible to sync.\n", lev_name(l));
log_fatal("Ensure that disk '%s' can be read.\n", lev_config_name(l));
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -965,25 +965,25 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
if (ret == -1) {
/* LCOV_EXCL_START */
if (errno == EIO) {
msg_tag("parity_error:%u:%s: Write EIO error. %s\n", i, lev_config_name(l), strerror(errno));
log_tag("parity_error:%u:%s: Write EIO error. %s\n", i, lev_config_name(l), strerror(errno));
if (io_error >= state->opt.io_error_limit) {
msg_error("DANGER! Unexpected input/output write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
msg_error("Ensure that disk '%s' is sane and can be written.\n", lev_config_name(l));
msg_error("Stopping at block %u\n", i);
log_fatal("DANGER! Unexpected input/output write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
log_fatal("Ensure that disk '%s' is sane and can be written.\n", lev_config_name(l));
log_fatal("Stopping at block %u\n", i);
++io_error;
goto bail;
}
msg_warning("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
log_error("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
++io_error;
io_error_on_this_block = 1;
continue;
}
msg_tag("parity_error:%u:%s: Write error. %s\n", i, lev_config_name(l), strerror(errno));
msg_error("WARNING! Unexpected write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
msg_error("Ensure that disk '%s' has some free space available.\n", lev_config_name(l));
msg_error("Stopping at block %u\n", i);
log_tag("parity_error:%u:%s: Write error. %s\n", i, lev_config_name(l), strerror(errno));
log_fatal("WARNING! Unexpected write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
log_fatal("Ensure that disk '%s' has some free space available.\n", lev_config_name(l));
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1086,10 +1086,10 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
ret = parity_sync(parity[l]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_tag("parity_error:%u:%s: Sync error\n", i, lev_config_name(l));
msg_error("DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
msg_error("Ensure that disk '%s' is sane.\n", lev_config_name(l));
msg_error("Stopping at block %u\n", i);
log_tag("parity_error:%u:%s: Sync error\n", i, lev_config_name(l));
log_fatal("DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
log_fatal("Ensure that disk '%s' is sane.\n", lev_config_name(l));
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1117,10 +1117,10 @@ end:
ret = parity_sync(parity[l]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_tag("parity_error:%u:%s: Sync error\n", i, lev_config_name(l));
msg_error("DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
msg_error("Ensure that disk '%s' is sane.\n", lev_config_name(l));
msg_error("Stopping at block %u\n", i);
log_tag("parity_error:%u:%s: Sync error\n", i, lev_config_name(l));
log_fatal("DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
log_fatal("Ensure that disk '%s' is sane.\n", lev_config_name(l));
log_fatal("Stopping at block %u\n", i);
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -1139,24 +1139,24 @@ end:
}
if (error)
msg_error("WARNING! Unexpected file errors!\n");
log_fatal("WARNING! Unexpected file errors!\n");
if (io_error)
msg_error("DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
log_fatal("DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
if (silent_error)
msg_error("DANGER! Unexpected data errors! The failing blocks are now marked as bad!\n");
log_fatal("DANGER! Unexpected data errors! The failing blocks are now marked as bad!\n");
if (io_error || silent_error) {
msg_error("Use 'snapraid status' to list the bad blocks.\n");
msg_error("Use 'snapraid -e fix' to recover.\n");
log_fatal("Use 'snapraid status' to list the bad blocks.\n");
log_fatal("Use 'snapraid -e fix' to recover.\n");
}
msg_tag("summary:error_file:%u\n", error);
msg_tag("summary:error_io:%u\n", io_error);
msg_tag("summary:error_data:%u\n", silent_error);
log_tag("summary:error_file:%u\n", error);
log_tag("summary:error_io:%u\n", io_error);
log_tag("summary:error_data:%u\n", silent_error);
if (error + silent_error + io_error == 0)
msg_tag("summary:exit:ok\n");
log_tag("summary:exit:ok\n");
else
msg_tag("summary:exit:error\n");
msg_flush();
log_tag("summary:exit:error\n");
log_flush();
bail:
for (j = 0; j < diskmax; ++j) {
@ -1165,8 +1165,8 @@ bail:
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
msg_error("DANGER! Unexpected close error in a data disk.\n");
log_tag("error:%u:%s:%s: Close error. %s\n", i, disk->name, esc(file->sub), strerror(errno));
log_fatal("DANGER! Unexpected close error in a data disk.\n");
++error;
/* continue, as we are already exiting */
/* LCOV_EXCL_STOP */
@ -1219,7 +1219,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
if (blockstart > blockmax) {
/* LCOV_EXCL_START */
msg_error("Error in the starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
log_fatal("Error in the starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1237,7 +1237,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
ret = parity_create(parity_ptr[l], state->parity[l].path, &out_size, state->file_mode);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
log_fatal("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1247,7 +1247,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
/* if the file is too small */
if (parityblocks < used_paritymax) {
msg_error("WARNING! The %s file %s has data only %u blocks instead of %u.\n", lev_name(l), state->parity[l].path, parityblocks, used_paritymax);
log_fatal("WARNING! The %s file %s has data only %u blocks instead of %u.\n", lev_name(l), state->parity[l].path, parityblocks, used_paritymax);
}
/* keep the smallest parity number of blocks */
@ -1260,15 +1260,15 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
/* if the parities are too small */
if (file_paritymax < used_paritymax) {
/* LCOV_EXCL_START */
msg_error("DANGER! One or more the parity files are smaller than expected!\n");
log_fatal("DANGER! One or more the parity files are smaller than expected!\n");
if (file_paritymax != 0) {
msg_error("If this happens because you are using an old content file,\n");
msg_error("you can 'sync' anyway using 'snapraid --force-full sync'\n");
msg_error("to force a full rebuild of the parity.\n");
log_fatal("If this happens because you are using an old content file,\n");
log_fatal("you can 'sync' anyway using 'snapraid --force-full sync'\n");
log_fatal("to force a full rebuild of the parity.\n");
} else {
msg_error("It's possible that the parity disks are not mounted.\n");
msg_error("If instead you are adding a new parity level, you can 'sync' using\n");
msg_error("'snapraid --force-full sync' to force a full rebuild of the parity.\n");
log_fatal("It's possible that the parity disks are not mounted.\n");
log_fatal("If instead you are adding a new parity level, you can 'sync' using\n");
log_fatal("'snapraid --force-full sync' to force a full rebuild of the parity.\n");
}
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
@ -1284,7 +1284,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
if (ret == -1) {
/* LCOV_EXCL_START */
parity_overflow(state, out_size);
msg_error("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
log_fatal("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -1331,7 +1331,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
ret = parity_close(parity_ptr[l]);
if (ret == -1) {
/* LCOV_EXCL_START */
msg_error("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
log_fatal("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
++unrecoverable_error;
/* continue, as we are already exiting */
/* LCOV_EXCL_STOP */

View file

@ -341,7 +341,7 @@ static dev_t devread(const char* path)
f = open(path, O_RDONLY);
if (f == -1) {
/* LCOV_EXCL_START */
msg_error("Failed to open '%s'.\n", path);
log_fatal("Failed to open '%s'.\n", path);
return 0;
/* LCOV_EXCL_STOP */
}
@ -350,14 +350,14 @@ static dev_t devread(const char* path)
if (ret < 0) {
/* LCOV_EXCL_START */
close(f);
msg_error("Failed to read '%s'.\n", path);
log_fatal("Failed to read '%s'.\n", path);
return 0;
/* LCOV_EXCL_STOP */
}
if (ret == sizeof(buf)) {
/* LCOV_EXCL_START */
close(f);
msg_error("Too long read '%s'.\n", path);
log_fatal("Too long read '%s'.\n", path);
return 0;
/* LCOV_EXCL_STOP */
}
@ -368,7 +368,7 @@ static dev_t devread(const char* path)
if (*e != ':') {
/* LCOV_EXCL_START */
close(f);
msg_error("Invalid format in '%s' for '%s'.\n", path, buf);
log_fatal("Invalid format in '%s' for '%s'.\n", path, buf);
return 0;
/* LCOV_EXCL_STOP */
}
@ -377,7 +377,7 @@ static dev_t devread(const char* path)
if (*e != 0 && !isspace(*e)) {
/* LCOV_EXCL_START */
close(f);
msg_error("Invalid format in '%s' for '%s'.\n", path, buf);
log_fatal("Invalid format in '%s' for '%s'.\n", path, buf);
return 0;
/* LCOV_EXCL_STOP */
}
@ -385,7 +385,7 @@ static dev_t devread(const char* path)
ret = close(f);
if (ret != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to close '%s'.\n", path);
log_fatal("Failed to close '%s'.\n", path);
return 0;
/* LCOV_EXCL_STOP */
}
@ -411,13 +411,13 @@ static int devresolve(dev_t device, char* path, size_t path_size)
ret = readlink(path, buf, sizeof(buf));
if (ret < 0) {
/* LCOV_EXCL_START */
msg_error("Failed to readlink '%s'.\n", path);
log_fatal("Failed to readlink '%s'.\n", path);
return -1;
/* LCOV_EXCL_STOP */
}
if (ret == sizeof(buf)) {
/* LCOV_EXCL_START */
msg_error("Too long readlink '%s'.\n", path);
log_fatal("Too long readlink '%s'.\n", path);
return -1;
/* LCOV_EXCL_STOP */
}
@ -426,7 +426,7 @@ static int devresolve(dev_t device, char* path, size_t path_size)
if (buf[0] != '.' || buf[1] != '.' || buf[2] != '/') {
/* LCOV_EXCL_START */
msg_error("Unexpected link '%s' at '%s'.\n", buf, path);
log_fatal("Unexpected link '%s' at '%s'.\n", buf, path);
return -1;
/* LCOV_EXCL_STOP */
}
@ -437,13 +437,13 @@ static int devresolve(dev_t device, char* path, size_t path_size)
/* check the device */
if (stat(path, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to stat '%s'.\n", path);
log_fatal("Failed to stat '%s'.\n", path);
return -1;
/* LCOV_EXCL_STOP */
}
if (st.st_rdev != device) {
/* LCOV_EXCL_START */
msg_error("Unexpected device '%u:%u' instead of '%u:%u' for '%s'.\n", major(st.st_rdev), minor(st.st_rdev), major(device), minor(device), path);
log_fatal("Unexpected device '%u:%u' instead of '%u:%u' for '%s'.\n", major(st.st_rdev), minor(st.st_rdev), major(device), minor(device), path);
return -1;
/* LCOV_EXCL_STOP */
}
@ -556,7 +556,7 @@ static int devscan(tommy_list* list)
d = opendir(dir);
if (d == 0) {
/* LCOV_EXCL_START */
msg_error("Failed to open dir '%s'.\n", dir);
log_fatal("Failed to open dir '%s'.\n", dir);
return -1;
/* LCOV_EXCL_STOP */
}
@ -639,12 +639,12 @@ static int devsmart(dev_t device, const char* name, const char* custom, uint64_t
snprintf(cmd, sizeof(cmd), "smartctl -a %s", file);
}
msg_tag("smartctl:%s:%s:run: %s\n", file, name, cmd);
log_tag("smartctl:%s:%s:run: %s\n", file, name, cmd);
f = popen(cmd, "r");
if (!f) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from popen).\n", cmd);
log_fatal("Failed to run '%s' (from popen).\n", cmd);
return -1;
/* LCOV_EXCL_STOP */
}
@ -658,17 +658,17 @@ static int devsmart(dev_t device, const char* name, const char* custom, uint64_t
ret = pclose(f);
msg_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
log_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
if (!WIFEXITED(ret)) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (not exited).\n", cmd);
log_fatal("Failed to run '%s' (not exited).\n", cmd);
return -1;
/* LCOV_EXCL_STOP */
}
if (WEXITSTATUS(ret) == 127) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from sh).\n", cmd);
log_fatal("Failed to run '%s' (from sh).\n", cmd);
return -1;
/* LCOV_EXCL_STOP */
}
@ -701,12 +701,12 @@ static int devdown(dev_t device, const char* name, const char* custom)
snprintf(cmd, sizeof(cmd), "smartctl -s standby,now %s", file);
}
msg_tag("smartctl:%s:%s:run: %s\n", file, name, cmd);
log_tag("smartctl:%s:%s:run: %s\n", file, name, cmd);
f = popen(cmd, "r");
if (!f) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from popen).\n", cmd);
log_fatal("Failed to run '%s' (from popen).\n", cmd);
return -1;
/* LCOV_EXCL_STOP */
}
@ -720,23 +720,23 @@ static int devdown(dev_t device, const char* name, const char* custom)
ret = pclose(f);
msg_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
log_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
if (!WIFEXITED(ret)) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (not exited).\n", cmd);
log_fatal("Failed to run '%s' (not exited).\n", cmd);
return -1;
/* LCOV_EXCL_STOP */
}
if (WEXITSTATUS(ret) == 127) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' (from sh).\n", cmd);
log_fatal("Failed to run '%s' (from sh).\n", cmd);
return -1;
/* LCOV_EXCL_STOP */
}
if (WEXITSTATUS(ret) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to run '%s' with return code %xh.\n", cmd, WEXITSTATUS(ret));
log_fatal("Failed to run '%s' with return code %xh.\n", cmd, WEXITSTATUS(ret));
return -1;
/* LCOV_EXCL_STOP */
}
@ -763,7 +763,7 @@ static int devup(const char* mount)
ret = mkdir(path, 0);
if (ret != 0 && errno != EEXIST) {
/* LCOV_EXCL_START */
msg_error("Failed to create dir '%s'.\n", path);
log_fatal("Failed to create dir '%s'.\n", path);
return -1;
/* LCOV_EXCL_STOP */
}
@ -792,7 +792,7 @@ static void* thread_spinup(void* arg)
/* first get the device number, this usually doesn't trigger a thread_spinup */
if (stat(devinfo->mount, &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to stat device '%s'.\n", devinfo->mount);
log_fatal("Failed to stat device '%s'.\n", devinfo->mount);
return (void*)-1;
/* LCOV_EXCL_STOP */
}
@ -872,7 +872,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
if (pthread_create(&devinfo->thread, 0, func, devinfo) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to create thread.\n");
log_fatal("Failed to create thread.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -885,7 +885,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
if (pthread_join(devinfo->thread, &retval) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to join thread.\n");
log_fatal("Failed to join thread.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -921,13 +921,13 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
/* sysfs and devfs interfaces are required */
if (stat("/sys/dev/block", &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Missing interface /sys/dev/block.\n");
log_fatal("Missing interface /sys/dev/block.\n");
return -1;
/* LCOV_EXCL_STOP */
}
if (stat("/dev/block", &st) != 0) {
/* LCOV_EXCL_START */
msg_error("Missing interface /dev/block.\n");
log_fatal("Missing interface /dev/block.\n");
return -1;
/* LCOV_EXCL_STOP */
}
@ -939,7 +939,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
/* get the device file */
if (devresolve(devinfo->device, devinfo->file, sizeof(devinfo->file)) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to resolve device '%u:%u'.\n", major(devinfo->device), minor(devinfo->device));
log_fatal("Failed to resolve device '%u:%u'.\n", major(devinfo->device), minor(devinfo->device));
return -1;
/* LCOV_EXCL_STOP */
}
@ -947,7 +947,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
/* expand the tree of devices */
if (devtree(devinfo->name, devinfo->smartctl, devinfo->device, devinfo, low) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to expand device '%u:%u'.\n", major(devinfo->device), minor(devinfo->device));
log_fatal("Failed to expand device '%u:%u'.\n", major(devinfo->device), minor(devinfo->device));
return -1;
/* LCOV_EXCL_STOP */
}
@ -977,7 +977,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
if (operation == DEVICE_SMART) {
if (devscan(low) != 0) {
/* LCOV_EXCL_START */
msg_error("Failed to list other devices.\n");
log_fatal("Failed to list other devices.\n");
return -1;
/* LCOV_EXCL_STOP */
}

View file

@ -72,8 +72,8 @@ void mtest_vector(int n, size_t size, void** vv)
{
if (raid_mtest_vector(n, size, vv) != 0) {
/* LCOV_EXCL_START */
msg_error("DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n");
msg_error("Try running a memory test like http://www.memtest86.com/\n");
log_fatal("DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n");
log_fatal("Try running a memory test like http://www.memtest86.com/\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -492,7 +492,7 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void*
break;
default :
/* LCOV_EXCL_START */
msg_error("Internal inconsistency in hash function %u\n", kind);
log_fatal("Internal inconsistency in hash function %u\n", kind);
exit(EXIT_FAILURE);
break;
/* LCOV_EXCL_STOP */