mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Change the log and output handling
Now the log file contains all the errors messages, and all the tag lines.
This commit is contained in:
parent
ce20be0ded
commit
b5ce575981
32 changed files with 1127 additions and 1036 deletions
6
HISTORY
6
HISTORY
|
|
@ -1,8 +1,12 @@
|
|||
SnapRAID HISTORY
|
||||
================
|
||||
|
||||
8.0 2015/01 BETA
|
||||
8.0 2015/02 BETA
|
||||
================
|
||||
* Changes the log handling. If no log file is specified, all the
|
||||
log goes to stderr. If a log file is specified, only the most
|
||||
serious errors are printed on the screen.
|
||||
This applies to all commands.
|
||||
* Adds new "smart" command to print a SMART report of the array.
|
||||
* Adds new "up" and "down" commands to spin up and down the disks of
|
||||
the array. Note that "down" is available only in Linux.
|
||||
|
|
|
|||
250
cmdline/check.c
250
cmdline/check.c
|
|
@ -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) {
|
||||
fprintf(stdlog, "hash_error: Hash mismatch on entry %u\n", failed_map[j]);
|
||||
ftag("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 */
|
||||
fprintf(stdlog, "parity_error:%u:", pos);
|
||||
ftag("parity_error:%u:", pos);
|
||||
for (i = 0; i < r; ++i) {
|
||||
if (i != 0)
|
||||
fprintf(stdlog, "/");
|
||||
fprintf(stdlog, "%s", lev_config_name(ip[i]));
|
||||
ftag("/");
|
||||
ftag("%s", lev_config_name(ip[i]));
|
||||
}
|
||||
fprintf(stdlog, ":parity: Parity mismatch\n");
|
||||
ftag(":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 */
|
||||
fprintf(stdlog, "parity_error:%u:", pos);
|
||||
ftag("parity_error:%u:", pos);
|
||||
for (i = 0; i < r; ++i) {
|
||||
if (i != 0)
|
||||
fprintf(stdlog, "/");
|
||||
fprintf(stdlog, "%s", lev_config_name(ip[i]));
|
||||
ftag("/");
|
||||
ftag("%s", lev_config_name(ip[i]));
|
||||
}
|
||||
fprintf(stdlog, ":hash: Hash mismatch\n");
|
||||
ftag(":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;
|
||||
|
||||
fprintf(stdlog, "strategy_error:%u: No strategy to recover from %u failures with %u parity %s hash\n",
|
||||
ftag("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;
|
||||
|
||||
fprintf(stdlog, "entry:%u:%s:%s:%s:%s:%s:%u:\n", j, state, hash, data, disk, sub, block_file_pos(block));
|
||||
ftag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, state, hash, data, disk, sub, block_file_pos(block));
|
||||
} else {
|
||||
fprintf(stdlog, "entry:%u:%s:%s:%s:\n", j, state, hash, data);
|
||||
ftag("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! */
|
||||
fprintf(stdlog, "hash_import: Fixed entry %u\n", j);
|
||||
ftag("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) {
|
||||
fprintf(stdlog, "recover_sync:%u:%u: Skipped for already recovered\n", pos, n);
|
||||
ftag("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;
|
||||
|
||||
fprintf(stdlog, "hash_unknown: Unknown hash on entry %u\n", j);
|
||||
ftag("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;
|
||||
|
||||
fprintf(stdlog, "hash_unknown: Maybe old zero on entry %u\n", j);
|
||||
ftag("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;
|
||||
|
||||
fprintf(stdlog, "hash_unknown: Maybe old data on entry %u\n", j);
|
||||
ftag("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)
|
||||
fprintf(stdlog, "recover_sync:%u:%u: Failed with no attempts\n", pos, n);
|
||||
ftag("recover_sync:%u:%u: Failed with no attempts\n", pos, n);
|
||||
else
|
||||
fprintf(stdlog, "recover_sync:%u:%u: Failed with %d attempts\n", pos, n, ret);
|
||||
ftag("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;
|
||||
|
||||
fprintf(stdlog, "hash_unknown: Surely old data on entry %u\n", j);
|
||||
ftag("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)
|
||||
fprintf(stdlog, "recover_unsync:%u:%u: Failed with no attempts\n", pos, n);
|
||||
ftag("recover_unsync:%u:%u: Failed with no attempts\n", pos, n);
|
||||
else
|
||||
fprintf(stdlog, "recover_unsync:%u:%u: Failed with %d attempts\n", pos, n, ret);
|
||||
ftag("recover_unsync:%u:%u: Failed with %d attempts\n", pos, n, ret);
|
||||
} else {
|
||||
fprintf(stdlog, "recover_unsync:%u:%u: Skipped for%s%s\n", pos, n,
|
||||
ftag("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 */
|
||||
fprintf(stderr, "Internal inconsistency in opened file for block %u\n", block->parity_pos);
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error closing '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("Error closing '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error renaming '%s' to '%s'. %s.\n", path, path_to, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("Error renaming '%s' to '%s'. %s.\n", path, path_to, strerror(errno));
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stdlog, "status:unrecoverable:%s:%s\n", disk->name, file->sub);
|
||||
ftag("status:unrecoverable:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("unrecoverable %s\n", path);
|
||||
}
|
||||
|
|
@ -688,7 +688,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
|
|||
goto close_and_continue;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", disk->name, file->sub);
|
||||
ftag("status:recovered:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recovered %s\n", path);
|
||||
}
|
||||
|
|
@ -718,35 +718,35 @@ 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);
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
} else {
|
||||
fprintf(stdlog, "collision:%s:%s:%s: Not setting modification time to avoid inode collision\n", disk->name, file->sub, collide_file->sub);
|
||||
ftag("collision:%s:%s:%s: Not setting modification time to avoid inode collision\n", disk->name, file->sub, 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) {
|
||||
fprintf(stdlog, "status:damaged:%s:%s\n", disk->name, file->sub);
|
||||
ftag("status:damaged:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("damaged %s\n", path);
|
||||
}
|
||||
} else {
|
||||
fprintf(stdlog, "status:unrecoverable:%s:%s\n", disk->name, file->sub);
|
||||
ftag("status:unrecoverable:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("unrecoverable %s\n", path);
|
||||
}
|
||||
}
|
||||
} else if (file_flag_has(file, FILE_IS_FIXED)) {
|
||||
fprintf(stdlog, "status:recoverable:%s:%s\n", disk->name, file->sub);
|
||||
ftag("status:recoverable:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recoverable %s\n", path);
|
||||
}
|
||||
} else {
|
||||
fprintf(stdlog, "status:correct:%s:%s\n", disk->name, file->sub);
|
||||
ftag("status:correct:%s:%s\n", disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("correct %s\n", path);
|
||||
}
|
||||
|
|
@ -762,8 +762,8 @@ close_and_continue:
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("Error closing '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -977,7 +977,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected close error in a data disk, it isn't possible to check.\n");
|
||||
ferr("DANGER! Unexpected close error in a data disk, it isn't possible to check.\n");
|
||||
printf("Stopping at block %u\n", i);
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -991,9 +991,9 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == EACCES) {
|
||||
fprintf(stderr, "WARNING! Please give write permission to the file.\n");
|
||||
ferr("WARNING! Please give write permission to the file.\n");
|
||||
} else {
|
||||
fprintf(stderr, "DANGER! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("DANGER! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
}
|
||||
printf("Stopping at block %u\n", i);
|
||||
++unrecoverable_error;
|
||||
|
|
@ -1009,7 +1009,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, stdlog);
|
||||
ret = handle_open(&handle[j], file, state->file_mode, flog);
|
||||
if (ret == -1) {
|
||||
/* save the failed block for the check/fix */
|
||||
failed[failed_count].is_bad = 1;
|
||||
|
|
@ -1019,7 +1019,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
failed[failed_count].handle = &handle[j];
|
||||
++failed_count;
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open error at position %u\n", i, disk->name, file->sub, block_file_pos(block));
|
||||
ftag("error:%u:%s:%s: Open error at position %u\n", i, disk->name, file->sub, block_file_pos(block));
|
||||
++error;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1046,22 +1046,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
|
||||
) {
|
||||
fprintf(stdlog, "File '%s' is larger than expected.\n", handle[j].path);
|
||||
fprintf(stdlog, "error:%u:%s:%s: Size error\n", i, disk->name, file->sub);
|
||||
flog("File '%s' is larger than expected.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Size error\n", i, disk->name, file->sub);
|
||||
++error;
|
||||
|
||||
if (fix) {
|
||||
ret = handle_truncate(&handle[j], file);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected truncate error in a data disk, it isn't possible to fix.\n");
|
||||
ferr("DANGER! Unexpected truncate error in a data disk, it isn't possible to fix.\n");
|
||||
printf("Stopping at block %u\n", i);
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stdlog, "fixed:%u:%s:%s: Fixed size\n", i, disk->name, file->sub);
|
||||
ftag("fixed:%u:%s:%s: Fixed size\n", i, disk->name, file->sub);
|
||||
++recovered_error;
|
||||
}
|
||||
}
|
||||
|
|
@ -1073,7 +1073,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, stdlog);
|
||||
read_size = handle_read(&handle[j], block, buffer[j], state->block_size, flog);
|
||||
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 */
|
||||
|
|
@ -1083,7 +1083,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
failed[failed_count].handle = &handle[j];
|
||||
++failed_count;
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Read error at position %u\n", i, disk->name, file->sub, block_file_pos(block));
|
||||
ftag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, file->sub, block_file_pos(block));
|
||||
++error;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1124,7 +1124,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
failed[failed_count].handle = &handle[j];
|
||||
++failed_count;
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Data error at position %u\n", i, disk->name, file->sub, block_file_pos(block));
|
||||
ftag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, file->sub, block_file_pos(block));
|
||||
++error;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1160,11 +1160,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, stdlog);
|
||||
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, flog);
|
||||
if (ret == -1) {
|
||||
buffer_recov[l] = 0; /* no parity to use */
|
||||
|
||||
fprintf(stdlog, "parity_error:%u:%s: Read error\n", i, lev_config_name(l));
|
||||
ftag("parity_error:%u:%s: Read error\n", i, lev_config_name(l));
|
||||
++error;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1183,7 +1183,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)
|
||||
fprintf(stdlog, "unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].handle->disk->name, block_file_get(failed[j].block)->sub, block_file_pos(failed[j].block));
|
||||
ftag("unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].handle->disk->name, block_file_get(failed[j].block)->sub, block_file_pos(failed[j].block));
|
||||
}
|
||||
|
||||
/* keep track of damaged files */
|
||||
|
|
@ -1201,7 +1201,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;
|
||||
fprintf(stdlog, "unrecoverable:%u:%s:%s: Unrecoverable unsynced error at position %u\n", i, failed[j].handle->disk->name, block_file_get(failed[j].block)->sub, block_file_pos(failed[j].block));
|
||||
ftag("unrecoverable:%u:%s:%s: Unrecoverable unsynced error at position %u\n", i, failed[j].handle->disk->name, block_file_get(failed[j].block)->sub, block_file_pos(failed[j].block));
|
||||
}
|
||||
}
|
||||
if (partial_recover_error != 0) {
|
||||
|
|
@ -1218,7 +1218,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;
|
||||
|
||||
fprintf(stdlog, "parity_error:%u:%s: Data error\n", i, lev_config_name(l));
|
||||
ftag("parity_error:%u:%s: Data error\n", i, lev_config_name(l));
|
||||
++error;
|
||||
}
|
||||
}
|
||||
|
|
@ -1244,10 +1244,10 @@ 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) {
|
||||
fprintf(stderr, "WARNING! Please give write permission to the file.\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
}
|
||||
printf("Stopping at block %u\n", i);
|
||||
++unrecoverable_error;
|
||||
|
|
@ -1266,7 +1266,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);
|
||||
|
||||
fprintf(stdlog, "fixed:%u:%s:%s: Fixed data error at position %u\n", i, failed[j].handle->disk->name, block_file_get(failed[j].block)->sub, block_file_pos(failed[j].block));
|
||||
ftag("fixed:%u:%s:%s: Fixed data error at position %u\n", i, failed[j].handle->disk->name, block_file_get(failed[j].block)->sub, block_file_pos(failed[j].block));
|
||||
++recovered_error;
|
||||
}
|
||||
|
||||
|
|
@ -1281,14 +1281,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 */
|
||||
fprintf(stderr, "WARNING! Without a working %s disk, it isn't possible to fix errors on it.\n", lev_name(l));
|
||||
ferr("WARNING! Without a working %s disk, it isn't possible to fix errors on it.\n", lev_name(l));
|
||||
printf("Stopping at block %u\n", i);
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stdlog, "parity_fixed:%u:%s: Fixed data error\n", i, lev_config_name(l));
|
||||
ftag("parity_fixed:%u:%s: Fixed data error\n", i, lev_config_name(l));
|
||||
++recovered_error;
|
||||
}
|
||||
}
|
||||
|
|
@ -1368,18 +1368,18 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret == -1) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error stating empty file '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stdlog, "error:%s:%s: Empty file stat error\n", disk->name, file->sub);
|
||||
flog("Error stating empty file '%s'. %s.\n", path, strerror(errno));
|
||||
ftag("error:%s:%s: Empty file stat error\n", disk->name, file->sub);
|
||||
++error;
|
||||
} else if (!S_ISREG(st.st_mode)) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "error:%s:%s: Empty file error for not regular file\n", disk->name, file->sub);
|
||||
ftag("error:%s:%s: Empty file error for not regular file\n", disk->name, file->sub);
|
||||
++error;
|
||||
} else if (st.st_size != 0) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, file->sub, st.st_size);
|
||||
ftag("error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, file->sub, st.st_size);
|
||||
++error;
|
||||
}
|
||||
|
||||
|
|
@ -1390,7 +1390,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1402,12 +1402,12 @@ 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 */
|
||||
fprintf(stderr, "Error creating empty file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("Error creating empty file '%s'. %s.\n", path, strerror(errno));
|
||||
if (errno == EACCES) {
|
||||
fprintf(stderr, "WARNING! Please give write permission to the file.\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
}
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
|
|
@ -1421,8 +1421,8 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_START */
|
||||
close(f);
|
||||
|
||||
fprintf(stderr, "Error timing file '%s'. %s.\n", file->sub, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("Error timing file '%s'. %s.\n", file->sub, strerror(errno));
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1433,17 +1433,17 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = close(f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stdlog, "fixed:%s:%s: Fixed empty file\n", disk->name, file->sub);
|
||||
ftag("fixed:%s:%s: Fixed empty file\n", disk->name, file->sub);
|
||||
++recovered_error;
|
||||
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", disk->name, file->sub);
|
||||
ftag("status:recovered:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recovered %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
|
|
@ -1478,13 +1478,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret == -1) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error stating hardlink '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink stat error\n", disk->name, link->sub, link->linkto);
|
||||
flog("Error stating hardlink '%s'. %s.\n", path, strerror(errno));
|
||||
ftag("hardlinkerror:%s:%s:%s: Hardlink stat error\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
} else if (!S_ISREG(st.st_mode)) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink error for not regular file\n", disk->name, link->sub, link->linkto);
|
||||
ftag("hardlinkerror:%s:%s:%s: Hardlink error for not regular file\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
}
|
||||
|
||||
|
|
@ -1508,19 +1508,19 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(stdlog, "Error stating hardlink-to '%s'. %s.\n", pathto, strerror(errno));
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink to stat error\n", disk->name, link->sub, link->linkto);
|
||||
flog("Error stating hardlink-to '%s'. %s.\n", pathto, strerror(errno));
|
||||
ftag("hardlinkerror:%s:%s:%s: Hardlink to stat error\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
} else if (!S_ISREG(stto.st_mode)) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink-to error for not regular file\n", disk->name, link->sub, link->linkto);
|
||||
ftag("hardlinkerror:%s:%s:%s: Hardlink-to error for not regular file\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
} else if (!unsuccesful && st.st_ino != stto.st_ino) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Mismatch hardlink '%s' and '%s'. Different inode.\n", path, pathto);
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink mismatch for different inode\n", disk->name, link->sub, link->linkto);
|
||||
flog("Mismatch hardlink '%s' and '%s'. Different inode.\n", path, pathto);
|
||||
ftag("hardlinkerror:%s:%s:%s: Hardlink mismatch for different inode\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1530,14 +1530,14 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret < 0) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error reading symlink '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stdlog, "symlinkerror:%s:%s: Symlink read error\n", disk->name, link->sub);
|
||||
flog("Error reading symlink '%s'. %s.\n", path, strerror(errno));
|
||||
ftag("symlinkerror:%s:%s: Symlink read error\n", disk->name, link->sub);
|
||||
++error;
|
||||
} else if (ret >= PATH_MAX) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error reading symlink '%s'. Symlink too long.\n", path);
|
||||
fprintf(stdlog, "symlinkerror:%s:%s: Symlink read error\n", disk->name, link->sub);
|
||||
flog("Error reading symlink '%s'. Symlink too long.\n", path);
|
||||
ftag("symlinkerror:%s:%s: Symlink read error\n", disk->name, link->sub);
|
||||
++error;
|
||||
} else {
|
||||
linkto[ret] = 0;
|
||||
|
|
@ -1545,7 +1545,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (strcmp(linkto, link->linkto) != 0) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "symlinkerror:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, link->sub, linkto, link->linkto);
|
||||
ftag("symlinkerror:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, link->sub, linkto, link->linkto);
|
||||
++error;
|
||||
}
|
||||
}
|
||||
|
|
@ -1556,7 +1556,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1567,8 +1567,8 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = remove(path);
|
||||
if (ret != 0 && errno != ENOENT) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("Error removing '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1580,12 +1580,12 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = hardlink(pathto, path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing hardlink '%s' to '%s'. %s.\n", path, pathto, strerror(errno));
|
||||
ferr("Error writing hardlink '%s' to '%s'. %s.\n", path, pathto, strerror(errno));
|
||||
if (errno == EACCES) {
|
||||
fprintf(stderr, "WARNING! Please give write permission to the hardlink.\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
}
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
|
|
@ -1593,18 +1593,18 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stdlog, "hardlinkfixed:%s:%s: Fixed hardlink error\n", disk->name, link->sub);
|
||||
ftag("hardlinkfixed:%s:%s: Fixed hardlink error\n", disk->name, link->sub);
|
||||
++recovered_error;
|
||||
} else {
|
||||
ret = symlink(link->linkto, path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing symlink '%s' to '%s'. %s.\n", path, link->linkto, strerror(errno));
|
||||
ferr("Error writing symlink '%s' to '%s'. %s.\n", path, link->linkto, strerror(errno));
|
||||
if (errno == EACCES) {
|
||||
fprintf(stderr, "WARNING! Please give write permission to the symlink.\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
}
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
|
|
@ -1612,11 +1612,11 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stdlog, "symlinkfixed:%s:%s: Fixed symlink error\n", disk->name, link->sub);
|
||||
ftag("symlinkfixed:%s:%s: Fixed symlink error\n", disk->name, link->sub);
|
||||
++recovered_error;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", disk->name, link->sub);
|
||||
ftag("status:recovered:%s:%s\n", disk->name, link->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recovered %s%s\n", disk->dir, link->sub);
|
||||
}
|
||||
|
|
@ -1646,13 +1646,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret == -1) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error stating dir '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stdlog, "dir_error:%s:%s: Dir stat error\n", disk->name, dir->sub);
|
||||
flog("Error stating dir '%s'. %s.\n", path, strerror(errno));
|
||||
ftag("dir_error:%s:%s: Dir stat error\n", disk->name, dir->sub);
|
||||
++error;
|
||||
} else if (!S_ISDIR(st.st_mode)) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "dir_error:%s:%s: Dir error for not directory\n", disk->name, dir->sub);
|
||||
ftag("dir_error:%s:%s: Dir error for not directory\n", disk->name, dir->sub);
|
||||
++error;
|
||||
}
|
||||
|
||||
|
|
@ -1661,7 +1661,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1672,12 +1672,12 @@ 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 */
|
||||
fprintf(stderr, "Error creating dir '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("Error creating dir '%s'. %s.\n", path, strerror(errno));
|
||||
if (errno == EACCES) {
|
||||
fprintf(stderr, "WARNING! Please give write permission to the dir.\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
}
|
||||
printf("Stopping\n");
|
||||
++unrecoverable_error;
|
||||
|
|
@ -1685,10 +1685,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stdlog, "dir_fixed:%s:%s: Fixed dir error\n", disk->name, dir->sub);
|
||||
ftag("dir_fixed:%s:%s: Fixed dir error\n", disk->name, dir->sub);
|
||||
++recovered_error;
|
||||
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", disk->name, dir->sub);
|
||||
ftag("status:recovered:%s:%s\n", disk->name, dir->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recovered %s%s\n", disk->dir, dir->sub);
|
||||
}
|
||||
|
|
@ -1704,7 +1704,7 @@ bail:
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected close error in a data disk.\n");
|
||||
ferr("DANGER! Unexpected close error in a data disk.\n");
|
||||
++unrecoverable_error;
|
||||
/* continue, as we are already exiting */
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1752,8 +1752,8 @@ bail:
|
|||
ret = remove(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
|
||||
ferr("Error removing '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
|
|
@ -1784,30 +1784,30 @@ bail:
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
fprintf(stdlog, "summary:error:%u\n", error);
|
||||
ftag("summary:error:%u\n", error);
|
||||
if (fix)
|
||||
fprintf(stdlog, "summary:error_recovered:%u\n", recovered_error);
|
||||
ftag("summary:error_recovered:%u\n", recovered_error);
|
||||
if (!state->opt.auditonly)
|
||||
fprintf(stdlog, "summary:error_unrecoverable:%u\n", unrecoverable_error);
|
||||
ftag("summary:error_unrecoverable:%u\n", unrecoverable_error);
|
||||
if (fix) {
|
||||
if (error + recovered_error + unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
ftag("summary:exit:ok\n");
|
||||
else if (unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:recovered\n");
|
||||
ftag("summary:exit:recovered\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:unrecoverable\n");
|
||||
ftag("summary:exit:unrecoverable\n");
|
||||
} else if (!state->opt.auditonly) {
|
||||
if (error + unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
ftag("summary:exit:ok\n");
|
||||
else if (unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:recoverable\n");
|
||||
ftag("summary:exit:recoverable\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:unrecoverable\n");
|
||||
ftag("summary:exit:unrecoverable\n");
|
||||
} else { /* audit only */
|
||||
if (error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
ftag("summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
ftag("summary:exit:error\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
|
||||
|
|
@ -1860,7 +1860,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
|
|||
|
||||
if (blockstart > blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error in the specified starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
|
||||
ferr("Error in the specified starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1878,7 +1878,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 */
|
||||
fprintf(stderr, "WARNING! Without an accessible %s file, it isn't possible to fix any error.\n", lev_name(l));
|
||||
ferr("WARNING! Without an accessible %s file, it isn't possible to fix any error.\n", lev_name(l));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1886,7 +1886,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 */
|
||||
fprintf(stderr, "WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
ferr("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1935,7 +1935,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) {
|
||||
fprintf(stderr, "DANGER! Unexpected close error in %s disk.\n", lev_name(l));
|
||||
ferr("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
|
||||
++error;
|
||||
/* continue, as we are already exiting */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -449,17 +449,17 @@ static void state_smart(int verbose, unsigned n, tommy_list* low)
|
|||
|
||||
printf("\n");
|
||||
|
||||
fprintf(stdlog, "smart:%s:%s:%s:%g\n", devinfo->file, devinfo->name, devinfo->smart_serial, afr);
|
||||
ftag("smart:%s:%s:%s:%g\n", devinfo->file, devinfo->name, devinfo->smart_serial, afr);
|
||||
for (j = 0; j < 256; ++j) {
|
||||
if (devinfo->smart[j] != SMART_UNASSIGNED)
|
||||
fprintf(stdlog, "attr:%s:%u:%" PRIu64 "\n", devinfo->file, j, devinfo->smart[j]);
|
||||
ftag("attr:%s:%u:%" PRIu64 "\n", devinfo->file, j, devinfo->smart[j]);
|
||||
}
|
||||
if (devinfo->smart[SMART_SIZE] != SMART_UNASSIGNED)
|
||||
fprintf(stdlog, "attr:%s:size:%" PRIu64 "\n", devinfo->file, devinfo->smart[SMART_SIZE]);
|
||||
ftag("attr:%s:size:%" PRIu64 "\n", devinfo->file, devinfo->smart[SMART_SIZE]);
|
||||
if (devinfo->smart[SMART_ERROR] != SMART_UNASSIGNED)
|
||||
fprintf(stdlog, "attr:%s:error:%" PRIu64 "\n", devinfo->file, devinfo->smart[SMART_ERROR]);
|
||||
ftag("attr:%s:error:%" PRIu64 "\n", devinfo->file, devinfo->smart[SMART_ERROR]);
|
||||
if (devinfo->smart[SMART_ROTATION_RATE] != SMART_UNASSIGNED)
|
||||
fprintf(stdlog, "attr:%s:rotationrate:%" PRIu64 "\n", devinfo->file, devinfo->smart[SMART_ROTATION_RATE]);
|
||||
ftag("attr:%s:rotationrate:%" PRIu64 "\n", devinfo->file, devinfo->smart[SMART_ROTATION_RATE]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
|
@ -470,7 +470,7 @@ static void state_smart(int verbose, unsigned n, tommy_list* low)
|
|||
*/
|
||||
p_at_least_one_failure = poisson_prob_n_or_more_failures(array_failure_rate, 1);
|
||||
|
||||
fprintf(stdlog, "summary:array_failure:%g:%g\n", array_failure_rate, p_at_least_one_failure);
|
||||
ftag("summary:array_failure:%g:%g\n", array_failure_rate, p_at_least_one_failure);
|
||||
|
||||
/* |<##################################################################72>|####80>| */
|
||||
printf("The FP column is the estimated probability (in percentage) that the disk\n");
|
||||
|
|
@ -564,12 +564,12 @@ void state_device(struct snapraid_state* state, int operation)
|
|||
|
||||
if (devquery(&high, &low, operation) != 0) {
|
||||
switch (operation) {
|
||||
case DEVICE_UP : fprintf(stderr, "Spinup"); break;
|
||||
case DEVICE_DOWN : fprintf(stderr, "Spindown"); break;
|
||||
case DEVICE_LIST : fprintf(stderr, "List"); break;
|
||||
case DEVICE_SMART : fprintf(stderr, "SMART"); break;
|
||||
case DEVICE_UP : ferr("Spinup"); break;
|
||||
case DEVICE_DOWN : ferr("Spindown"); break;
|
||||
case DEVICE_LIST : ferr("List"); break;
|
||||
case DEVICE_SMART : ferr("SMART"); break;
|
||||
}
|
||||
fprintf(stderr, " unsupported in this platform.\n");
|
||||
ferr(" unsupported in this platform.\n");
|
||||
} else {
|
||||
|
||||
#ifndef _WIN32
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected close error in a data disk, it isn't possible to dry.\n");
|
||||
ferr("DANGER! Unexpected close error in a data disk, it isn't possible to dry.\n");
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -90,10 +90,10 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
|
|||
}
|
||||
|
||||
/* open the file only for reading */
|
||||
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, stdlog);
|
||||
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, ferr);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected open error in a data disk, it isn't possible to dry.\n");
|
||||
ferr("DANGER! Unexpected open error in a data disk, it isn't possible to dry.\n");
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -102,9 +102,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, stdlog);
|
||||
read_size = handle_read(&handle[j], block, buffer_aligned, state->block_size, flog);
|
||||
if (read_size == -1) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Read error at position %u\n", i, disk->name, block_file_get(block)->sub, block_file_pos(block));
|
||||
ftag("error:%u:%s:%s: Read error at position %u\n", i, disk->name, block_file_get(block)->sub, block_file_pos(block));
|
||||
++error;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -121,9 +121,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, stdlog);
|
||||
ret = parity_read(parity[l], i, buffer_aligned, state->block_size, flog);
|
||||
if (ret == -1) {
|
||||
fprintf(stdlog, "parity_error:%u:%s: Read error\n", i, lev_config_name(l));
|
||||
ftag("parity_error:%u:%s: Read error\n", i, lev_config_name(l));
|
||||
++error;
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ bail:
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected close error in a data disk.\n");
|
||||
ferr("DANGER! Unexpected close error in a data disk.\n");
|
||||
++error;
|
||||
/* continue, as we are already exiting */
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -191,7 +191,7 @@ void state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
|
||||
if (blockstart > blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error in the specified starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
|
||||
ferr("Error in the specified starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ void state_dup(struct snapraid_state* state)
|
|||
if (dup) {
|
||||
++count;
|
||||
size += dup->file->size;
|
||||
fprintf(stdlog, "dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, file->sub, dup->disk->name, dup->file->sub, dup->file->size);
|
||||
ftag("dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, file->sub, dup->disk->name, 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,12 +144,12 @@ void state_dup(struct snapraid_state* state)
|
|||
else
|
||||
printf("No duplicates\n");
|
||||
|
||||
fprintf(stdlog, "summary:dup_count:%u\n", count);
|
||||
fprintf(stdlog, "summary:dup_size:%" PRIu64 "\n", size);
|
||||
ftag("summary:dup_count:%u\n", count);
|
||||
ftag("summary:dup_size:%" PRIu64 "\n", size);
|
||||
if (count == 0) {
|
||||
fprintf(stdlog, "summary:exit:unique\n");
|
||||
ftag("summary:exit:unique\n");
|
||||
} else {
|
||||
fprintf(stdlog, "summary:exit:dup\n");
|
||||
ftag("summary:exit:dup\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ int filter_existence(int filter_missing, const char* dir, const char* sub)
|
|||
if (errno == ENOENT)
|
||||
return 0;
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error in stat file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Internal inconsistency in block %u ownership\n", block->parity_pos);
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Internal inconsistency in copy file with different size\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Internal inconsistency in copy file with different mtime_sec\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Internal inconsistency in copy file with different mtime_nsec\n");
|
||||
ferr("Internal inconsistency in copy file with different mtime_nsec\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -747,7 +747,7 @@ int disk_is_empty(struct snapraid_disk* disk, block_off_t blockmax)
|
|||
return 0;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Internal inconsistency for used block in disk '%s' without files\n", disk->name);
|
||||
ferr("Internal inconsistency for used block in disk '%s' without files\n", disk->name);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
|
|||
handle->f = -1;
|
||||
handle->valid_size = 0;
|
||||
|
||||
fprintf(stderr, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error advising file '%s'. %s.\n", handle->path, strerror(ret));
|
||||
ferr("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) {
|
||||
fprintf(stderr, "Failed to truncate file '%s' for missing write permission.\n", handle->path);
|
||||
ferr("Failed to truncate file '%s' for missing write permission.\n", handle->path);
|
||||
} else {
|
||||
fprintf(stderr, "Error truncating file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
ferr("Error truncating file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -148,7 +148,7 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, FILE* out)
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out)
|
||||
{
|
||||
int ret;
|
||||
int flags;
|
||||
|
|
@ -179,7 +179,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
|
|||
handle->f = -1;
|
||||
handle->valid_size = 0;
|
||||
|
||||
fprintf(out, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
out("Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
|
|||
ret = fstat(handle->f, &handle->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(out, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
out("Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
|
|||
ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(out, "Error advising file '%s'. %s.\n", handle->path, strerror(ret));
|
||||
out("Error advising file '%s'. %s.\n", handle->path, strerror(ret));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -223,7 +223,7 @@ int handle_close(struct snapraid_handle* handle)
|
|||
ret = close(handle->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing file '%s'. %s.\n", handle->file->sub, strerror(errno));
|
||||
ferr("Error closing file '%s'. %s.\n", handle->file->sub, strerror(errno));
|
||||
|
||||
/* invalidate for error */
|
||||
handle->file = 0;
|
||||
|
|
@ -242,7 +242,7 @@ int handle_close(struct snapraid_handle* handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* out)
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, fptr* out)
|
||||
{
|
||||
ssize_t read_ret;
|
||||
data_off_t offset;
|
||||
|
|
@ -253,7 +253,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
|
||||
/* check if we are going to read only not initialized data */
|
||||
if (offset >= handle->valid_size) {
|
||||
fprintf(out, "Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
#if !HAVE_PREAD
|
||||
if (lseek(handle->f, offset, SEEK_SET) != offset) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(out, "Error seeking file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
|
||||
out("Error seeking file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -279,12 +279,12 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
|
||||
if (read_ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(out, "Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, read_size - count, strerror(errno));
|
||||
out("Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, read_size - count, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (read_ret == 0) {
|
||||
fprintf(out, "Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
|
||||
out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +325,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 */
|
||||
fprintf(stderr, "Error seeking file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
ferr("Error seeking file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -334,7 +334,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 */
|
||||
fprintf(stderr, "Error writing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
ferr("Error writing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -362,7 +362,7 @@ int handle_utime(struct snapraid_handle* handle)
|
|||
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error timing file '%s'. %s.\n", handle->file->sub, strerror(errno));
|
||||
ferr("Error timing file '%s'. %s.\n", handle->file->sub, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -410,7 +410,7 @@ struct snapraid_handle* handle_map(struct snapraid_state* state, unsigned* handl
|
|||
}
|
||||
if (k == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Internal error for inconsistent disk mapping.\n");
|
||||
ferr("Internal error for inconsistent disk mapping.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#define __HANDLE_H
|
||||
|
||||
#include "state.h"
|
||||
#include "support.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* handle */
|
||||
|
|
@ -52,7 +53,7 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file);
|
|||
* Opens a file.
|
||||
* The file is opened for reading.
|
||||
*/
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, FILE* out);
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out);
|
||||
|
||||
/**
|
||||
* Closes a file.
|
||||
|
|
@ -63,7 +64,7 @@ int handle_close(struct snapraid_handle* handle);
|
|||
* Read a block from a file.
|
||||
* If the read block is shorter, it's padded with 0.
|
||||
*/
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, FILE* out);
|
||||
int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size, fptr* out);
|
||||
|
||||
/**
|
||||
* Writes a block to a 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 */
|
||||
fprintf(stderr, "Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error advising file '%s'. %s.\n", path, strerror(ret));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error seeking file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error in data reading file '%s'.\n", path);
|
||||
fprintf(stderr, "Please don't change imported files while running.\n");
|
||||
ferr("Error in data reading file '%s'.\n", path);
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error opening directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void state_list(struct snapraid_state* state)
|
|||
++file_count;
|
||||
file_size += file->size;
|
||||
|
||||
fprintf(stdlog, "file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, file->sub, file->size, file->mtime_sec, file->mtime_nsec, file->inode);
|
||||
ftag("file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, file->sub, file->size, file->mtime_sec, file->mtime_nsec, file->inode);
|
||||
|
||||
t = file->mtime_sec;
|
||||
#if HAVE_LOCALTIME_R
|
||||
|
|
@ -99,7 +99,7 @@ void state_list(struct snapraid_state* state)
|
|||
|
||||
++link_count;
|
||||
|
||||
fprintf(stdlog, "link_%s:%s:%s:%s\n", type, disk->name, link->sub, link->linkto);
|
||||
ftag("link_%s:%s:%s:%s\n", type, disk->name, link->sub, link->linkto);
|
||||
|
||||
printf("%12s ", type);
|
||||
printf(" ");
|
||||
|
|
@ -113,10 +113,10 @@ void state_list(struct snapraid_state* state)
|
|||
printf("%8u files, for %" PRIu64 " GiB\n", file_count, file_size / (1024 * 1024 * 1024));
|
||||
printf("%8u links\n", link_count);
|
||||
|
||||
fprintf(stdlog, "summary:file_count:%u\n", file_count);
|
||||
fprintf(stdlog, "summary:file_size:%" PRIu64 "\n", file_size);
|
||||
fprintf(stdlog, "summary:link_count:%u\n", link_count);
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
ftag("summary:file_count:%u\n", file_count);
|
||||
ftag("summary:file_size:%" PRIu64 "\n", file_size);
|
||||
ftag("summary:link_count:%u\n", link_count);
|
||||
ftag("summary:exit:ok\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,19 +137,19 @@ void os_init(int opt)
|
|||
|
||||
ntdll = GetModuleHandle("NTDLL.DLL");
|
||||
if (!ntdll) {
|
||||
fprintf(stderr, "Error loading the NTDLL module.\n");
|
||||
ferr("Error loading the NTDLL module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
kernel32 = GetModuleHandle("KERNEL32.DLL");
|
||||
if (!kernel32) {
|
||||
fprintf(stderr, "Error loading the KERNEL32 module.\n");
|
||||
ferr("Error loading the KERNEL32 module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dll_advapi32 = LoadLibrary("ADVAPI32.DLL");
|
||||
if (!dll_advapi32) {
|
||||
fprintf(stderr, "Error loading the ADVAPI32 module.\n");
|
||||
ferr("Error loading the ADVAPI32 module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ void os_init(int opt)
|
|||
|
||||
ptr_RtlGenRandom = (void*)GetProcAddress(dll_advapi32, "SystemFunction036");
|
||||
if (!ptr_RtlGenRandom) {
|
||||
fprintf(stderr, "Error loading RtlGenRandom() from the ADVAPI32 module.\n");
|
||||
ferr("Error loading RtlGenRandom() from the ADVAPI32 module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ static wchar_t* u8tou16(const char* src)
|
|||
ret = MultiByteToWideChar(CP_UTF8, 0, src, -1, conv_utf16_buffer[conv_utf16], sizeof(conv_utf16_buffer[0]) / sizeof(wchar_t));
|
||||
|
||||
if (ret <= 0) {
|
||||
fprintf(stderr, "Error converting name '%s' from UTF-8 to UTF-16\n", src);
|
||||
ferr("Error converting name '%s' from UTF-8 to UTF-16\n", src);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ static char* u16tou8(const wchar_t* src, size_t number_of_wchar, size_t* result_
|
|||
|
||||
ret = WideCharToMultiByte(CP_UTF8, 0, src, number_of_wchar, conv_utf8_buffer[conv_utf8], sizeof(conv_utf8_buffer[0]), 0, 0);
|
||||
if (ret <= 0) {
|
||||
fprintf(stderr, "Error converting from UTF-16 to UTF-8\n");
|
||||
ferr("Error converting from UTF-16 to UTF-8\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +322,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) {
|
||||
fprintf(stderr, "Error converting name '%s' from UTF-8 to UTF-16\n", src);
|
||||
ferr("Error converting name '%s' from UTF-8 to UTF-16\n", src);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -556,7 +556,7 @@ static void windows_finddata2dirent(const WIN32_FIND_DATAW* info, struct windows
|
|||
name = u16tou8(info->cFileName, wcslen(info->cFileName), &len);
|
||||
|
||||
if (len + 1 >= sizeof(dirent->d_name)) {
|
||||
fprintf(stderr, "Name too long\n");
|
||||
ferr("Name too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -574,7 +574,7 @@ static void windows_stream2dirent(const BY_HANDLE_FILE_INFORMATION* info, const
|
|||
name = u16tou8(stream->FileName, stream->FileNameLength / 2, &len);
|
||||
|
||||
if (len + 1 >= sizeof(dirent->d_name)) {
|
||||
fprintf(stderr, "Name too long\n");
|
||||
ferr("Name too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -625,7 +625,7 @@ static void windows_errno(DWORD error)
|
|||
errno = EPERM;
|
||||
break;
|
||||
default :
|
||||
fprintf(stderr, "Unexpected Windows error %d.\n", (int)error);
|
||||
ferr("Unexpected Windows error %d.\n", (int)error);
|
||||
errno = EIO;
|
||||
break;
|
||||
}
|
||||
|
|
@ -924,8 +924,8 @@ int windows_fsync(int fd)
|
|||
* this error, but not enough sure to ignore it.
|
||||
* So, we use now an extended error reporting.
|
||||
*/
|
||||
fprintf(stderr, "Unexpected Windows INVALID_HANDLE error in FlushFileBuffers().\n");
|
||||
fprintf(stderr, "Are you using ATA-over-Ethernet ? Please report it.\n");
|
||||
ferr("Unexpected Windows INVALID_HANDLE error in FlushFileBuffers().\n");
|
||||
ferr("Are you using ATA-over-Ethernet ? Please report it.\n");
|
||||
|
||||
/* normal error processing */
|
||||
windows_errno(error);
|
||||
|
|
@ -1056,7 +1056,7 @@ static windows_dir* windows_opendir_find(const char* dir)
|
|||
|
||||
dirstream = malloc(sizeof(windows_dir));
|
||||
if (!dirstream) {
|
||||
fprintf(stderr, "Low memory\n");
|
||||
ferr("Low memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -1193,7 +1193,7 @@ static windows_dir* windows_opendir_stream(const char* dir)
|
|||
|
||||
dirstream = malloc(sizeof(windows_dir));
|
||||
if (!dirstream) {
|
||||
fprintf(stderr, "Low memory\n");
|
||||
ferr("Low memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -1203,7 +1203,7 @@ static windows_dir* windows_opendir_stream(const char* dir)
|
|||
dirstream->buffer_size = 64 * 1024;
|
||||
dirstream->buffer = malloc(dirstream->buffer_size);
|
||||
if (!dirstream->buffer) {
|
||||
fprintf(stderr, "Low memory\n");
|
||||
ferr("Low memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -1680,7 +1680,7 @@ retry:
|
|||
* https://sourceforge.net/p/snapraid/discussion/1677233/thread/a7c25ba9/
|
||||
*/
|
||||
if (err == ERROR_NO_SYSTEM_RESOURCES) {
|
||||
fprintf(stderr, "Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pread(), retrying...\n");
|
||||
ferr("Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pread(), retrying...\n");
|
||||
Sleep(50);
|
||||
goto retry;
|
||||
}
|
||||
|
|
@ -1720,7 +1720,7 @@ retry:
|
|||
DWORD err = GetLastError();
|
||||
/* See windows_pread() for comments on this error management */
|
||||
if (err == ERROR_NO_SYSTEM_RESOURCES) {
|
||||
fprintf(stderr, "Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pwrite(), retrying...\n");
|
||||
ferr("Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pwrite(), retrying...\n");
|
||||
Sleep(50);
|
||||
goto retry;
|
||||
}
|
||||
|
|
@ -1787,7 +1787,7 @@ static int devscan(tommy_list* list)
|
|||
f = popen(cmd, "r");
|
||||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctl --scan-open (from popen).\n");
|
||||
ferr("Failed to run smartctl --scan-open (from popen).\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1802,13 +1802,13 @@ static int devscan(tommy_list* list)
|
|||
ret = pclose(f);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctl --scan-open (from pclose).\n");
|
||||
ferr("Failed to run smartctl --scan-open (from pclose).\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctl --scan-open with return code %xh.\n", ret);
|
||||
ferr("Failed to run smartctl --scan-open with return code %xh.\n", ret);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1830,7 +1830,7 @@ static int devsmart(const char* file, uint64_t* smart, char* serial)
|
|||
f = popen(cmd, "r");
|
||||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctl -a on device '%s' (from open).\n", file);
|
||||
ferr("Failed to run smartctl -a on device '%s' (from open).\n", file);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1845,7 +1845,7 @@ static int devsmart(const char* file, uint64_t* smart, char* serial)
|
|||
ret = pclose(f);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctl -a on device '%s' (from pclose).\n", file);
|
||||
ferr("Failed to run smartctl -a on device '%s' (from pclose).\n", file);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1882,7 +1882,7 @@ static void* thread_spinup(void* arg)
|
|||
if (lstat(devinfo->mount, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
pthread_mutex_lock(&io_lock);
|
||||
fprintf(stderr, "Failed to stat devinfo '%s'. %s.\n", devinfo->mount, strerror(errno));
|
||||
ferr("Failed to stat devinfo '%s'. %s.\n", devinfo->mount, strerror(errno));
|
||||
pthread_mutex_unlock(&io_lock);
|
||||
return (void*)-1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1940,7 +1940,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
|
|||
|
||||
if (pthread_create(&devinfo->thread, 0, func, devinfo) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to create thread.\n");
|
||||
ferr("Failed to create thread.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1953,7 +1953,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
|
|||
|
||||
if (pthread_join(devinfo->thread, &retval) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to join thread.\n");
|
||||
ferr("Failed to join thread.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "portable.h"
|
||||
|
||||
#include "support.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* random */
|
||||
|
||||
|
|
@ -147,7 +149,7 @@ void cmd_generate_file(const char* path, int size)
|
|||
if (remove(path) != 0) {
|
||||
if (errno != ENOENT) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing file %s\n", path);
|
||||
ferr("Error removing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -169,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 */
|
||||
fprintf(stderr, "Error creating file %s\n", path);
|
||||
ferr("Error creating file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (write(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing file %s\n", path);
|
||||
ferr("Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing file %s\n", path);
|
||||
ferr("Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -201,7 +203,7 @@ void cmd_generate_symlink(const char* path, const char* linkto)
|
|||
if (remove(path) != 0) {
|
||||
if (errno != ENOENT) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing file %s\n", path);
|
||||
ferr("Error removing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -209,7 +211,7 @@ void cmd_generate_symlink(const char* path, const char* linkto)
|
|||
|
||||
if (symlink(linkto, path) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing symlink %s\n", path);
|
||||
ferr("Error writing symlink %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -234,7 +236,7 @@ void cmd_generate(int disk, int size)
|
|||
if (mkdir(path, 0777) != 0) {
|
||||
if (errno != EEXIST) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error creating directory %s\n", path);
|
||||
ferr("Error creating directory %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -292,7 +294,7 @@ void cmd_write(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error accessing %s\n", path);
|
||||
ferr("Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -319,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 */
|
||||
fprintf(stderr, "Error creating file %s\n", path);
|
||||
ferr("Error creating file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (lseek(f, off, SEEK_SET) != off) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error seeking file %s\n", path);
|
||||
ferr("Error seeking file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (write(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing file %s\n", path);
|
||||
ferr("Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing file %s\n", path);
|
||||
ferr("Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -368,7 +370,7 @@ void cmd_damage(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error accessing %s\n", path);
|
||||
ferr("Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -396,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 */
|
||||
fprintf(stderr, "Error creating file %s\n", path);
|
||||
ferr("Error creating file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (lseek(f, off, SEEK_SET) != off) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error seeking file %s\n", path);
|
||||
ferr("Error seeking file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (read(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing file %s\n", path);
|
||||
ferr("Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -419,28 +421,28 @@ void cmd_damage(const char* path, int size)
|
|||
|
||||
if (lseek(f, off, SEEK_SET) != off) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error seeking file %s\n", path);
|
||||
ferr("Error seeking file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (write(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing file %s\n", path);
|
||||
ferr("Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (fallback(f, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error setting time for file %s\n", path);
|
||||
ferr("Error setting time for file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing file %s\n", path);
|
||||
ferr("Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -460,7 +462,7 @@ void cmd_append(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error accessing %s\n", path);
|
||||
ferr("Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -476,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 */
|
||||
fprintf(stderr, "Error opening file %s\n", path);
|
||||
ferr("Error opening file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (write(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing file %s\n", path);
|
||||
ferr("Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing file %s\n", path);
|
||||
ferr("Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -511,7 +513,7 @@ void cmd_truncate(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error accessing %s\n", path);
|
||||
ferr("Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -534,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 */
|
||||
fprintf(stderr, "Error opening file %s\n", path);
|
||||
ferr("Error opening file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (ftruncate(f, off) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error truncating file %s\n", path);
|
||||
ferr("Error truncating file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing file %s\n", path);
|
||||
ferr("Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -563,7 +565,7 @@ void cmd_delete(const char* path)
|
|||
{
|
||||
if (remove(path) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing %s\n", path);
|
||||
ferr("Error removing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -582,7 +584,7 @@ void cmd_change(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error accessing %s\n", path);
|
||||
ferr("Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -593,7 +595,7 @@ void cmd_change(const char* path, int size)
|
|||
/* delete */
|
||||
if (remove(path) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing %s\n", path);
|
||||
ferr("Error removing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -603,7 +605,7 @@ void cmd_change(const char* path, int size)
|
|||
|
||||
if (remove(path) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing %s\n", path);
|
||||
ferr("Error removing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
fprintf(stderr, "Failed to get random values.\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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);
|
||||
fprintf(stderr, "Error accessing file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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);
|
||||
fprintf(stderr, "Error timing file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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);
|
||||
fprintf(stderr, "Error accessing file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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;
|
||||
|
||||
fprintf(stdlog, "nano:%s:%s\n", disk->name, file->sub);
|
||||
ftag("nano:%s:%s\n", disk->name, file->sub);
|
||||
printf("nano %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
|
|||
|
||||
if (file->blockmax > 0) {
|
||||
if (file->blockvec[file->blockmax - 1].parity_pos >= blockalloc) {
|
||||
fprintf(stdlog, "outofparity:%s:%s\n", disk->name, file->sub);
|
||||
ftag("outofparity:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stdlog);
|
||||
if (first) {
|
||||
first = 0;
|
||||
|
|
@ -131,7 +131,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 */
|
||||
fprintf(stderr, "Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -140,7 +140,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 */
|
||||
fprintf(stderr, "Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -151,7 +151,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 */
|
||||
fprintf(stderr, "Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
|
||||
ferr("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -227,7 +227,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 */
|
||||
fprintf(stderr, "Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -239,9 +239,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) {
|
||||
fprintf(stderr, "Failed to grow parity file '%s' to size %" PRIu64 " using %s due lack of space.\n", parity->path, size, call);
|
||||
ferr("Failed to grow parity file '%s' to size %" PRIu64 " using %s due lack of space.\n", parity->path, size, call);
|
||||
} else {
|
||||
fprintf(stderr, "Error growing parity file '%s' to size %" PRIu64 " using %s. Do you have enough space? %s.\n", parity->path, size, call, strerror(f_errno));
|
||||
ferr("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 */
|
||||
|
|
@ -261,7 +261,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 */
|
||||
fprintf(stderr, "Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -272,7 +272,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 */
|
||||
fprintf(stderr, "Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", parity->path, size, strerror(f_errno));
|
||||
ferr("Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", parity->path, size, strerror(f_errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -305,7 +305,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) {
|
||||
fprintf(stderr, "Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error opening parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +313,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 */
|
||||
fprintf(stderr, "Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error accessing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -327,7 +327,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 */
|
||||
fprintf(stderr, "Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
|
||||
ferr("Error advising parity file '%s'. %s.\n", parity->path, strerror(ret));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -356,7 +356,7 @@ int parity_sync(struct snapraid_parity_handle* parity)
|
|||
ret = fsync(parity->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error synching parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error synching parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -379,7 +379,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 */
|
||||
fprintf(stderr, "Error closing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error closing parity file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -404,9 +404,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) {
|
||||
fprintf(stderr, "Failed to grow parity file '%s' using lseek due lack of space.\n", parity->path);
|
||||
ferr("Failed to grow parity file '%s' using lseek due lack of space.\n", parity->path);
|
||||
} else {
|
||||
fprintf(stderr, "Error seeking file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error seeking file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -417,9 +417,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) {
|
||||
fprintf(stderr, "Failed to grow parity file '%s' using write due lack of space.\n", parity->path);
|
||||
ferr("Failed to grow parity file '%s' using write due lack of space.\n", parity->path);
|
||||
} else {
|
||||
fprintf(stderr, "Error writing file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
ferr("Error writing file '%s'. %s.\n", parity->path, strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -436,7 +436,7 @@ int parity_write(struct snapraid_parity_handle* parity, block_off_t pos, unsigne
|
|||
return 0;
|
||||
}
|
||||
|
||||
int parity_read(struct snapraid_parity_handle* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* out)
|
||||
int parity_read(struct snapraid_parity_handle* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, fptr* out)
|
||||
{
|
||||
ssize_t read_ret;
|
||||
data_off_t offset;
|
||||
|
|
@ -446,14 +446,14 @@ int parity_read(struct snapraid_parity_handle* parity, block_off_t pos, unsigned
|
|||
|
||||
/* check if we are going to read only not initialized data */
|
||||
if (offset >= parity->valid_size) {
|
||||
fprintf(out, "Reading missing data from file '%s' at offset %" PRIu64 ".\n", parity->path, offset);
|
||||
out("Reading missing data from file '%s' at offset %" PRIu64 ".\n", parity->path, offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if !HAVE_PREAD
|
||||
if (lseek(parity->f, offset, SEEK_SET) != offset) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(out, "Error seeking file '%s' at offset %" PRIu64 ". %s.\n", parity->path, offset, strerror(errno));
|
||||
out("Error seeking file '%s' at offset %" PRIu64 ". %s.\n", parity->path, offset, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -469,13 +469,13 @@ int parity_read(struct snapraid_parity_handle* parity, block_off_t pos, unsigned
|
|||
#endif
|
||||
if (read_ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(out, "Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", parity->path, offset + count, block_size - count, strerror(errno));
|
||||
out("Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", parity->path, offset + count, block_size - count, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (read_ret == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(out, "Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", parity->path, offset, strerror(errno));
|
||||
out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", parity->path, offset, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
#ifndef __PARITY_H
|
||||
#define __PARITY_H
|
||||
|
||||
#include "support.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* parity */
|
||||
|
||||
|
|
@ -84,7 +86,7 @@ int parity_close(struct snapraid_parity_handle* parity);
|
|||
/**
|
||||
* Read a block from the parity file.
|
||||
*/
|
||||
int parity_read(struct snapraid_parity_handle* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* out);
|
||||
int parity_read(struct snapraid_parity_handle* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, fptr* out);
|
||||
|
||||
/**
|
||||
* Writes a block in the parity file.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
d = opendir(dir);
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error opening pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error reading pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error removing symlink '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Directory '%s' not removed because it's in use.\n", path_next);
|
||||
ferr("Directory '%s' not removed because it's in use.\n", path_next);
|
||||
ignored = 1;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing pool directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("Error removing pool directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
|
||||
if (closedir(d) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -183,17 +183,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) {
|
||||
fprintf(stderr, "WARNING! Duplicate pooling for '%s'\n", path);
|
||||
ferr("WARNING! Duplicate pooling for '%s'\n", path);
|
||||
#ifdef _WIN32
|
||||
} else if (errno == EPERM) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You must run as Adminstrator to be able to create symlinks.\n");
|
||||
ferr("You must run as Adminstrator to be able to create symlinks.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
#endif
|
||||
} else {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("Error writing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -209,7 +209,7 @@ void state_pool(struct snapraid_state* state)
|
|||
|
||||
if (state->pool[0] == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "To use the 'pool' command you must set the pool directory in the configuration file\n");
|
||||
ferr("To use the 'pool' command you must set the pool directory in the configuration file\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -257,8 +257,8 @@ void state_pool(struct snapraid_state* state)
|
|||
else
|
||||
printf("No link created\n");
|
||||
|
||||
fprintf(stdlog, "summary:link_count::%u\n", count);
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
ftag("summary:link_count::%u\n", count);
|
||||
ftag("summary:exit:ok\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
fprintf(stderr, "You already have a rehash in progress.\n");
|
||||
ferr("You already have a rehash in progress.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (state->hash == state->besthash) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You are already using the best hash for your platform.\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Failed to get random values.\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Internal inconsistency for a rehash already in progress\n");
|
||||
ferr("Internal inconsistency for a rehash already in progress\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
150
cmdline/scan.c
150
cmdline/scan.c
|
|
@ -94,7 +94,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 */
|
||||
fprintf(stderr, "Internal inconsistency for link '%s%s'\n", disk->dir, sub);
|
||||
ferr("Internal inconsistency for link '%s%s'\n", disk->dir, sub);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
++scan->count_equal;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, link->sub);
|
||||
ftag("scan:equal:%s:%s\n", disk->name, link->sub);
|
||||
}
|
||||
} else {
|
||||
/* it's an update */
|
||||
|
|
@ -118,7 +118,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
|
||||
++scan->count_change;
|
||||
|
||||
fprintf(stdlog, "scan:update:%s:%s\n", disk->name, link->sub);
|
||||
ftag("scan:update:%s:%s\n", disk->name, link->sub);
|
||||
if (is_diff) {
|
||||
printf("update %s%s\n", disk->dir, link->sub);
|
||||
}
|
||||
|
|
@ -135,7 +135,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
/* create the new link */
|
||||
++scan->count_insert;
|
||||
|
||||
fprintf(stdlog, "scan:add:%s:%s\n", disk->name, sub);
|
||||
ftag("scan:add:%s:%s\n", disk->name, sub);
|
||||
if (is_diff) {
|
||||
printf("add %s%s\n", disk->dir, sub);
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_fil
|
|||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Internal inconsistency in deallocating for block %u state %u\n", block->parity_pos, block_state);
|
||||
ferr("Internal inconsistency in deallocating for block %u state %u\n", block->parity_pos, block_state);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -305,7 +305,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 */
|
||||
fprintf(stderr, "Error in getting the physical offset of file '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("Error in getting the physical offset of file '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -347,7 +347,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 */
|
||||
fprintf(stderr, "Error in stat file '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("Error in stat file '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -365,8 +365,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
|
||||
*/
|
||||
fprintf(stderr, "WARNING! Detected uncached time change for file '%s'\n", sub);
|
||||
fprintf(stderr, "It's better if you run SnapRAID without other processes running.\n");
|
||||
ferr("WARNING! Detected uncached time change for file '%s'\n", sub);
|
||||
ferr("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;
|
||||
|
|
@ -374,15 +374,15 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc
|
|||
|
||||
if (st->st_size != synced_st.st_size) {
|
||||
#ifndef _WIN32
|
||||
fprintf(stderr, "WARNING! Detected uncached size change for file '%s'\n", sub);
|
||||
fprintf(stderr, "It's better if you run SnapRAID without other processes running.\n");
|
||||
ferr("WARNING! Detected uncached size change for file '%s'\n", sub);
|
||||
ferr("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) {
|
||||
fprintf(stderr, "DANGER! Detected uncached inode change for file '%s'\n", sub);
|
||||
fprintf(stderr, "Please ensure to run SnapRAID without other processes running.\n");
|
||||
ferr("DANGER! Detected uncached inode change for file '%s'\n", sub);
|
||||
ferr("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 */
|
||||
|
|
@ -610,7 +610,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 */
|
||||
fprintf(stderr, "Internal inode '%" PRIu64 "' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub);
|
||||
ferr("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 */
|
||||
}
|
||||
|
|
@ -638,7 +638,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;
|
||||
|
||||
fprintf(stdlog, "scan:move:%s:%s:%s\n", disk->name, file->sub, sub);
|
||||
ftag("scan:move:%s:%s:%s\n", disk->name, file->sub, sub);
|
||||
if (is_diff) {
|
||||
printf("move %s%s -> %s%s\n", disk->dir, file->sub, disk->dir, sub);
|
||||
}
|
||||
|
|
@ -659,7 +659,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
++scan->count_equal;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, file->sub);
|
||||
ftag("scan:equal:%s:%s\n", disk->name, file->sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -678,7 +678,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 */
|
||||
fprintf(stderr, "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);
|
||||
ferr("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 */
|
||||
}
|
||||
|
|
@ -728,7 +728,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 */
|
||||
fprintf(stderr, "Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub);
|
||||
ferr("Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -737,7 +737,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 */
|
||||
fprintf(stderr, "Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub);
|
||||
ferr("Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -775,7 +775,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;
|
||||
|
||||
fprintf(stdlog, "scan:restore:%s:%s\n", disk->name, sub);
|
||||
ftag("scan:restore:%s:%s\n", disk->name, sub);
|
||||
if (is_diff) {
|
||||
printf("restore %s%s\n", disk->dir, sub);
|
||||
}
|
||||
|
|
@ -798,7 +798,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
++scan->count_equal;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, file->sub);
|
||||
ftag("scan:equal:%s:%s\n", disk->name, file->sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -830,11 +830,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 */
|
||||
fprintf(stderr, "The file '%s%s' has unexpected zero size!\n", disk->dir, sub);
|
||||
fprintf(stderr, "It's possible that after a kernel crash this file was lost,\n");
|
||||
fprintf(stderr, "and you can use 'snapraid --filter %s fix' to recover it.\n", sub);
|
||||
ferr("The file '%s%s' has unexpected zero size!\n", disk->dir, sub);
|
||||
ferr("It's possible that after a kernel crash this file was lost,\n");
|
||||
ferr("and you can use 'snapraid --filter %s fix' to recover it.\n", sub);
|
||||
if (!is_diff) {
|
||||
fprintf(stderr, "If this an expected condition you can '%s' anyway using 'snapraid --force-zero %s'\n", state->command, state->command);
|
||||
ferr("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 */
|
||||
|
|
@ -875,7 +875,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;
|
||||
|
||||
fprintf(stdlog, "scan:copy:%s:%s:%s:%s\n", other_disk->name, other_file->sub, disk->name, file->sub);
|
||||
ftag("scan:copy:%s:%s:%s:%s\n", other_disk->name, other_file->sub, disk->name, file->sub);
|
||||
if (is_diff) {
|
||||
printf("copy %s%s -> %s%s\n", other_disk->dir, other_file->sub, disk->dir, file->sub);
|
||||
}
|
||||
|
|
@ -894,14 +894,14 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
if (is_file_already_present) {
|
||||
++scan->count_change;
|
||||
|
||||
fprintf(stdlog, "scan:update:%s:%s\n", disk->name, sub);
|
||||
ftag("scan:update:%s:%s\n", disk->name, sub);
|
||||
if (is_diff) {
|
||||
printf("update %s%s\n", disk->dir, sub);
|
||||
}
|
||||
} else {
|
||||
++scan->count_insert;
|
||||
|
||||
fprintf(stdlog, "scan:add:%s:%s\n", disk->name, sub);
|
||||
ftag("scan:add:%s:%s\n", disk->name, sub);
|
||||
if (is_diff) {
|
||||
printf("add %s%s\n", disk->dir, sub);
|
||||
}
|
||||
|
|
@ -966,7 +966,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 */
|
||||
fprintf(stderr, "Internal inconsistency for dir '%s%s'\n", disk->dir, sub);
|
||||
ferr("Internal inconsistency for dir '%s%s'\n", disk->dir, sub);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1044,7 +1044,7 @@ struct stat* dstat(const char* file, struct stat* st)
|
|||
{
|
||||
if (lstat(file, st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", file, strerror(errno));
|
||||
ferr("Error in stat file/directory '%s'. %s.\n", file, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1070,8 +1070,8 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
d = opendir(dir);
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error opening directory '%s'. %s.\n", dir, strerror(errno));
|
||||
fprintf(stderr, "You can exclude it in the config file with:\n\texclude /%s\n", sub);
|
||||
ferr("Error opening directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("You can exclude it in the config file with:\n\texclude /%s\n", sub);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1090,8 +1090,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 */
|
||||
fprintf(stderr, "Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
fprintf(stderr, "You can exclude it in the config file with:\n\texclude /%s\n", sub);
|
||||
ferr("Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("You can exclude it in the config file with:\n\texclude /%s\n", sub);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1110,7 +1110,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 */
|
||||
fprintf(stderr, "Unsupported name '%s' in file '%s'.\n", name, path_next);
|
||||
ferr("Unsupported name '%s' in file '%s'.\n", name, path_next);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1155,7 +1155,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
|
||||
if (closedir(d) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1222,7 +1222,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 */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1252,7 +1252,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 */
|
||||
fprintf(stderr, "Error in stat file '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("Error in stat file '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1274,13 +1274,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 */
|
||||
fprintf(stderr, "Error in readlink file '%s'. Symlink too long.\n", path_next);
|
||||
ferr("Error in readlink file '%s'. Symlink too long.\n", path_next);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error in readlink file '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("Error in readlink file '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1306,7 +1306,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) {
|
||||
fprintf(stderr, "WARNING! Ignoring mount point '%s' because it appears to be in a different device\n", path_next);
|
||||
ferr("WARNING! Ignoring mount point '%s' because it appears to be in a different device\n", path_next);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
|
@ -1334,7 +1334,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);
|
||||
|
||||
fprintf(stderr, "WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next);
|
||||
ferr("WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next);
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding special file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
|
|
@ -1395,7 +1395,7 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
ret = fsinfo(disk->dir, &has_persistent_inode, 0, 0);
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error accessing disk '%s' to get filesystem info. %s.\n", disk->dir, strerror(errno));
|
||||
ferr("Error accessing disk '%s' to get filesystem info. %s.\n", disk->dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1455,7 +1455,7 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
if (!file_flag_has(file, FILE_IS_PRESENT)) {
|
||||
++scan->count_remove;
|
||||
|
||||
fprintf(stdlog, "scan:remove:%s:%s\n", disk->name, file->sub);
|
||||
ftag("scan:remove:%s:%s\n", disk->name, file->sub);
|
||||
if (is_diff) {
|
||||
printf("remove %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
|
|
@ -1476,7 +1476,7 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
if (!link_flag_has(link, FILE_IS_PRESENT)) {
|
||||
++scan->count_remove;
|
||||
|
||||
fprintf(stdlog, "scan:remove:%s:%s\n", disk->name, link->sub);
|
||||
ftag("scan:remove:%s:%s\n", disk->name, link->sub);
|
||||
if (is_diff) {
|
||||
printf("remove %s%s\n", disk->dir, link->sub);
|
||||
}
|
||||
|
|
@ -1537,7 +1537,7 @@ void state_scan(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 (state->opt.verbose && phy_last >= FILEPHY_REAL_OFFSET) {
|
||||
fprintf(stderr, "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);
|
||||
ferr("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;
|
||||
}
|
||||
|
|
@ -1594,20 +1594,20 @@ void state_scan(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;
|
||||
fprintf(stderr, "WARNING! All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir);
|
||||
ferr("WARNING! All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir);
|
||||
} else {
|
||||
fprintf(stderr, ", disk '%s' at dir '%s'", disk->name, disk->dir);
|
||||
ferr(", disk '%s' at dir '%s'", disk->name, disk->dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
fprintf(stderr, "\nare now missing or rewritten!\n");
|
||||
fprintf(stderr, "This could happen when deleting all the files from a disk,\n");
|
||||
fprintf(stderr, "and restoring them with a program that it's not setting\n");
|
||||
fprintf(stderr, "correctly the timestamps.\n");
|
||||
fprintf(stderr, "It's also possible that you have some disks not mounted.\n");
|
||||
ferr("\nare now missing or rewritten!\n");
|
||||
ferr("This could happen when deleting all the files from a disk,\n");
|
||||
ferr("and restoring them with a program that it's not setting\n");
|
||||
ferr("correctly the timestamps.\n");
|
||||
ferr("It's also possible that you have some disks not mounted.\n");
|
||||
if (!is_diff) {
|
||||
fprintf(stderr, "If you want to '%s' anyway, use 'snapraid --force-empty %s'.", state->command, state->command);
|
||||
ferr("If you want to '%s' anyway, use 'snapraid --force-empty %s'.", state->command, state->command);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1622,14 +1622,14 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
if (disk->has_unreliable_physical) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
fprintf(stderr, "WARNING! Physical offsets not supported for disk '%s'", disk->name);
|
||||
ferr("WARNING! Physical offsets not supported for disk '%s'", disk->name);
|
||||
} else {
|
||||
fprintf(stderr, ", '%s'", disk->name);
|
||||
ferr(", '%s'", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
fprintf(stderr, ". Files order won't be optimal.\n");
|
||||
ferr(". Files order won't be optimal.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1641,14 +1641,14 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
if (disk->has_volatile_inodes) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
fprintf(stderr, "WARNING! Inodes are not persistent for disks: '%s'", disk->name);
|
||||
ferr("WARNING! Inodes are not persistent for disks: '%s'", disk->name);
|
||||
} else {
|
||||
fprintf(stderr, ", '%s'", disk->name);
|
||||
ferr(", '%s'", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
fprintf(stderr, ". Move operations won't be optimal.\n");
|
||||
ferr(". Move operations won't be optimal.\n");
|
||||
}
|
||||
|
||||
/* checks for disks with changed UUID */
|
||||
|
|
@ -1663,14 +1663,14 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
if (disk->has_different_uuid && !disk->had_empty_uuid) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
fprintf(stderr, "WARNING! UUID is changed for disks: '%s'", disk->name);
|
||||
ferr("WARNING! UUID is changed for disks: '%s'", disk->name);
|
||||
} else {
|
||||
fprintf(stderr, ", '%s'", disk->name);
|
||||
ferr(", '%s'", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
fprintf(stderr, ". Move operations won't be optimal.\n");
|
||||
ferr(". Move operations won't be optimal.\n");
|
||||
}
|
||||
|
||||
/* checks for disks with unsupported UUID */
|
||||
|
|
@ -1681,14 +1681,14 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
if (disk->has_unsupported_uuid) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
fprintf(stderr, "WARNING! UUID is unsupported for disks: '%s'", disk->name);
|
||||
ferr("WARNING! UUID is unsupported for disks: '%s'", disk->name);
|
||||
} else {
|
||||
fprintf(stderr, ", '%s'", disk->name);
|
||||
ferr(", '%s'", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
fprintf(stderr, ". Move operations won't be optimal.\n");
|
||||
ferr(". Move operations won't be optimal.\n");
|
||||
}
|
||||
|
||||
if (state->opt.verbose || is_diff) {
|
||||
|
|
@ -1726,13 +1726,13 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
printf("%8u added\n", total.count_insert);
|
||||
}
|
||||
|
||||
fprintf(stdlog, "summary:equal:%u\n", total.count_equal);
|
||||
fprintf(stdlog, "summary:moved:%u\n", total.count_move);
|
||||
fprintf(stdlog, "summary:copied:%u\n", total.count_copy);
|
||||
fprintf(stdlog, "summary:restored:%u\n", total.count_restore);
|
||||
fprintf(stdlog, "summary:updated:%u\n", total.count_change);
|
||||
fprintf(stdlog, "summary:removed:%u\n", total.count_remove);
|
||||
fprintf(stdlog, "summary:added:%u\n", total.count_insert);
|
||||
ftag("summary:equal:%u\n", total.count_equal);
|
||||
ftag("summary:moved:%u\n", total.count_move);
|
||||
ftag("summary:copied:%u\n", total.count_copy);
|
||||
ftag("summary:restored:%u\n", total.count_restore);
|
||||
ftag("summary:updated:%u\n", total.count_change);
|
||||
ftag("summary:removed:%u\n", total.count_remove);
|
||||
ftag("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;
|
||||
|
|
@ -1746,9 +1746,9 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
}
|
||||
|
||||
if (no_difference) {
|
||||
fprintf(stdlog, "summary:exit:equal\n");
|
||||
ftag("summary:exit:equal\n");
|
||||
} else {
|
||||
fprintf(stdlog, "summary:exit:diff\n");
|
||||
ftag("summary:exit:diff\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,17 +228,17 @@ 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) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "DANGER! Unexpected input/output close error in a data disk, it isn't possible to scrub.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
ftag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("DANGER! Unexpected input/output close error in a data disk, it isn't possible to scrub.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Close error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected close error in a data disk, it isn't possible to scrub.\n");
|
||||
fprintf(stderr, "Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Close error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("WARNING! Unexpected close error in a data disk, it isn't possible to scrub.\n");
|
||||
ferr("Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -246,22 +246,22 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
}
|
||||
}
|
||||
|
||||
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, stderr);
|
||||
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, flog);
|
||||
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 */
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "DANGER! Unexpected input/output open error in a data disk, it isn't possible to scrub.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
ftag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("DANGER! Unexpected input/output open error in a data disk, it isn't possible to scrub.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ftag("error:%u:%s:%s: Open error. %s\n", i, disk->name, 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, stderr);
|
||||
read_size = handle_read(&handle[j], block, buffer[j], state->block_size, flog);
|
||||
if (read_size == -1) {
|
||||
/* file we are processing for error reporting */
|
||||
struct snapraid_file* file = block_file_get(block);
|
||||
if (errno == EIO) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
ftag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected input/output read error in a data disk, it isn't possible to scrub.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
ferr("DANGER! Unexpected input/output read error in a data disk, it isn't possible to scrub.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stderr, "Input/Output error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
|
||||
ferr("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;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
ftag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, 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) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Data error at position %u\n", i, disk->name, handle[j].file->sub, block_file_pos(block));
|
||||
ftag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, 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 {
|
||||
fprintf(stderr, "Data error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
|
||||
ferr("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, stdlog);
|
||||
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, flog);
|
||||
if (ret == -1) {
|
||||
buffer_recov[l] = 0;
|
||||
|
||||
if (errno == EIO) {
|
||||
fprintf(stdlog, "parity_error:%u:%s: Read EIO error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
ftag("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 */
|
||||
fprintf(stderr, "DANGER! Unexpected input/output read error in the %s disk, it isn't possible to scrub.\n", lev_name(l));
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and can be read.\n", lev_config_name(l));
|
||||
ferr("DANGER! Unexpected input/output read error in the %s disk, it isn't possible to scrub.\n", lev_name(l));
|
||||
ferr("Ensure that disk '%s' is sane and can be read.\n", lev_config_name(l));
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
fprintf(stderr, "Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
|
||||
ferr("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
|
||||
++io_error;
|
||||
io_error_on_this_block = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "parity_error:%u:%s: Read error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
ftag("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) {
|
||||
fprintf(stdlog, "parity_error:%u:%s: Data error\n", i, lev_config_name(l));
|
||||
ftag("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 {
|
||||
fprintf(stderr, "Data error in parity '%s' at position '%u'\n", lev_config_name(l), i);
|
||||
ferr("Data error in parity '%s' at position '%u'\n", lev_config_name(l), i);
|
||||
++silent_error;
|
||||
silent_error_on_this_block = 1;
|
||||
}
|
||||
|
|
@ -475,12 +475,12 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
state_usage_print(state);
|
||||
|
||||
if (io_error)
|
||||
fprintf(stderr, "WARNING! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
|
||||
ferr("WARNING! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
|
||||
if (silent_error)
|
||||
fprintf(stderr, "WARNING! Unexpected data errors! The failing blocks are now marked as bad!\n");
|
||||
ferr("WARNING! Unexpected data errors! The failing blocks are now marked as bad!\n");
|
||||
if (io_error || silent_error) {
|
||||
fprintf(stderr, "Use 'snapraid status' to list the bad blocks.\n");
|
||||
fprintf(stderr, "Use 'snapraid -e fix' to recover.\n");
|
||||
ferr("Use 'snapraid status' to list the bad blocks.\n");
|
||||
ferr("Use 'snapraid -e fix' to recover.\n");
|
||||
}
|
||||
|
||||
if (error || silent_error || io_error) {
|
||||
|
|
@ -495,13 +495,13 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
fprintf(stdlog, "summary:error_file:%u\n", error);
|
||||
fprintf(stdlog, "summary:error_io:%u\n", io_error);
|
||||
fprintf(stdlog, "summary:error_data:%u\n", silent_error);
|
||||
ftag("summary:error_file:%u\n", error);
|
||||
ftag("summary:error_io:%u\n", io_error);
|
||||
ftag("summary:error_data:%u\n", silent_error);
|
||||
if (error + silent_error + io_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
ftag("summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
ftag("summary:exit:error\n");
|
||||
fflush(stdlog);
|
||||
|
||||
bail:
|
||||
|
|
@ -509,7 +509,7 @@ bail:
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected close error in a data disk.\n");
|
||||
ferr("DANGER! Unexpected close error in a data disk.\n");
|
||||
++error;
|
||||
/* continue, as we are already exiting */
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -598,7 +598,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
|
||||
/* copy the info in the temp vector */
|
||||
count = 0;
|
||||
fprintf(stdlog, "block_count:%u\n", blockmax);
|
||||
ftag("block_count:%u\n", blockmax);
|
||||
for (i = 0; i < blockmax; ++i) {
|
||||
snapraid_info info = info_get(&state->infoarr, i);
|
||||
|
||||
|
|
@ -611,7 +611,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
|
||||
if (!count) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "The array appears to be empty.\n");
|
||||
ferr("The array appears to be empty.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -621,12 +621,12 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
|
||||
/* output the info map */
|
||||
i = 0;
|
||||
fprintf(stdlog, "info_count:%u\n", count);
|
||||
ftag("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;
|
||||
fprintf(stdlog, "info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
|
||||
ftag("info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
|
||||
i = j;
|
||||
}
|
||||
|
||||
|
|
@ -654,9 +654,9 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
lastlimit = 0;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "count_limit:%u\n", countlimit);
|
||||
fprintf(stdlog, "time_limit:%" PRIu64 "\n", (uint64_t)timelimit);
|
||||
fprintf(stdlog, "last_limit:%u\n", lastlimit);
|
||||
ftag("count_limit:%u\n", countlimit);
|
||||
ftag("time_limit:%" PRIu64 "\n", (uint64_t)timelimit);
|
||||
ftag("last_limit:%u\n", lastlimit);
|
||||
|
||||
/* free the temp vector */
|
||||
free(infomap);
|
||||
|
|
@ -667,7 +667,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 */
|
||||
fprintf(stderr, "WARNING! Without an accessible %s file, it isn't possible to scrub.\n", lev_name(l));
|
||||
ferr("WARNING! Without an accessible %s file, it isn't possible to scrub.\n", lev_name(l));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -687,7 +687,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
ret = parity_close(parity_ptr[l]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected close error in %s disk.\n", lev_name(l));
|
||||
ferr("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
|
||||
++error;
|
||||
/* continue, as we are already exiting */
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
fprintf(stderr, "Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error seeking file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error opening directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -220,7 +220,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 */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -229,7 +229,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 */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
ferr("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
|
||||
if (closedir(d) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "raid/test.h"
|
||||
#include "elem.h"
|
||||
#include "state.h"
|
||||
#include "support.h"
|
||||
#include "tommyds/tommyhash.h"
|
||||
#include "tommyds/tommyarray.h"
|
||||
#include "tommyds/tommyarrayblk.h"
|
||||
|
|
@ -159,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 */
|
||||
fprintf(stderr, "Failed hash32 test\n");
|
||||
ferr("Failed hash32 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -171,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 */
|
||||
fprintf(stderr, "Failed hash64 test\n");
|
||||
ferr("Failed hash64 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -184,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 */
|
||||
fprintf(stderr, "Failed Murmur3 test\n");
|
||||
ferr("Failed Murmur3 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -196,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 */
|
||||
fprintf(stderr, "Failed Spooky2 test\n");
|
||||
ferr("Failed Spooky2 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -245,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 */
|
||||
fprintf(stderr, "Failed CRC32C test\n");
|
||||
ferr("Failed CRC32C test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -372,14 +373,14 @@ static void test_tommy(void)
|
|||
return;
|
||||
bail:
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed tommy test\n");
|
||||
ferr("Failed tommy test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
void selftest(void)
|
||||
{
|
||||
fprintf(stdlog, "selftest:\n");
|
||||
ftag("selftest:\n");
|
||||
fflush(stdlog);
|
||||
|
||||
printf("Self test...\n");
|
||||
|
|
@ -387,7 +388,7 @@ void selftest(void)
|
|||
/* large file check */
|
||||
if (sizeof(off_t) < sizeof(uint64_t)) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Missing support for large files\n");
|
||||
ferr("Missing support for large files\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -397,55 +398,55 @@ void selftest(void)
|
|||
test_tommy();
|
||||
if (raid_selftest() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed SELF test\n");
|
||||
ferr("Failed SELF test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_sort() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed SORT test\n");
|
||||
ferr("Failed SORT test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_insert() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed INSERT test\n");
|
||||
ferr("Failed INSERT test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_combo() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed COMBO test\n");
|
||||
ferr("Failed COMBO test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_par(RAID_MODE_VANDERMONDE, 32, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed GEN Vandermonde test\n");
|
||||
ferr("Failed GEN Vandermonde test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_rec(RAID_MODE_VANDERMONDE, 12, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed REC Vandermonde test\n");
|
||||
ferr("Failed REC Vandermonde test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_par(RAID_MODE_CAUCHY, 32, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed GEN Cauchy test\n");
|
||||
ferr("Failed GEN Cauchy test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_rec(RAID_MODE_CAUCHY, 12, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed REC Cauchy test\n");
|
||||
ferr("Failed REC Cauchy test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_par(RAID_MODE_CAUCHY, 1, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed GEN Cauchy test sigle data disk\n");
|
||||
ferr("Failed GEN Cauchy test sigle data disk\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ void usage(void)
|
|||
|
||||
void memory(void)
|
||||
{
|
||||
fprintf(stdlog, "memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter());
|
||||
ftag("memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter());
|
||||
printf("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024));
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ void log_open(const char* log)
|
|||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid type specifier '%c' in the log file.\n", *log);
|
||||
ferr("Invalid type specifier '%c' in the log file.\n", *log);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ void log_open(const char* log)
|
|||
stdlog = fopen(path, mode);
|
||||
if (!stdlog) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error opening the log file '%s'. %s.\n", path, strerror(errno));
|
||||
ferr("Error opening the log file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ void log_close(const char* log)
|
|||
if (stdlog != stdout && stdlog != stderr) {
|
||||
if (fclose(stdlog) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing the log file '%s'. %s.\n", log, strerror(errno));
|
||||
ferr("Error closing the log file '%s'. %s.\n", log, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -454,7 +454,7 @@ int main(int argc, char* argv[])
|
|||
struct snapraid_filter* filter = filter_alloc_file(1, optarg);
|
||||
if (!filter) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid filter specification '%s'\n", optarg);
|
||||
ferr("Invalid filter specification '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -464,7 +464,7 @@ int main(int argc, char* argv[])
|
|||
struct snapraid_filter* filter = filter_alloc_disk(1, optarg);
|
||||
if (!filter) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid filter specification '%s'\n", optarg);
|
||||
ferr("Invalid filter specification '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -484,7 +484,7 @@ int main(int argc, char* argv[])
|
|||
percentage = strtoul(optarg, &e, 10);
|
||||
if (!e || *e || percentage > 100) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid percentage '%s'\n", optarg);
|
||||
ferr("Invalid percentage '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -493,7 +493,7 @@ int main(int argc, char* argv[])
|
|||
olderthan = strtoul(optarg, &e, 10);
|
||||
if (!e || *e || olderthan > 1000) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid number of days '%s'\n", optarg);
|
||||
ferr("Invalid number of days '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -502,7 +502,7 @@ int main(int argc, char* argv[])
|
|||
blockstart = strtoul(optarg, &e, 0);
|
||||
if (!e || *e) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid start position '%s'\n", optarg);
|
||||
ferr("Invalid start position '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -511,7 +511,7 @@ int main(int argc, char* argv[])
|
|||
blockcount = strtoul(optarg, &e, 0);
|
||||
if (!e || *e) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid count number '%s'\n", optarg);
|
||||
ferr("Invalid count number '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -520,7 +520,7 @@ int main(int argc, char* argv[])
|
|||
opt.io_error_limit = strtoul(optarg, &e, 0);
|
||||
if (!e || *e) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid error limit number '%s'\n", optarg);
|
||||
ferr("Invalid error limit number '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -528,7 +528,7 @@ int main(int argc, char* argv[])
|
|||
case 'i' :
|
||||
if (import_timestamp) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Import directory '%s' already specified as '%s'\n", optarg, import_timestamp);
|
||||
ferr("Import directory '%s' already specified as '%s'\n", optarg, import_timestamp);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -537,7 +537,7 @@ int main(int argc, char* argv[])
|
|||
case OPT_TEST_IMPORT_CONTENT :
|
||||
if (import_content) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Import directory '%s' already specified as '%s'\n", optarg, import_content);
|
||||
ferr("Import directory '%s' already specified as '%s'\n", optarg, import_content);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -546,7 +546,7 @@ int main(int argc, char* argv[])
|
|||
case 'l' :
|
||||
if (log) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Log file '%s' already specified as '%s'\n", optarg, log);
|
||||
ferr("Log file '%s' already specified as '%s'\n", optarg, log);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -683,7 +683,7 @@ int main(int argc, char* argv[])
|
|||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Unknown option '%c'\n", (char)c);
|
||||
ferr("Unknown option '%c'\n", (char)c);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -749,7 +749,7 @@ int main(int argc, char* argv[])
|
|||
operation = OPERATION_SMART;
|
||||
} else {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Unknown command '%s'\n", argv[optind]);
|
||||
ferr("Unknown command '%s'\n", argv[optind]);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -761,7 +761,7 @@ int main(int argc, char* argv[])
|
|||
default :
|
||||
if (opt.auditonly) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You cannot use -a, --audit-only with the '%s' command\n", command);
|
||||
ferr("You cannot use -a, --audit-only with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -775,7 +775,7 @@ int main(int argc, char* argv[])
|
|||
default :
|
||||
if (opt.force_nocopy) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You cannot use -N, --force-nocopy with the '%s' command\n", command);
|
||||
ferr("You cannot use -N, --force-nocopy with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -787,14 +787,14 @@ int main(int argc, char* argv[])
|
|||
default :
|
||||
if (opt.prehash) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You cannot use -h, --pre-hash with the '%s' command\n", command);
|
||||
ferr("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 */
|
||||
fprintf(stderr, "You cannot use -F, --force-full with the '%s' command\n", command);
|
||||
ferr("You cannot use -F, --force-full with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -802,14 +802,14 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (opt.force_full && opt.force_nocopy) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You cannot use the -F, --force-full and -N, --force-nocopy options at the same time\n");
|
||||
ferr("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 */
|
||||
fprintf(stderr, "You cannot use the -h, --pre-hash and -N, --force-nocopy options at the same time\n");
|
||||
ferr("You cannot use the -h, --pre-hash and -N, --force-nocopy options at the same time\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -822,25 +822,25 @@ int main(int argc, char* argv[])
|
|||
default :
|
||||
if (!tommy_list_empty(&filterlist_file)) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You cannot use -f, --filter with the '%s' command\n", command);
|
||||
ferr("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 */
|
||||
fprintf(stderr, "You cannot use -d, --filter-disk with the '%s' command\n", command);
|
||||
ferr("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 */
|
||||
fprintf(stderr, "You cannot use -m, --filter-missing with the '%s' command\n", command);
|
||||
ferr("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 */
|
||||
fprintf(stderr, "You cannot use -e, --filter-error with the '%s' command\n", command);
|
||||
ferr("You cannot use -e, --filter-error with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -853,7 +853,7 @@ int main(int argc, char* argv[])
|
|||
default :
|
||||
if (import_timestamp != 0 || import_content != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You cannot import with the '%s' command\n", command);
|
||||
ferr("You cannot import with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -914,16 +914,16 @@ int main(int argc, char* argv[])
|
|||
/* print generic info into the log */
|
||||
t = time(0);
|
||||
tm = localtime(&t);
|
||||
fprintf(stdlog, "version:%s\n", PACKAGE_VERSION);
|
||||
fprintf(stdlog, "unixtime:%" PRIi64 "\n", (int64_t)t);
|
||||
ftag("version:%s\n", PACKAGE_VERSION);
|
||||
ftag("unixtime:%" PRIi64 "\n", (int64_t)t);
|
||||
if (tm) {
|
||||
char datetime[64];
|
||||
strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm);
|
||||
fprintf(stdlog, "time:%s\n", datetime);
|
||||
ftag("time:%s\n", datetime);
|
||||
}
|
||||
fprintf(stdlog, "command:%s\n", command);
|
||||
ftag("command:%s\n", command);
|
||||
for (i = 0; i < argc; ++i)
|
||||
fprintf(stdlog, "argv:%u:%s\n", i, argv[i]);
|
||||
ftag("argv:%u:%s\n", i, argv[i]);
|
||||
fflush(stdlog);
|
||||
|
||||
if (!opt.skip_self)
|
||||
|
|
@ -944,10 +944,10 @@ int main(int argc, char* argv[])
|
|||
if (lock == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno != EWOULDBLOCK) {
|
||||
fprintf(stderr, "Error creating the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
|
||||
ferr("Error creating the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
|
||||
} else {
|
||||
fprintf(stderr, "The lock file '%s' is already locked!\n", state.lockfile);
|
||||
fprintf(stderr, "SnapRAID is already in use!\n");
|
||||
ferr("The lock file '%s' is already locked!\n", state.lockfile);
|
||||
ferr("SnapRAID is already in use!\n");
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1005,7 +1005,7 @@ int main(int argc, char* argv[])
|
|||
ret = system(run); /* ignore error */
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error in running command '%s'.\n", run);
|
||||
ferr("Error in running command '%s'.\n", run);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1161,7 +1161,7 @@ int main(int argc, char* argv[])
|
|||
if (!opt.skip_lock) {
|
||||
if (lock_unlock(lock) == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
|
||||
ferr("Error closing the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
636
cmdline/state.c
636
cmdline/state.c
File diff suppressed because it is too large
Load diff
|
|
@ -82,20 +82,20 @@ int state_status(struct snapraid_state* state)
|
|||
|
||||
blockmax = parity_allocated_size(state);
|
||||
|
||||
fprintf(stdlog, "summary:block_size:%u\n", state->block_size);
|
||||
fprintf(stdlog, "summary:parity_block_count:%u\n", blockmax);
|
||||
ftag("summary:block_size:%u\n", state->block_size);
|
||||
ftag("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) {
|
||||
fprintf(stdlog, "summary:parity_block_total:%s:%u\n", lev_config_name(l), state->parity[l].total_blocks);
|
||||
fprintf(stdlog, "summary:parity_block_free:%s:%u\n", lev_config_name(l), state->parity[l].free_blocks);
|
||||
ftag("summary:parity_block_total:%s:%u\n", lev_config_name(l), state->parity[l].total_blocks);
|
||||
ftag("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;
|
||||
}
|
||||
fprintf(stdlog, "summary:parity_block_free_min:%u\n", parity_block_free);
|
||||
ftag("summary:parity_block_free_min:%u\n", parity_block_free);
|
||||
|
||||
printf("SnapRAID status report:\n");
|
||||
printf("\n");
|
||||
|
|
@ -204,17 +204,17 @@ int state_status(struct snapraid_state* state)
|
|||
printf(" %3u%%", perc(disk_block_count, disk_block_max));
|
||||
printf(" %s\n", disk->name);
|
||||
|
||||
fprintf(stdlog, "summary:disk_file_count:%s:%u\n", disk->name, disk_file_count);
|
||||
fprintf(stdlog, "summary:disk_block_count:%s:%u\n", disk->name, disk_block_count);
|
||||
fprintf(stdlog, "summary:disk_fragmented_file_count:%s:%u\n", disk->name, disk_file_fragmented);
|
||||
fprintf(stdlog, "summary:disk_excess_fragment_count:%s:%u\n", disk->name, disk_extra_fragment);
|
||||
fprintf(stdlog, "summary:disk_file_size:%s:%" PRIu64 "\n", disk->name, disk_file_size);
|
||||
fprintf(stdlog, "summary:disk_block_allocated:%s:%u\n", disk->name, disk_block_latest_used + 1);
|
||||
fprintf(stdlog, "summary:disk_block_total:%s:%u\n", disk->name, disk->total_blocks);
|
||||
fprintf(stdlog, "summary:disk_block_free:%s:%u\n", disk->name, disk->free_blocks);
|
||||
fprintf(stdlog, "summary:disk_block_max_by_space:%s:%u\n", disk->name, disk_block_max_by_space);
|
||||
fprintf(stdlog, "summary:disk_block_max_by_parity:%s:%u\n", disk->name, disk_block_max_by_parity);
|
||||
fprintf(stdlog, "summary:disk_block_max:%s:%u\n", disk->name, disk_block_max);
|
||||
ftag("summary:disk_file_count:%s:%u\n", disk->name, disk_file_count);
|
||||
ftag("summary:disk_block_count:%s:%u\n", disk->name, disk_block_count);
|
||||
ftag("summary:disk_fragmented_file_count:%s:%u\n", disk->name, disk_file_fragmented);
|
||||
ftag("summary:disk_excess_fragment_count:%s:%u\n", disk->name, disk_extra_fragment);
|
||||
ftag("summary:disk_file_size:%s:%" PRIu64 "\n", disk->name, disk_file_size);
|
||||
ftag("summary:disk_block_allocated:%s:%u\n", disk->name, disk_block_latest_used + 1);
|
||||
ftag("summary:disk_block_total:%s:%u\n", disk->name, disk->total_blocks);
|
||||
ftag("summary:disk_block_free:%s:%u\n", disk->name, disk->free_blocks);
|
||||
ftag("summary:disk_block_max_by_space:%s:%u\n", disk->name, disk_block_max_by_space);
|
||||
ftag("summary:disk_block_max_by_parity:%s:%u\n", disk->name, disk_block_max_by_parity);
|
||||
ftag("summary:disk_block_max:%s:%u\n", disk->name, disk_block_max);
|
||||
}
|
||||
|
||||
/* totals */
|
||||
|
|
@ -232,16 +232,16 @@ int state_status(struct snapraid_state* state)
|
|||
if (!free_not_zero)
|
||||
printf("\nWARNING! Free space info will be valid after the first sync.\n");
|
||||
|
||||
fprintf(stdlog, "summary:file_count:%u\n", file_count);
|
||||
fprintf(stdlog, "summary:file_block_count:%" PRIu64 "\n", file_block_count);
|
||||
fprintf(stdlog, "summary:fragmented_file_count:%u\n", file_fragmented);
|
||||
fprintf(stdlog, "summary:excess_fragment_count:%u\n", extra_fragment);
|
||||
fprintf(stdlog, "summary:file_size:%" PRIu64 "\n", file_size);
|
||||
fprintf(stdlog, "summary:parity_size:%" PRIu64 "\n", blockmax * (uint64_t)state->block_size);
|
||||
fprintf(stdlog, "summary:parity_size_max:%" PRIu64 "\n", (blockmax + parity_block_free) * (uint64_t)state->block_size);
|
||||
fprintf(stdlog, "summary:hash:%s\n", hash_config_name(state->hash));
|
||||
fprintf(stdlog, "summary:prev_hash:%s\n", hash_config_name(state->prevhash));
|
||||
fprintf(stdlog, "summary:best_hash:%s\n", hash_config_name(state->besthash));
|
||||
ftag("summary:file_count:%u\n", file_count);
|
||||
ftag("summary:file_block_count:%" PRIu64 "\n", file_block_count);
|
||||
ftag("summary:fragmented_file_count:%u\n", file_fragmented);
|
||||
ftag("summary:excess_fragment_count:%u\n", extra_fragment);
|
||||
ftag("summary:file_size:%" PRIu64 "\n", file_size);
|
||||
ftag("summary:parity_size:%" PRIu64 "\n", blockmax * (uint64_t)state->block_size);
|
||||
ftag("summary:parity_size_max:%" PRIu64 "\n", (blockmax + parity_block_free) * (uint64_t)state->block_size);
|
||||
ftag("summary:hash:%s\n", hash_config_name(state->hash));
|
||||
ftag("summary:prev_hash:%s\n", hash_config_name(state->prevhash));
|
||||
ftag("summary:best_hash:%s\n", hash_config_name(state->besthash));
|
||||
fflush(stdlog);
|
||||
|
||||
/* copy the info a temp vector, and count bad/rehash/unsynced blocks */
|
||||
|
|
@ -252,7 +252,7 @@ int state_status(struct snapraid_state* state)
|
|||
count = 0;
|
||||
rehash = 0;
|
||||
unsynced_blocks = 0;
|
||||
fprintf(stdlog, "block_count:%u\n", blockmax);
|
||||
ftag("block_count:%u\n", blockmax);
|
||||
for (i = 0; i < blockmax; ++i) {
|
||||
int one_invalid;
|
||||
int one_valid;
|
||||
|
|
@ -294,19 +294,19 @@ int state_status(struct snapraid_state* state)
|
|||
|
||||
if (state->opt.gui) {
|
||||
if (info != 0)
|
||||
fprintf(stdlog, "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" : "");
|
||||
ftag("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
|
||||
fprintf(stdlog, "block_noinfo:%u:%s:%s\n", i, one_valid ? "used" : "", one_invalid ? "unsynced" : "");
|
||||
ftag("block_noinfo:%u:%s:%s\n", i, one_valid ? "used" : "", one_invalid ? "unsynced" : "");
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stdlog, "summary:has_unsynced:%u\n", unsynced_blocks);
|
||||
fprintf(stdlog, "summary:has_rehash:%u\n", rehash);
|
||||
fprintf(stdlog, "summary:has_bad:%u:%u:%u\n", bad, bad_first, bad_last);
|
||||
ftag("summary:has_unsynced:%u\n", unsynced_blocks);
|
||||
ftag("summary:has_rehash:%u\n", rehash);
|
||||
ftag("summary:has_bad:%u:%u:%u\n", bad, bad_first, bad_last);
|
||||
fflush(stdlog);
|
||||
|
||||
if (!count) {
|
||||
fprintf(stderr, "The array is empty.\n");
|
||||
ferr("The array is empty.\n");
|
||||
free(infomap);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -316,12 +316,12 @@ int state_status(struct snapraid_state* state)
|
|||
|
||||
/* output the info map */
|
||||
i = 0;
|
||||
fprintf(stdlog, "info_count:%u\n", count);
|
||||
ftag("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;
|
||||
fprintf(stdlog, "info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
|
||||
ftag("info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
|
||||
i = j;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,55 @@
|
|||
|
||||
#include "support.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* print */
|
||||
|
||||
void fout(const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stdout, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void ferr(const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
if (stdlog) {
|
||||
fprintf(stdlog, "msg: ");
|
||||
vfprintf(stdlog, format, ap);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void flog(const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
if (stdlog) {
|
||||
fprintf(stdlog, "msg: ");
|
||||
vfprintf(stdlog, format, ap);
|
||||
} else {
|
||||
vfprintf(stderr, format, ap);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void ftag(const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
if (stdlog)
|
||||
vfprintf(stdlog, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* path */
|
||||
|
||||
|
|
@ -28,7 +77,7 @@ void pathcpy(char* dst, size_t size, const char* src)
|
|||
|
||||
if (len + 1 > size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Path too long\n");
|
||||
ferr("Path too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -43,7 +92,7 @@ void pathcat(char* dst, size_t size, const char* src)
|
|||
|
||||
if (dst_len + src_len + 1 > size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Path too long\n");
|
||||
ferr("Path too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -57,7 +106,7 @@ void pathcatc(char* dst, size_t size, char c)
|
|||
|
||||
if (dst_len + 2 > size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Path too long\n");
|
||||
ferr("Path too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -105,7 +154,7 @@ void pathprint(char* dst, size_t size, const char* format, ...)
|
|||
|
||||
if (len >= size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Path too long\n");
|
||||
ferr("Path too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -118,7 +167,7 @@ void pathslash(char* dst, size_t size)
|
|||
if (len > 0 && dst[len - 1] != '/') {
|
||||
if (len + 2 >= size) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Path too long\n");
|
||||
ferr("Path too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -213,7 +262,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 */
|
||||
fprintf(stderr, "Error creating directory '%s'. %s.\n", dir, strerror(errno));
|
||||
ferr("Error creating directory '%s'. %s.\n", dir, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -469,14 +518,14 @@ int smartctl_attribute(FILE* f, uint64_t* smart, char* serial)
|
|||
} else if (inside) {
|
||||
if (sscanf(s, "%u %*s %*s %*u %*u %*u %*s %*s %*s %" SCNu64, &id, &raw) != 2) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid smartctl line '%s'.\n", buf);
|
||||
ferr("Invalid smartctl line '%s'.\n", buf);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (id >= 256) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Invalid SMART id '%u'.\n", id);
|
||||
ferr("Invalid SMART id '%u'.\n", id);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,50 @@
|
|||
#ifndef __SUPPORT_H
|
||||
#define __SUPPORT_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* log */
|
||||
|
||||
/**
|
||||
* Output message targgeted for the screen.
|
||||
*
|
||||
* Messages are in human readable format.
|
||||
*
|
||||
* These messages go in stdout.
|
||||
*/
|
||||
void fout(const char* format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
/**
|
||||
* Error message printed before an early termination.
|
||||
*
|
||||
* Messages are in human readable format.
|
||||
*
|
||||
* These messages go in the log file and in stderr.
|
||||
*/
|
||||
void ferr(const char* format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
/**
|
||||
* Log message printed after an error.
|
||||
*
|
||||
* Messages are in human readable format.
|
||||
*
|
||||
* These messages go in the log file if specified, otherwise in stderr.
|
||||
*/
|
||||
void flog(const char* format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
/**
|
||||
* Tag message.
|
||||
*
|
||||
* Messages are in tag format, like "tag:entry:...".
|
||||
*
|
||||
* These messages go in the log file.
|
||||
*/
|
||||
void ftag(const char* format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
/**
|
||||
* Pointer to log function.
|
||||
*/
|
||||
typedef void fptr(const char* format, ...);
|
||||
|
||||
/****************************************************************************/
|
||||
/* path */
|
||||
|
||||
|
|
@ -57,7 +101,7 @@ void pathexport(char* dst, size_t size, const char* src);
|
|||
* Prints a path.
|
||||
* Aborts if too long.
|
||||
*/
|
||||
void pathprint(char* dst, size_t size, const char* format, ...);
|
||||
void pathprint(char* dst, size_t size, const char* format, ...) __attribute__((format(printf, 3, 4)));
|
||||
|
||||
/**
|
||||
* Ensures the presence of a terminating slash, if it isn't empty.
|
||||
|
|
|
|||
260
cmdline/sync.c
260
cmdline/sync.c
|
|
@ -132,17 +132,17 @@ 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) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
ftag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Close error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Close error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -150,15 +150,15 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
}
|
||||
}
|
||||
|
||||
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, stderr);
|
||||
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, flog);
|
||||
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 */
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "DANGER! Unexpected input/output open error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
ftag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("DANGER! Unexpected input/output open error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
|
|
@ -166,10 +166,10 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
}
|
||||
|
||||
if (errno == ENOENT) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open ENOENT error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "Missing file '%s'.\n", handle[j].path);
|
||||
fprintf(stderr, "WARNING! You cannot modify data disk during a sync.\n");
|
||||
fprintf(stderr, "Rerun the sync command when finished.\n");
|
||||
ftag("error:%u:%s:%s: Open ENOENT error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
flog("Missing file '%s'.\n", handle[j].path);
|
||||
flog("WARNING! You cannot modify data disk during a sync.\n");
|
||||
flog("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,19 +177,19 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
}
|
||||
|
||||
if (errno == EACCES) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open EACCES error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "No access at file '%s'.\n", handle[j].path);
|
||||
fprintf(stderr, "WARNING! Please fix the access permission in the data disk.\n");
|
||||
fprintf(stderr, "Rerun the sync command when finished.\n");
|
||||
ftag("error:%u:%s:%s: Open EACCES error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
flog("No access at file '%s'.\n", handle[j].path);
|
||||
flog("WARNING! Please fix the access permission in the data disk.\n");
|
||||
flog("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 */
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Open error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
printf("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -204,40 +204,40 @@ 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);
|
||||
fprintf(stdlog, "error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, file->sub);
|
||||
ftag("error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, file->sub);
|
||||
if (handle[j].st.st_size != file->size) {
|
||||
fprintf(stderr, "Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, handle[j].st.st_size);
|
||||
flog("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) {
|
||||
fprintf(stderr, "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));
|
||||
flog("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 {
|
||||
fprintf(stderr, "Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
|
||||
flog("Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
|
||||
}
|
||||
fprintf(stderr, "WARNING! You cannot modify files during a sync.\n");
|
||||
fprintf(stderr, "Rerun the sync command when finished.\n");
|
||||
flog("WARNING! You cannot modify files during a sync.\n");
|
||||
flog("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, stderr);
|
||||
read_size = handle_read(&handle[j], block, buffer, state->block_size, ferr);
|
||||
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) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
fprintf(stderr, "DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle[j].path);
|
||||
ftag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
ferr("DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that file '%s' can be read.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
ferr("WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that file '%s' can be read.\n", handle[j].path);
|
||||
printf("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -287,17 +287,17 @@ 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) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Close EIO error. %s\n", blockmax, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
ftag("error:%u:%s:%s: Close EIO error. %s\n", blockmax, disk->name, file->sub, strerror(errno));
|
||||
ferr("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", blockmax);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Close error. %s\n", blockmax, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Close error. %s\n", blockmax, disk->name, file->sub, strerror(errno));
|
||||
ferr("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
printf("Stopping at block %u\n", blockmax);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -320,7 +320,7 @@ end:
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
fprintf(stdlog, "hash_summary:error_readwrite:%u\n", error);
|
||||
ftag("hash_summary:error_readwrite:%u\n", error);
|
||||
|
||||
/* proceed without bailing out */
|
||||
goto finish;
|
||||
|
|
@ -333,7 +333,7 @@ bail:
|
|||
for (j = 0; j < diskmax; ++j) {
|
||||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
fprintf(stderr, "DANGER! Unexpected close error in a data disk.\n");
|
||||
ferr("DANGER! Unexpected close error in a data disk.\n");
|
||||
++error;
|
||||
/* continue, as we are already exiting */
|
||||
}
|
||||
|
|
@ -598,17 +598,17 @@ 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) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
ftag("error:%u:%s:%s: Close EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("DANGER! Unexpected input/output close error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Close error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Close error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("WARNING! Unexpected close error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -616,15 +616,15 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
}
|
||||
|
||||
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, stderr);
|
||||
ret = handle_open(&handle[j], block_file_get(block), state->file_mode, flog);
|
||||
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 */
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "DANGER! Unexpected input/output open error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
ftag("error:%u:%s:%s: Open EIO error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("DANGER! Unexpected input/output open error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
|
|
@ -632,10 +632,10 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
|
||||
if (errno == ENOENT) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open ENOENT error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "Missing file '%s'.\n", handle[j].path);
|
||||
fprintf(stderr, "WARNING! You cannot modify data disk during a sync.\n");
|
||||
fprintf(stderr, "Rerun the sync command when finished.\n");
|
||||
ftag("error:%u:%s:%s: Open ENOENT error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
flog("Missing file '%s'.\n", handle[j].path);
|
||||
flog("WARNING! You cannot modify data disk during a sync.\n");
|
||||
flog("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 */
|
||||
|
|
@ -644,10 +644,10 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
|
||||
if (errno == EACCES) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open EACCES error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "No access at file '%s'.\n", handle[j].path);
|
||||
fprintf(stderr, "WARNING! Please fix the access permission in the data disk.\n");
|
||||
fprintf(stderr, "Rerun the sync command when finished.\n");
|
||||
ftag("error:%u:%s:%s: Open EACCES error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
flog("No access at file '%s'.\n", handle[j].path);
|
||||
flog("WARNING! Please fix the access permission in the data disk.\n");
|
||||
flog("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;
|
||||
|
|
@ -655,9 +655,9 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stdlog, "error:%u:%s:%s: Open error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Open error. %s\n", i, disk->name, file->sub, strerror(errno));
|
||||
ferr("WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that file '%s' can be accessed.\n", handle[j].path);
|
||||
printf("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -672,17 +672,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);
|
||||
fprintf(stdlog, "error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, file->sub);
|
||||
ftag("error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, file->sub);
|
||||
if (handle[j].st.st_size != file->size) {
|
||||
fprintf(stderr, "Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, handle[j].st.st_size);
|
||||
flog("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) {
|
||||
fprintf(stderr, "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));
|
||||
flog("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 {
|
||||
fprintf(stderr, "Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
|
||||
flog("Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
|
||||
}
|
||||
fprintf(stderr, "WARNING! You cannot modify files during a sync.\n");
|
||||
fprintf(stderr, "Rerun the sync command when finished.\n");
|
||||
flog("WARNING! You cannot modify files during a sync.\n");
|
||||
flog("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 */
|
||||
|
|
@ -690,30 +690,30 @@ 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, stderr);
|
||||
read_size = handle_read(&handle[j], block, buffer[j], state->block_size, flog);
|
||||
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) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
ftag("error:%u:%s:%s: Read EIO error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
fprintf(stderr, "DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle[j].path);
|
||||
ferr("DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle[j].path);
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Input/Output error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
|
||||
flog("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;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
|
||||
fprintf(stderr, "Ensure that file '%s' can be read.\n", handle[j].path);
|
||||
ftag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, file->sub, block_file_pos(block), strerror(errno));
|
||||
ferr("WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
|
||||
ferr("Ensure that file '%s' can be read.\n", handle[j].path);
|
||||
printf("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -744,17 +744,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)) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Unexpected data change\n", i, disk->name, file->sub);
|
||||
fprintf(stderr, "Data change at file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
|
||||
fprintf(stderr, "WARNING! Unexpected data modification of a file without parity!\n");
|
||||
ftag("error:%u:%s:%s: Unexpected data change\n", i, disk->name, file->sub);
|
||||
flog("Data change at file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
|
||||
flog("WARNING! Unexpected data modification of a file without parity!\n");
|
||||
|
||||
if (file_flag_has(file, FILE_IS_COPY)) {
|
||||
fprintf(stderr, "This file was detected as a copy of another file with the same name, size,\n");
|
||||
fprintf(stderr, "and timestamp, but the file data isn't matching the assumed copy.\n");
|
||||
fprintf(stderr, "If this is a false positive, and the files are expected to be different,\n");
|
||||
fprintf(stderr, "you can 'sync' anyway using 'snapraid --force-nocopy sync'\n");
|
||||
flog("This file was detected as a copy of another file with the same name, size,\n");
|
||||
flog("and timestamp, but the file data isn't matching the assumed copy.\n");
|
||||
flog("If this is a false positive, and the files are expected to be different,\n");
|
||||
flog("you can 'sync' anyway using 'snapraid --force-nocopy sync'\n");
|
||||
} else {
|
||||
fprintf(stderr, "Try removing the file from the array and rerun the 'sync' command!\n");
|
||||
flog("Try removing the file from the array and rerun the 'sync' command!\n");
|
||||
}
|
||||
|
||||
++error;
|
||||
|
|
@ -764,8 +764,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 */
|
||||
fprintf(stdlog, "error:%u:%s:%s: Data error at position %u\n", i, disk->name, file->sub, block_file_pos(block));
|
||||
fprintf(stderr, "Data error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
|
||||
ftag("error:%u:%s:%s: Data error at position %u\n", i, disk->name, file->sub, block_file_pos(block));
|
||||
flog("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;
|
||||
|
|
@ -858,28 +858,28 @@ 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, stdlog);
|
||||
ret = parity_read(parity[l], i, buffer[diskmax + l], state->block_size, flog);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == EIO) {
|
||||
fprintf(stdlog, "parity_error:%u:%s: Read EIO error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
ftag("parity_error:%u:%s: Read EIO error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
fprintf(stderr, "DANGER! Unexpected input/output read error in the %s disk, it isn't possible to sync.\n", lev_name(l));
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and can be read.\n", lev_config_name(l));
|
||||
ferr("DANGER! Unexpected input/output read error in the %s disk, it isn't possible to sync.\n", lev_name(l));
|
||||
ferr("Ensure that disk '%s' is sane and can be read.\n", lev_config_name(l));
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
|
||||
flog("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
|
||||
++io_error;
|
||||
io_error_on_this_block = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "parity_error:%u:%s: Read error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected read error in the %s disk, it isn't possible to sync.\n", lev_name(l));
|
||||
fprintf(stderr, "Ensure that disk '%s' can be read.\n", lev_config_name(l));
|
||||
ftag("parity_error:%u:%s: Read error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
ferr("WARNING! Unexpected read error in the %s disk, it isn't possible to sync.\n", lev_name(l));
|
||||
ferr("Ensure that disk '%s' can be read.\n", lev_config_name(l));
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -957,24 +957,24 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == EIO) {
|
||||
fprintf(stdlog, "parity_error:%u:%s: Write EIO error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
ftag("parity_error:%u:%s: Write EIO error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
fprintf(stderr, "DANGER! Unexpected input/output write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane and can be written.\n", lev_config_name(l));
|
||||
ferr("DANGER! Unexpected input/output write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
|
||||
ferr("Ensure that disk '%s' is sane and can be written.\n", lev_config_name(l));
|
||||
printf("Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
|
||||
flog("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(l), i);
|
||||
++io_error;
|
||||
io_error_on_this_block = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stdlog, "parity_error:%u:%s: Write error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
fprintf(stderr, "WARNING! Unexpected write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
|
||||
fprintf(stderr, "Ensure that disk '%s' has some free space available.\n", lev_config_name(l));
|
||||
ftag("parity_error:%u:%s: Write error. %s\n", i, lev_config_name(l), strerror(errno));
|
||||
ferr("WARNING! Unexpected write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
|
||||
ferr("Ensure that disk '%s' has some free space available.\n", lev_config_name(l));
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -1078,9 +1078,9 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
ret = parity_sync(parity[l]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stdlog, "parity_error:%u:%s: Sync error\n", i, lev_config_name(l));
|
||||
fprintf(stderr, "DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane.\n", lev_config_name(l));
|
||||
ftag("parity_error:%u:%s: Sync error\n", i, lev_config_name(l));
|
||||
ferr("DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
|
||||
ferr("Ensure that disk '%s' is sane.\n", lev_config_name(l));
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -1109,9 +1109,9 @@ end:
|
|||
ret = parity_sync(parity[l]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stdlog, "parity_error:%u:%s: Sync error\n", i, lev_config_name(l));
|
||||
fprintf(stderr, "DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
|
||||
fprintf(stderr, "Ensure that disk '%s' is sane.\n", lev_config_name(l));
|
||||
ftag("parity_error:%u:%s: Sync error\n", i, lev_config_name(l));
|
||||
ferr("DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
|
||||
ferr("Ensure that disk '%s' is sane.\n", lev_config_name(l));
|
||||
printf("Stopping at block %u\n", i);
|
||||
++error;
|
||||
goto bail;
|
||||
|
|
@ -1120,12 +1120,12 @@ end:
|
|||
}
|
||||
|
||||
if (io_error)
|
||||
fprintf(stderr, "WARNING! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
|
||||
ferr("WARNING! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
|
||||
if (silent_error)
|
||||
fprintf(stderr, "WARNING! Unexpected data errors! The failing blocks are now marked as bad!\n");
|
||||
ferr("WARNING! Unexpected data errors! The failing blocks are now marked as bad!\n");
|
||||
if (io_error || silent_error) {
|
||||
fprintf(stderr, "Use 'snapraid status' to list the bad blocks.\n");
|
||||
fprintf(stderr, "Use 'snapraid -e fix' to recover.\n");
|
||||
ferr("Use 'snapraid status' to list the bad blocks.\n");
|
||||
ferr("Use 'snapraid -e fix' to recover.\n");
|
||||
}
|
||||
|
||||
if (error || silent_error || io_error) {
|
||||
|
|
@ -1140,13 +1140,13 @@ end:
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
fprintf(stdlog, "summary:error_file:%u\n", error);
|
||||
fprintf(stdlog, "summary:error_io:%u\n", io_error);
|
||||
fprintf(stdlog, "summary:error_data:%u\n", silent_error);
|
||||
ftag("summary:error_file:%u\n", error);
|
||||
ftag("summary:error_io:%u\n", io_error);
|
||||
ftag("summary:error_data:%u\n", silent_error);
|
||||
if (error + silent_error + io_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
ftag("summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
ftag("summary:exit:error\n");
|
||||
fflush(stdlog);
|
||||
|
||||
bail:
|
||||
|
|
@ -1154,7 +1154,7 @@ bail:
|
|||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Unexpected close error in a data disk.\n");
|
||||
ferr("DANGER! Unexpected close error in a data disk.\n");
|
||||
++error;
|
||||
/* continue, as we are already exiting */
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1207,7 +1207,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
|
||||
if (blockstart > blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error in the starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
|
||||
ferr("Error in the starting block %u. It's bigger than the parity size %u.\n", blockstart, blockmax);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1225,7 +1225,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 */
|
||||
fprintf(stderr, "WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
ferr("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1235,7 +1235,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) {
|
||||
fprintf(stderr, "WARNING! The %s file %s has data only %u blocks instead of %u.\n", lev_name(l), state->parity[l].path, parityblocks, used_paritymax);
|
||||
ferr("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 */
|
||||
|
|
@ -1248,15 +1248,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 */
|
||||
fprintf(stderr, "DANGER! One or more the parity files are smaller than expected!\n");
|
||||
ferr("DANGER! One or more the parity files are smaller than expected!\n");
|
||||
if (file_paritymax != 0) {
|
||||
fprintf(stderr, "If this happens because you are using an old content file,\n");
|
||||
fprintf(stderr, "you can 'sync' anyway using 'snapraid --force-full sync'\n");
|
||||
fprintf(stderr, "to force a full rebuild of the parity.\n");
|
||||
ferr("If this happens because you are using an old content file,\n");
|
||||
ferr("you can 'sync' anyway using 'snapraid --force-full sync'\n");
|
||||
ferr("to force a full rebuild of the parity.\n");
|
||||
} else {
|
||||
fprintf(stderr, "It's possible that the parity disks are not mounted.\n");
|
||||
fprintf(stderr, "If instead you are adding a new parity level, you can 'sync' using\n");
|
||||
fprintf(stderr, "'snapraid --force-full sync' to force a full rebuild of the parity.\n");
|
||||
ferr("It's possible that the parity disks are not mounted.\n");
|
||||
ferr("If instead you are adding a new parity level, you can 'sync' using\n");
|
||||
ferr("'snapraid --force-full sync' to force a full rebuild of the parity.\n");
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1272,7 +1272,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);
|
||||
fprintf(stderr, "WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
ferr("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1319,7 +1319,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 */
|
||||
fprintf(stderr, "DANGER! Unexpected close error in %s disk.\n", lev_name(l));
|
||||
ferr("DANGER! Unexpected close error in %s disk.\n", lev_name(l));
|
||||
++unrecoverable_error;
|
||||
/* continue, as we are already exiting */
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ static dev_t devread(const char* path)
|
|||
f = open(path, O_RDONLY);
|
||||
if (f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to open '%s'.\n", path);
|
||||
ferr("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);
|
||||
fprintf(stderr, "Failed to read '%s'.\n", path);
|
||||
ferr("Failed to read '%s'.\n", path);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (ret == sizeof(buf)) {
|
||||
/* LCOV_EXCL_START */
|
||||
close(f);
|
||||
fprintf(stderr, "Too long read '%s'.\n", path);
|
||||
ferr("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);
|
||||
fprintf(stderr, "Invalid format in '%s' for '%s'.\n", path, buf);
|
||||
ferr("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);
|
||||
fprintf(stderr, "Invalid format in '%s' for '%s'.\n", path, buf);
|
||||
ferr("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 */
|
||||
fprintf(stderr, "Failed to close '%s'.\n", path);
|
||||
ferr("Failed to close '%s'.\n", path);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -408,13 +408,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 */
|
||||
fprintf(stderr, "Failed to readlink '%s'.\n", path);
|
||||
ferr("Failed to readlink '%s'.\n", path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (ret == sizeof(buf)) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Too long readlink '%s'.\n", path);
|
||||
ferr("Too long readlink '%s'.\n", path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -423,7 +423,7 @@ static int devresolve(dev_t device, char* path, size_t path_size)
|
|||
|
||||
if (buf[0] != '.' || buf[1] != '.' || buf[2] != '/') {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Unexpected link '%s' at '%s'.\n", buf, path);
|
||||
ferr("Unexpected link '%s' at '%s'.\n", buf, path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -434,13 +434,13 @@ static int devresolve(dev_t device, char* path, size_t path_size)
|
|||
/* check the device */
|
||||
if (stat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to stat '%s'.\n", path);
|
||||
ferr("Failed to stat '%s'.\n", path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (st.st_rdev != device) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Unexpected device '%u:%u' instead of '%u:%u' for '%s'.\n", major(st.st_rdev), minor(st.st_rdev), major(device), minor(device), path);
|
||||
ferr("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 */
|
||||
}
|
||||
|
|
@ -552,7 +552,7 @@ static int devscan(tommy_list* list)
|
|||
d = opendir(dir);
|
||||
if (d == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to open dir '%s'.\n", dir);
|
||||
ferr("Failed to open dir '%s'.\n", dir);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -628,7 +628,7 @@ static int devsmart(dev_t device, uint64_t* smart, char* serial)
|
|||
f = popen(cmd, "r");
|
||||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctl -a on device '%u:%u' (from popen).\n", major(device), minor(device));
|
||||
ferr("Failed to run smartctl -a on device '%u:%u' (from popen).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -643,13 +643,13 @@ static int devsmart(dev_t device, uint64_t* smart, char* serial)
|
|||
ret = pclose(f);
|
||||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctl -a on device '%u:%u' (not exited).\n", major(device), minor(device));
|
||||
ferr("Failed to run smartctl -a on device '%u:%u' (not exited).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) == 127) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run smartctl -a on device '%u:%u' (from sh).\n", major(device), minor(device));
|
||||
ferr("Failed to run smartctl -a on device '%u:%u' (from sh).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -674,25 +674,25 @@ static int devdown(dev_t device)
|
|||
ret = system(cmd);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run hdparm -y on device '%u:%u' (from system).\n", major(device), minor(device));
|
||||
ferr("Failed to run hdparm -y on device '%u:%u' (from system).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run hdparm -y on device '%u:%u' (not exited).\n", major(device), minor(device));
|
||||
ferr("Failed to run hdparm -y on device '%u:%u' (not exited).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) == 127) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run hdparm -y on device '%u:%u' (from sh).\n", major(device), minor(device));
|
||||
ferr("Failed to run hdparm -y on device '%u:%u' (from sh).\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to run hdparm -y on device '%u:%u' with return code %xh.\n", major(device), minor(device), WEXITSTATUS(ret));
|
||||
ferr("Failed to run hdparm -y on device '%u:%u' with return code %xh.\n", major(device), minor(device), WEXITSTATUS(ret));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -721,7 +721,7 @@ static int devup(dev_t device, const char* mount)
|
|||
ret = mkdir(path, 0);
|
||||
if (ret != 0 && errno != EEXIST) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to create dir '%s'.\n", path);
|
||||
ferr("Failed to create dir '%s'.\n", path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -750,7 +750,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 */
|
||||
fprintf(stderr, "Failed to stat device '%s'.\n", devinfo->mount);
|
||||
ferr("Failed to stat device '%s'.\n", devinfo->mount);
|
||||
return (void*)-1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -830,7 +830,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
|
|||
|
||||
if (pthread_create(&devinfo->thread, 0, func, devinfo) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to create thread.\n");
|
||||
ferr("Failed to create thread.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -843,7 +843,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
|
|||
|
||||
if (pthread_join(devinfo->thread, &retval) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to join thread.\n");
|
||||
ferr("Failed to join thread.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -879,13 +879,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 */
|
||||
fprintf(stderr, "Missing interface /sys/dev/block.\n");
|
||||
ferr("Missing interface /sys/dev/block.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (stat("/dev/block", &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Missing interface /dev/block.\n");
|
||||
ferr("Missing interface /dev/block.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -897,7 +897,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 */
|
||||
fprintf(stderr, "Failed to resolve device '%u:%u'.\n", major(devinfo->device), minor(devinfo->device));
|
||||
ferr("Failed to resolve device '%u:%u'.\n", major(devinfo->device), minor(devinfo->device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -905,7 +905,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
|
|||
/* expand the tree of devices */
|
||||
if (devtree(devinfo->name, devinfo->device, devinfo, low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to expand device '%u:%u'.\n", major(devinfo->device), minor(devinfo->device));
|
||||
ferr("Failed to expand device '%u:%u'.\n", major(devinfo->device), minor(devinfo->device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -935,7 +935,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
|
|||
if (operation == DEVICE_SMART) {
|
||||
if (devscan(low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Failed to list other devices.\n");
|
||||
ferr("Failed to list other devices.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,8 +926,8 @@ void mtest_vector(int n, size_t size, void** vv)
|
|||
{
|
||||
if (raid_mtest_vector(n, size, vv) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n");
|
||||
fprintf(stderr, "Try running a memory test like http://www.memtest86.com/\n");
|
||||
ferr("DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n");
|
||||
ferr("Try running a memory test like http://www.memtest86.com/\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1347,7 +1347,7 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void*
|
|||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Internal inconsistency in hash function %u\n", kind);
|
||||
ferr("Internal inconsistency in hash function %u\n", kind);
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
|||
12
snapraid.1
12
snapraid.1
|
|
@ -998,14 +998,10 @@ the old content file and the parity data you have.
|
|||
This option can be used only with \[dq]sync\[dq].
|
||||
.TP
|
||||
.B \-l, \-\-log FILE
|
||||
Write a detailed log of errors found in check and fix.
|
||||
This log contains the exact specification of which block of
|
||||
any file is not recoverable and why.
|
||||
If this option is not specified, no detailed log is printed,
|
||||
and you\'ll get only a summary at the end of the operations.
|
||||
When checking and fixing this allows to keep separated
|
||||
the possible huge list of errors from the human readable
|
||||
output.
|
||||
Write a detailed log of errors encoutered.
|
||||
If this option is not specified, the errors are printed on
|
||||
the screen, likely resulting in too much output in case
|
||||
of many errors.
|
||||
If the specified path starts with \'>>\' the file is opened
|
||||
in append mode. Occurrences of \'%D\' and \'%T\' in the name are
|
||||
replaced with the date and time in the format YYYYMMDD and
|
||||
|
|
|
|||
12
snapraid.d
12
snapraid.d
|
|
@ -739,14 +739,10 @@ Options
|
|||
This option can be used only with "sync".
|
||||
|
||||
-l, --log FILE
|
||||
Write a detailed log of errors found in check and fix.
|
||||
This log contains the exact specification of which block of
|
||||
any file is not recoverable and why.
|
||||
If this option is not specified, no detailed log is printed,
|
||||
and you'll get only a summary at the end of the operations.
|
||||
When checking and fixing this allows to keep separated
|
||||
the possible huge list of errors from the human readable
|
||||
output.
|
||||
Write a detailed log of errors encoutered.
|
||||
If this option is not specified, the errors are printed on
|
||||
the screen, likely resulting in too much output in case
|
||||
of many errors.
|
||||
If the specified path starts with '>>' the file is opened
|
||||
in append mode. Occurrences of '%D' and '%T' in the name are
|
||||
replaced with the date and time in the format YYYYMMDD and
|
||||
|
|
|
|||
12
snapraid.txt
12
snapraid.txt
|
|
@ -796,14 +796,10 @@ SnapRAID provides the following options:
|
|||
This option can be used only with "sync".
|
||||
|
||||
-l, --log FILE
|
||||
Write a detailed log of errors found in check and fix.
|
||||
This log contains the exact specification of which block of
|
||||
any file is not recoverable and why.
|
||||
If this option is not specified, no detailed log is printed,
|
||||
and you'll get only a summary at the end of the operations.
|
||||
When checking and fixing this allows to keep separated
|
||||
the possible huge list of errors from the human readable
|
||||
output.
|
||||
Write a detailed log of errors encoutered.
|
||||
If this option is not specified, the errors are printed on
|
||||
the screen, likely resulting in too much output in case
|
||||
of many errors.
|
||||
If the specified path starts with '>>' the file is opened
|
||||
in append mode. Occurrences of '%D' and '%T' in the name are
|
||||
replaced with the date and time in the format YYYYMMDD and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue