mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Put all the stdout output also in stdlog
This commit is contained in:
parent
3884af54ea
commit
2ac751b6d9
21 changed files with 221 additions and 216 deletions
|
|
@ -675,7 +675,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
|
|||
|
||||
ftag("status:unrecoverable:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("unrecoverable %s\n", path);
|
||||
fout("unrecoverable %s\n", path);
|
||||
}
|
||||
|
||||
/* and do not set the time if damaged */
|
||||
|
|
@ -690,7 +690,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
|
|||
|
||||
ftag("status:recovered:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recovered %s\n", path);
|
||||
fout("recovered %s\n", path);
|
||||
}
|
||||
|
||||
inode = handle[j].st.st_ino;
|
||||
|
|
@ -732,23 +732,23 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
|
|||
if (state->opt.auditonly) {
|
||||
ftag("status:damaged:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("damaged %s\n", path);
|
||||
fout("damaged %s\n", path);
|
||||
}
|
||||
} else {
|
||||
ftag("status:unrecoverable:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("unrecoverable %s\n", path);
|
||||
fout("unrecoverable %s\n", path);
|
||||
}
|
||||
}
|
||||
} else if (file_flag_has(file, FILE_IS_FIXED)) {
|
||||
ftag("status:recoverable:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recoverable %s\n", path);
|
||||
fout("recoverable %s\n", path);
|
||||
}
|
||||
} else {
|
||||
ftag("status:correct:%s:%s\n", disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("correct %s\n", path);
|
||||
fout("correct %s\n", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1445,7 +1445,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
|
||||
ftag("status:recovered:%s:%s\n", disk->name, file->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recovered %s%s\n", disk->dir, file->sub);
|
||||
fout("recovered %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1618,7 +1618,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
|
||||
ftag("status:recovered:%s:%s\n", disk->name, link->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recovered %s%s\n", disk->dir, link->sub);
|
||||
fout("recovered %s%s\n", disk->dir, link->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1690,7 +1690,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
|
||||
ftag("status:recovered:%s:%s\n", disk->name, dir->sub);
|
||||
if (!state->opt.quiet) {
|
||||
printf("recovered %s%s\n", disk->dir, dir->sub);
|
||||
fout("recovered %s%s\n", disk->dir, dir->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1763,25 +1763,25 @@ bail:
|
|||
}
|
||||
|
||||
if (error || recovered_error || unrecoverable_error) {
|
||||
printf("\n");
|
||||
printf("%8u read/data errors\n", error);
|
||||
fout("\n");
|
||||
fout("%8u read/data errors\n", error);
|
||||
if (fix) {
|
||||
printf("%8u recovered errors\n", recovered_error);
|
||||
fout("%8u recovered errors\n", recovered_error);
|
||||
}
|
||||
if (unrecoverable_error) {
|
||||
printf("%8u UNRECOVERABLE errors\n", unrecoverable_error);
|
||||
printf("DANGER! There are unrecoverable errors!\n");
|
||||
fout("%8u UNRECOVERABLE errors\n", unrecoverable_error);
|
||||
fout("DANGER! There are unrecoverable errors!\n");
|
||||
} else {
|
||||
/* without checking, we don't know if they are really recoverable or not */
|
||||
if (!state->opt.auditonly)
|
||||
printf("%8u unrecoverable errors\n", unrecoverable_error);
|
||||
fout("%8u unrecoverable errors\n", unrecoverable_error);
|
||||
if (fix)
|
||||
printf("Everything OK\n");
|
||||
fout("Everything OK\n");
|
||||
else
|
||||
printf("WARNING! There are errors!\n");
|
||||
fout("WARNING! There are errors!\n");
|
||||
}
|
||||
} else {
|
||||
printf("Everything OK\n");
|
||||
fout("Everything OK\n");
|
||||
}
|
||||
|
||||
ftag("summary:error:%u\n", error);
|
||||
|
|
@ -1853,7 +1853,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
|
|||
unsigned error;
|
||||
unsigned l;
|
||||
|
||||
printf("Initializing...\n");
|
||||
fout("Initializing...\n");
|
||||
|
||||
blockmax = parity_allocated_size(state);
|
||||
size = blockmax * (data_off_t)state->block_size;
|
||||
|
|
@ -1898,7 +1898,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
|
|||
parity_ptr[l] = &parity[l];
|
||||
ret = parity_open(parity_ptr[l], state->parity[l].path, state->file_mode);
|
||||
if (ret == -1) {
|
||||
printf("No accessible %s file, only files will be checked.\n", lev_name(l));
|
||||
fout("No accessible %s file, only files will be checked.\n", lev_name(l));
|
||||
/* continue anyway */
|
||||
parity_ptr[l] = 0;
|
||||
}
|
||||
|
|
@ -1910,11 +1910,11 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
|
|||
}
|
||||
|
||||
if (fix)
|
||||
printf("Fixing...\n");
|
||||
fout("Fixing...\n");
|
||||
else if (!state->opt.auditonly)
|
||||
printf("Checking...\n");
|
||||
fout("Checking...\n");
|
||||
else
|
||||
printf("Hashing...\n");
|
||||
fout("Hashing...\n");
|
||||
|
||||
error = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -165,9 +165,9 @@ bail:
|
|||
}
|
||||
|
||||
if (error) {
|
||||
printf("%u read errors\n", error);
|
||||
fout("%u read errors\n", error);
|
||||
} else {
|
||||
printf("Everything OK\n");
|
||||
fout("Everything OK\n");
|
||||
}
|
||||
|
||||
free(handle);
|
||||
|
|
@ -189,7 +189,7 @@ void state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
unsigned error;
|
||||
unsigned l;
|
||||
|
||||
printf("Drying...\n");
|
||||
fout("Drying...\n");
|
||||
|
||||
blockmax = parity_allocated_size(state);
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ void state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
parity_ptr[l] = &parity[l];
|
||||
ret = parity_open(parity_ptr[l], state->parity[l].path, state->file_mode);
|
||||
if (ret == -1) {
|
||||
printf("No accessible %s file.\n", lev_name(l));
|
||||
fout("No accessible %s file.\n", lev_name(l));
|
||||
/* continue anyway */
|
||||
parity_ptr[l] = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ void state_dup(struct snapraid_state* state)
|
|||
count = 0;
|
||||
size = 0;
|
||||
|
||||
printf("Comparing...\n");
|
||||
fout("Comparing...\n");
|
||||
|
||||
/* for each disk */
|
||||
for (i = state->disklist; i != 0; i = i->next) {
|
||||
|
|
@ -126,7 +126,7 @@ void state_dup(struct snapraid_state* state)
|
|||
++count;
|
||||
size += 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);
|
||||
fout("%12" PRIu64 " %s%s = %s%s\n", file->size, disk->dir, file->sub, dup->disk->dir, dup->file->sub);
|
||||
hash_free(hash);
|
||||
} else {
|
||||
tommy_hashdyn_insert(&hashset, &hash->node, hash, hash32);
|
||||
|
|
@ -137,12 +137,12 @@ void state_dup(struct snapraid_state* state)
|
|||
tommy_hashdyn_foreach(&hashset, (tommy_foreach_func*)hash_free);
|
||||
tommy_hashdyn_done(&hashset);
|
||||
|
||||
printf("\n");
|
||||
printf("%8u duplicates, for %" PRIu64 " MiB\n", count, size / (1024 * 1024));
|
||||
fout("\n");
|
||||
fout("%8u duplicates, for %" PRIu64 " MiB\n", count, size / (1024 * 1024));
|
||||
if (count)
|
||||
printf("There are duplicates!\n");
|
||||
fout("There are duplicates!\n");
|
||||
else
|
||||
printf("No duplicates\n");
|
||||
fout("No duplicates\n");
|
||||
|
||||
ftag("summary:dup_count:%u\n", count);
|
||||
ftag("summary:dup_size:%" PRIu64 "\n", size);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#define __ELEM_H
|
||||
|
||||
#include "util.h"
|
||||
#include "support.h"
|
||||
#include "tommyds/tommylist.h"
|
||||
#include "tommyds/tommyhash.h"
|
||||
#include "tommyds/tommyhashdyn.h"
|
||||
|
|
@ -495,7 +496,7 @@ static inline void block_file_set(struct snapraid_block* block, struct snapraid_
|
|||
/* ensure that the pointer doesn't use the flag space */
|
||||
if ((ptr & (uintptr_t)BLOCK_STATE_MASK) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Internal error for pointer not aligned\n");
|
||||
ferr("Internal error for pointer not aligned\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -522,7 +523,7 @@ static inline void block_state_set(struct snapraid_block* block, unsigned state)
|
|||
/* ensure that the state can be stored inside the file pointer */
|
||||
if ((state & BLOCK_STATE_MASK) != state) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Internal error when setting the block state %u\n", state);
|
||||
ferr("Internal error when setting the block state %u\n", state);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ void state_import(struct snapraid_state* state, const char* dir)
|
|||
{
|
||||
char path[PATH_MAX];
|
||||
|
||||
printf("Importing...\n");
|
||||
fout("Importing...\n");
|
||||
|
||||
/* add the final slash */
|
||||
pathimport(path, sizeof(path), dir);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void state_list(struct snapraid_state* state)
|
|||
file_size = 0;
|
||||
link_count = 0;
|
||||
|
||||
printf("Listing...\n");
|
||||
fout("Listing...\n");
|
||||
|
||||
/* for each disk */
|
||||
for (i = state->disklist; i != 0; i = i->next) {
|
||||
|
|
@ -109,9 +109,9 @@ void state_list(struct snapraid_state* state)
|
|||
printf("%s%s -> %s%s\n", disk->dir, link->sub, disk->dir, link->linkto);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
printf("%8u files, for %" PRIu64 " GiB\n", file_count, file_size / (1024 * 1024 * 1024));
|
||||
printf("%8u links\n", link_count);
|
||||
fout("\n");
|
||||
fout("%8u files, for %" PRIu64 " GiB\n", file_count, file_size / (1024 * 1024 * 1024));
|
||||
fout("%8u links\n", link_count);
|
||||
|
||||
ftag("summary:file_count:%u\n", file_count);
|
||||
ftag("summary:file_size:%" PRIu64 "\n", file_size);
|
||||
|
|
|
|||
|
|
@ -633,14 +633,14 @@ void cmd_change(const char* path, int size)
|
|||
|
||||
void help(void)
|
||||
{
|
||||
printf("Test for " PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
|
||||
printf("Usage:\n");
|
||||
printf("\tmktest generate SEED DISK_NUM FILE_NUM FILE_SIZE\n");
|
||||
printf("\tmktest damage SEED NUM SIZE FILE\n");
|
||||
printf("\tmktest write SEED NUM SIZE FILE\n");
|
||||
printf("\tmktest change SEED SIZE FILE\n");
|
||||
printf("\tmktest append SEED SIZE FILE\n");
|
||||
printf("\tmktest truncate SEED SIZE FILE\n");
|
||||
fout("Test for " PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
|
||||
fout("Usage:\n");
|
||||
fout("\tmktest generate SEED DISK_NUM FILE_NUM FILE_SIZE\n");
|
||||
fout("\tmktest damage SEED NUM SIZE FILE\n");
|
||||
fout("\tmktest write SEED NUM SIZE FILE\n");
|
||||
fout("\tmktest change SEED SIZE FILE\n");
|
||||
fout("\tmktest append SEED SIZE FILE\n");
|
||||
fout("\tmktest truncate SEED SIZE FILE\n");
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ void state_nano(struct snapraid_state* state)
|
|||
{
|
||||
tommy_node* i;
|
||||
|
||||
printf("Setting nanosecond timestamps...\n");
|
||||
fout("Setting nanosecond timestamps...\n");
|
||||
|
||||
/* for all disks */
|
||||
for (i = state->disklist; i != 0; i = i->next) {
|
||||
|
|
@ -126,7 +126,7 @@ void state_nano(struct snapraid_state* state)
|
|||
state->need_write = 1;
|
||||
|
||||
ftag("nano:%s:%s\n", disk->name, file->sub);
|
||||
printf("nano %s%s\n", disk->dir, file->sub);
|
||||
fout("nano %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,10 +106,10 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
|
|||
fflush_log();
|
||||
if (first) {
|
||||
first = 0;
|
||||
printf("\nYour data requires more parity than the available space.\n");
|
||||
printf("Please move the following files to another data disk:\n");
|
||||
fout("\nYour data requires more parity than the available space.\n");
|
||||
fout("Please move the following files to another data disk:\n");
|
||||
}
|
||||
printf("outofparity %s%s\n", disk->dir, file->sub);
|
||||
fout("outofparity %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
} else {
|
||||
ignored = 1;
|
||||
if (state->opt.verbose) {
|
||||
printf("Ignoring pool file '%s'\n", path_next);
|
||||
fout("Ignoring pool file '%s'\n", path_next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ void state_pool(struct snapraid_state* state)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
printf("Cleaning...\n");
|
||||
fout("Cleaning...\n");
|
||||
|
||||
/* pool directory with final slash */
|
||||
pathprint(pool_dir, sizeof(pool_dir), "%s", state->pool);
|
||||
|
|
@ -227,7 +227,7 @@ void state_pool(struct snapraid_state* state)
|
|||
/* first clear the previous pool tree */
|
||||
clean_dir(state, pool_dir);
|
||||
|
||||
printf("Pooling...\n");
|
||||
fout("Pooling...\n");
|
||||
|
||||
/* for each disk */
|
||||
count = 0;
|
||||
|
|
@ -253,9 +253,9 @@ void state_pool(struct snapraid_state* state)
|
|||
}
|
||||
|
||||
if (count)
|
||||
printf("%u links created\n", count);
|
||||
fout("%u links created\n", count);
|
||||
else
|
||||
printf("No link created\n");
|
||||
fout("No link created\n");
|
||||
|
||||
ftag("summary:link_count::%u\n", count);
|
||||
ftag("summary:exit:ok\n");
|
||||
|
|
|
|||
|
|
@ -91,9 +91,8 @@ void state_rehash(struct snapraid_state* state)
|
|||
/* save the new content file */
|
||||
state->need_write = 1;
|
||||
|
||||
printf(
|
||||
"A rehash is now scheduled. It will take place progressively in the next\n"
|
||||
"'sync' and 'scrub' commands. You can check the rehash progress using the\n"
|
||||
"'status' command.\n");
|
||||
fout("A rehash is now scheduled. It will take place progressively in the next\n");
|
||||
fout("'sync' and 'scrub' commands. You can check the rehash progress using the\n");
|
||||
fout("'status' command.\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
|
||||
ftag("scan:update:%s:%s\n", disk->name, link->sub);
|
||||
if (is_diff) {
|
||||
printf("update %s%s\n", disk->dir, link->sub);
|
||||
fout("update %s%s\n", disk->dir, link->sub);
|
||||
}
|
||||
|
||||
/* update it */
|
||||
|
|
@ -137,7 +137,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
|
||||
ftag("scan:add:%s:%s\n", disk->name, sub);
|
||||
if (is_diff) {
|
||||
printf("add %s%s\n", disk->dir, sub);
|
||||
fout("add %s%s\n", disk->dir, sub);
|
||||
}
|
||||
|
||||
/* and continue to insert it */
|
||||
|
|
@ -640,7 +640,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* 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);
|
||||
fout("move %s%s -> %s%s\n", disk->dir, file->sub, disk->dir, sub);
|
||||
}
|
||||
|
||||
/* remove from the name set */
|
||||
|
|
@ -777,7 +777,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
|
||||
ftag("scan:restore:%s:%s\n", disk->name, sub);
|
||||
if (is_diff) {
|
||||
printf("restore %s%s\n", disk->dir, sub);
|
||||
fout("restore %s%s\n", disk->dir, sub);
|
||||
}
|
||||
|
||||
/* remove from the inode set */
|
||||
|
|
@ -877,7 +877,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* 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);
|
||||
fout("copy %s%s -> %s%s\n", other_disk->dir, other_file->sub, disk->dir, file->sub);
|
||||
}
|
||||
|
||||
/* mark it as reported */
|
||||
|
|
@ -896,14 +896,14 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
|
||||
ftag("scan:update:%s:%s\n", disk->name, sub);
|
||||
if (is_diff) {
|
||||
printf("update %s%s\n", disk->dir, sub);
|
||||
fout("update %s%s\n", disk->dir, sub);
|
||||
}
|
||||
} else {
|
||||
++scan->count_insert;
|
||||
|
||||
ftag("scan:add:%s:%s\n", disk->name, sub);
|
||||
if (is_diff) {
|
||||
printf("add %s%s\n", disk->dir, sub);
|
||||
fout("add %s%s\n", disk->dir, sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1118,7 +1118,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
/* exclude hidden files even before calling lstat() */
|
||||
if (filter_hidden(state->filter_hidden, dd) != 0) {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding hidden '%s'\n", path_next);
|
||||
fout("Excluding hidden '%s'\n", path_next);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1126,7 +1126,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
/* exclude content files even before calling lstat() */
|
||||
if (filter_content(&state->contentlist, path_next) != 0) {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding content '%s'\n", path_next);
|
||||
fout("Excluding content '%s'\n", path_next);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1263,7 +1263,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
processed = 1;
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
fout("Excluding file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
} else if (type == 1) { /* LNK */
|
||||
|
|
@ -1293,7 +1293,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
processed = 1;
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
fout("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
} else if (type == 2) { /* DIR */
|
||||
|
|
@ -1325,7 +1325,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
}
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
fout("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1337,7 +1337,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
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)));
|
||||
fout("Excluding special file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1362,7 +1362,7 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
tommy_list_init(&scanlist);
|
||||
|
||||
if (is_diff)
|
||||
printf("Comparing...\n");
|
||||
fout("Comparing...\n");
|
||||
|
||||
/* first scan all the directory and find new and deleted files */
|
||||
for (i = state->disklist; i != 0; i = i->next) {
|
||||
|
|
@ -1389,7 +1389,7 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
tommy_list_insert_tail(&scanlist, &scan->node, scan);
|
||||
|
||||
if (!is_diff)
|
||||
printf("Scanning disk %s...\n", disk->name);
|
||||
fout("Scanning disk %s...\n", disk->name);
|
||||
|
||||
/* check if the disk supports persistent inodes */
|
||||
ret = fsinfo(disk->dir, &has_persistent_inode, 0, 0);
|
||||
|
|
@ -1457,7 +1457,7 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
|
||||
ftag("scan:remove:%s:%s\n", disk->name, file->sub);
|
||||
if (is_diff) {
|
||||
printf("remove %s%s\n", disk->dir, file->sub);
|
||||
fout("remove %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
|
||||
scan_file_remove(scan, file);
|
||||
|
|
@ -1478,7 +1478,7 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
|
||||
ftag("scan:remove:%s:%s\n", disk->name, link->sub);
|
||||
if (is_diff) {
|
||||
printf("remove %s%s\n", disk->dir, link->sub);
|
||||
fout("remove %s%s\n", disk->dir, link->sub);
|
||||
}
|
||||
|
||||
scan_link_remove(scan, link);
|
||||
|
|
@ -1716,14 +1716,14 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
|
||||
if (state->opt.verbose || is_diff) {
|
||||
if (is_diff)
|
||||
printf("\n");
|
||||
printf("%8u equal\n", total.count_equal);
|
||||
printf("%8u moved\n", total.count_move);
|
||||
printf("%8u copied\n", total.count_copy);
|
||||
printf("%8u restored\n", total.count_restore);
|
||||
printf("%8u updated\n", total.count_change);
|
||||
printf("%8u removed\n", total.count_remove);
|
||||
printf("%8u added\n", total.count_insert);
|
||||
fout("\n");
|
||||
fout("%8u equal\n", total.count_equal);
|
||||
fout("%8u moved\n", total.count_move);
|
||||
fout("%8u copied\n", total.count_copy);
|
||||
fout("%8u restored\n", total.count_restore);
|
||||
fout("%8u updated\n", total.count_change);
|
||||
fout("%8u removed\n", total.count_remove);
|
||||
fout("%8u added\n", total.count_insert);
|
||||
}
|
||||
|
||||
ftag("summary:equal:%u\n", total.count_equal);
|
||||
|
|
@ -1739,9 +1739,9 @@ void state_scan(struct snapraid_state* state, int is_diff)
|
|||
|
||||
if (is_diff) {
|
||||
if (no_difference) {
|
||||
printf("No differences\n");
|
||||
fout("No differences\n");
|
||||
} else {
|
||||
printf("There are differences!\n");
|
||||
fout("There are differences!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
|
||||
state_progress_stop(state);
|
||||
|
||||
printf("Autosaving...\n");
|
||||
fout("Autosaving...\n");
|
||||
state_write(state);
|
||||
|
||||
state_progress_restart(state);
|
||||
|
|
@ -484,15 +484,15 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
}
|
||||
|
||||
if (error || silent_error || io_error) {
|
||||
printf("\n");
|
||||
printf("%8u file errors\n", error);
|
||||
printf("%8u io errors\n", io_error);
|
||||
printf("%8u data errors\n", silent_error);
|
||||
printf("WARNING! There are errors!\n");
|
||||
fout("\n");
|
||||
fout("%8u file errors\n", error);
|
||||
fout("%8u io errors\n", io_error);
|
||||
fout("%8u data errors\n", silent_error);
|
||||
fout("WARNING! There are errors!\n");
|
||||
} else {
|
||||
/* print the result only if processed something */
|
||||
if (countpos != 0)
|
||||
printf("Everything OK\n");
|
||||
fout("Everything OK\n");
|
||||
}
|
||||
|
||||
ftag("summary:error_file:%u\n", error);
|
||||
|
|
@ -568,7 +568,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
/* get the present time */
|
||||
now = time(0);
|
||||
|
||||
printf("Initializing...\n");
|
||||
fout("Initializing...\n");
|
||||
|
||||
blockmax = parity_allocated_size(state);
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
}
|
||||
}
|
||||
|
||||
printf("Scrubbing...\n");
|
||||
fout("Scrubbing...\n");
|
||||
|
||||
error = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
/* exclude hidden files even before calling lstat() */
|
||||
if (disk != 0 && filter_hidden(state->filter_hidden, dd) != 0) {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding hidden '%s'\n", path_next);
|
||||
fout("Excluding hidden '%s'\n", path_next);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
/* exclude content files even before calling lstat() */
|
||||
if (disk != 0 && filter_content(&state->contentlist, path_next) != 0) {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding content '%s'\n", path_next);
|
||||
fout("Excluding content '%s'\n", path_next);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
search_file(state, path_next, st.st_size, st.st_mtime, STAT_NSEC(&st));
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
fout("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
|
|
@ -250,7 +250,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
search_dir(state, disk, path_next, sub_next);
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
fout("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ void state_search(struct snapraid_state* state, const char* dir)
|
|||
{
|
||||
char path[PATH_MAX];
|
||||
|
||||
printf("Importing...\n");
|
||||
fout("Importing...\n");
|
||||
|
||||
/* add the final slash */
|
||||
pathimport(path, sizeof(path), dir);
|
||||
|
|
@ -285,7 +285,7 @@ void state_search_array(struct snapraid_state* state)
|
|||
for (i = state->disklist; i != 0; i = i->next) {
|
||||
struct snapraid_disk* disk = i->data;
|
||||
|
||||
printf("Scanning disk %s...\n", disk->name);
|
||||
fout("Scanning disk %s...\n", disk->name);
|
||||
|
||||
search_dir(state, disk, disk->dir, "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ void selftest(void)
|
|||
ftag("selftest:\n");
|
||||
fflush_log();
|
||||
|
||||
printf("Self test...\n");
|
||||
fout("Self test...\n");
|
||||
|
||||
/* large file check */
|
||||
if (sizeof(off_t) < sizeof(uint64_t)) {
|
||||
|
|
|
|||
|
|
@ -30,54 +30,54 @@
|
|||
|
||||
void version(void)
|
||||
{
|
||||
printf(PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
|
||||
fout(PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
|
||||
}
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
version();
|
||||
|
||||
printf("Usage: " PACKAGE " status|diff|sync|scrub|list|dup|up|down|smart|pool|check|fix [options]\n");
|
||||
printf("\n");
|
||||
printf("Commands:\n");
|
||||
printf(" status Print the status of the array\n");
|
||||
printf(" diff Show the changes that needs to be syncronized\n");
|
||||
printf(" sync Syncronize the state of the array\n");
|
||||
printf(" scrub Scrub the array\n");
|
||||
printf(" list List the array content\n");
|
||||
printf(" dup Find duplicate files\n");
|
||||
printf(" up Spinup the array\n");
|
||||
printf(" down Spindown the array\n");
|
||||
printf(" smart SMART attributes of the array\n");
|
||||
printf(" pool Create or update the virtual view of the array\n");
|
||||
printf(" check Check the array\n");
|
||||
printf(" fix Fix the array\n");
|
||||
printf("\n");
|
||||
printf("Options:\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-c, --conf FILE ", "-c") " Configuration file\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-f, --filter PATTERN ", "-f") " Process only files matching the pattern\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-d, --filter-disk NAME", "-f") " Process only files in the specified disk\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-m, --filter-missing ", "-m") " Process only missing/deleted files\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-e, --filter-error ", "-e") " Process only files with errors\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-p, --percentage PERC ", "-p") " Process only a part of the array\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-o, --older-than DAYS ", "-o") " Process only the older part of the array\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-i, --import DIR ", "-i") " Import deleted files\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-l, --log FILE ", "-l") " Log file. Default none\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-a, --audit-only ", "-a") " Check only file data and not parity\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-h, --pre-hash ", "-h") " Pre hash all the new data\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-Z, --force-zero ", "-Z") " Force synching of files that get zero size\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-E, --force-empty ", "-E") " Force synching of disks that get empty\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-U, --force-uuid ", "-U") " Force commands on disks with uuid changed\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-D, --force-device ", "-D") " Force commands on disks with same device id\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-N, --force-nocopy ", "-N") " Force commands disabling the copy detection\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-F, --force-full ", "-F") " Force commands requiring a full sync\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-v, --verbose ", "-v") " Verbose\n");
|
||||
fout("Usage: " PACKAGE " status|diff|sync|scrub|list|dup|up|down|smart|pool|check|fix [options]\n");
|
||||
fout("\n");
|
||||
fout("Commands:\n");
|
||||
fout(" status Print the status of the array\n");
|
||||
fout(" diff Show the changes that needs to be syncronized\n");
|
||||
fout(" sync Syncronize the state of the array\n");
|
||||
fout(" scrub Scrub the array\n");
|
||||
fout(" list List the array content\n");
|
||||
fout(" dup Find duplicate files\n");
|
||||
fout(" up Spinup the array\n");
|
||||
fout(" down Spindown the array\n");
|
||||
fout(" smart SMART attributes of the array\n");
|
||||
fout(" pool Create or update the virtual view of the array\n");
|
||||
fout(" check Check the array\n");
|
||||
fout(" fix Fix the array\n");
|
||||
fout("\n");
|
||||
fout("Options:\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-c, --conf FILE ", "-c") " Configuration file\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-f, --filter PATTERN ", "-f") " Process only files matching the pattern\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-d, --filter-disk NAME", "-f") " Process only files in the specified disk\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-m, --filter-missing ", "-m") " Process only missing/deleted files\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-e, --filter-error ", "-e") " Process only files with errors\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-p, --percentage PERC ", "-p") " Process only a part of the array\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-o, --older-than DAYS ", "-o") " Process only the older part of the array\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-i, --import DIR ", "-i") " Import deleted files\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-l, --log FILE ", "-l") " Log file. Default none\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-a, --audit-only ", "-a") " Check only file data and not parity\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-h, --pre-hash ", "-h") " Pre hash all the new data\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-Z, --force-zero ", "-Z") " Force synching of files that get zero size\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-E, --force-empty ", "-E") " Force synching of disks that get empty\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-U, --force-uuid ", "-U") " Force commands on disks with uuid changed\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-D, --force-device ", "-D") " Force commands on disks with same device id\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-N, --force-nocopy ", "-N") " Force commands disabling the copy detection\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-F, --force-full ", "-F") " Force commands requiring a full sync\n");
|
||||
fout(" " SWITCH_GETOPT_LONG("-v, --verbose ", "-v") " Verbose\n");
|
||||
}
|
||||
|
||||
void memory(void)
|
||||
{
|
||||
ftag("memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter());
|
||||
printf("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024));
|
||||
fout("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024));
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -2409,10 +2409,10 @@ static void state_read_text(struct snapraid_state* state, const char* path, STRE
|
|||
}
|
||||
|
||||
if (state->opt.verbose) {
|
||||
printf("%8u files\n", count_file);
|
||||
printf("%8u hardlinks\n", count_hardlink);
|
||||
printf("%8u symlinks\n", count_symlink);
|
||||
printf("%8u empty dirs\n", count_dir);
|
||||
fout("%8u files\n", count_file);
|
||||
fout("%8u hardlinks\n", count_hardlink);
|
||||
fout("%8u symlinks\n", count_symlink);
|
||||
fout("%8u empty dirs\n", count_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2797,10 +2797,10 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
|
|||
}
|
||||
|
||||
if (state->opt.verbose) {
|
||||
printf("%8u files\n", count_file);
|
||||
printf("%8u hardlinks\n", count_hardlink);
|
||||
printf("%8u symlinks\n", count_symlink);
|
||||
printf("%8u empty dirs\n", count_dir);
|
||||
fout("%8u files\n", count_file);
|
||||
fout("%8u hardlinks\n", count_hardlink);
|
||||
fout("%8u symlinks\n", count_symlink);
|
||||
fout("%8u empty dirs\n", count_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3811,10 +3811,10 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
|
|||
}
|
||||
|
||||
if (state->opt.verbose) {
|
||||
printf("%8u files\n", count_file);
|
||||
printf("%8u hardlinks\n", count_hardlink);
|
||||
printf("%8u symlinks\n", count_symlink);
|
||||
printf("%8u empty dirs\n", count_dir);
|
||||
fout("%8u files\n", count_file);
|
||||
fout("%8u hardlinks\n", count_hardlink);
|
||||
fout("%8u symlinks\n", count_symlink);
|
||||
fout("%8u empty dirs\n", count_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4259,10 +4259,10 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
|
|||
}
|
||||
|
||||
if (state->opt.verbose) {
|
||||
printf("%8u files\n", count_file);
|
||||
printf("%8u hardlinks\n", count_hardlink);
|
||||
printf("%8u symlinks\n", count_symlink);
|
||||
printf("%8u empty dirs\n", count_dir);
|
||||
fout("%8u files\n", count_file);
|
||||
fout("%8u hardlinks\n", count_hardlink);
|
||||
fout("%8u symlinks\n", count_symlink);
|
||||
fout("%8u empty dirs\n", count_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4286,7 +4286,7 @@ void state_read(struct snapraid_state* state)
|
|||
ftag("content:%s\n", path);
|
||||
fflush_log();
|
||||
}
|
||||
printf("Loading state from %s...\n", path);
|
||||
fout("Loading state from %s...\n", path);
|
||||
|
||||
f = sopen_read(path);
|
||||
if (f != 0) {
|
||||
|
|
@ -4425,7 +4425,7 @@ void state_write(struct snapraid_state* state)
|
|||
i = tommy_list_head(&state->contentlist);
|
||||
while (i) {
|
||||
struct snapraid_content* content = i->data;
|
||||
printf("Saving state to %s...\n", content->content);
|
||||
fout("Saving state to %s...\n", content->content);
|
||||
++count_content;
|
||||
i = i->next;
|
||||
}
|
||||
|
|
@ -4515,28 +4515,22 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom
|
|||
if (!filter_missing && !filter_error && tommy_list_empty(filterlist_file) && tommy_list_empty(filterlist_disk))
|
||||
return;
|
||||
|
||||
printf("Filtering...\n");
|
||||
fout("Filtering...\n");
|
||||
|
||||
if (state->opt.verbose) {
|
||||
tommy_node* k;
|
||||
for (k = tommy_list_head(filterlist_disk); k != 0; k = k->next) {
|
||||
struct snapraid_filter* filter = k->data;
|
||||
printf("\t%s", filter->pattern);
|
||||
if (filter->is_disk)
|
||||
printf("//");
|
||||
printf("\n");
|
||||
fout("\t%s%s\n", filter->pattern, filter->is_disk ? "//" : "");
|
||||
}
|
||||
for (k = tommy_list_head(filterlist_file); k != 0; k = k->next) {
|
||||
struct snapraid_filter* filter = k->data;
|
||||
printf("\t%s", filter->pattern);
|
||||
if (filter->is_dir)
|
||||
printf("/");
|
||||
printf("\n");
|
||||
fout("\t%s%s\n", filter->pattern, filter->is_dir ? "/" : "");
|
||||
}
|
||||
if (filter_missing)
|
||||
printf("\t<missing>\n");
|
||||
fout("\t<missing>\n");
|
||||
if (filter_error)
|
||||
printf("\t<error>\n");
|
||||
fout("\t<error>\n");
|
||||
}
|
||||
|
||||
/* for each disk */
|
||||
|
|
@ -4546,7 +4540,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom
|
|||
|
||||
/* if we filter for presence, we have to access the disk, so better to print something */
|
||||
if (filter_missing)
|
||||
printf("Scanning disk %s...\n", disk->name);
|
||||
fout("Scanning disk %s...\n", disk->name);
|
||||
|
||||
/* for each file */
|
||||
for (j = tommy_list_head(&disk->filelist); j != 0; j = j->next) {
|
||||
|
|
@ -4608,7 +4602,7 @@ int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, b
|
|||
if (global_interrupt) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (!state->opt.gui) {
|
||||
printf("Not starting for interruption\n");
|
||||
fout("Not starting for interruption\n");
|
||||
}
|
||||
ftag("sigint:0: SIGINT received\n");
|
||||
fflush_log();
|
||||
|
|
@ -4640,7 +4634,7 @@ void state_progress_end(struct snapraid_state* state, block_off_t countpos, bloc
|
|||
printf(" in %u:%02u", (unsigned)(elapsed / 3600), (unsigned)((elapsed % 3600) / 60));
|
||||
printf("\n");
|
||||
} else {
|
||||
printf("Nothing to do\n");
|
||||
fout("Nothing to do\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4760,6 +4754,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
|
|||
ftag("run:pos:%u:%u:%" PRIu64 ":%u:%u:%u:%u:%" PRIu64 "\n", blockpos, countpos, countsize, out_perc, out_eta, out_speed, out_cpu, (uint64_t)elapsed);
|
||||
fflush_log();
|
||||
} else {
|
||||
/* note that here we don't use fout() becase we don't want this in the log */
|
||||
printf("%u%%, %u MiB", out_perc, (unsigned)(countsize / (1024 * 1024)));
|
||||
if (out_speed)
|
||||
printf(", %u MiB/s", out_speed);
|
||||
|
|
@ -4791,7 +4786,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
|
|||
if (global_interrupt) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (!state->opt.gui) {
|
||||
printf("\n");
|
||||
ferr("\n");
|
||||
ferr("Stopping for interruption at block %u\n", blockpos);
|
||||
}
|
||||
ftag("sigint:%u: SIGINT received\n", blockpos);
|
||||
|
|
@ -4871,36 +4866,36 @@ void generate_configuration(const char* path)
|
|||
state_read(&state);
|
||||
|
||||
/* output a dummy configuration file */
|
||||
printf("# Configuration file generated from %s\n", path);
|
||||
printf("\n");
|
||||
printf("# Use this blocksize\n");
|
||||
printf("blocksize %u\n", state.block_size / 1024);
|
||||
printf("\n");
|
||||
fout("# Configuration file generated from %s\n", path);
|
||||
fout("\n");
|
||||
fout("# Use this blocksize\n");
|
||||
fout("blocksize %u\n", state.block_size / 1024);
|
||||
fout("\n");
|
||||
for (i = 0; i < state.level; ++i) {
|
||||
printf("# Set the correct path for the %s file\n", lev_name(i));
|
||||
fout("# Set the correct path for the %s file\n", lev_name(i));
|
||||
if (state.parity[i].uuid[0])
|
||||
printf("# The file was in the disk with id '%s'\n", state.parity[i].uuid);
|
||||
printf("%s ENTER_HERE_THE_PARITY_FILE\n", lev_config_name(i));
|
||||
printf("\n");
|
||||
fout("# The file was in the disk with id '%s'\n", state.parity[i].uuid);
|
||||
fout("%s ENTER_HERE_THE_PARITY_FILE\n", lev_config_name(i));
|
||||
fout("\n");
|
||||
}
|
||||
printf("# Add any other content file\n");
|
||||
printf("content %s\n", path);
|
||||
printf("\n");
|
||||
fout("# Add any other content file\n");
|
||||
fout("content %s\n", path);
|
||||
fout("\n");
|
||||
for (j = state.maplist; j; j = j->next) {
|
||||
struct snapraid_map* map = j->data;
|
||||
struct snapraid_disk* disk;
|
||||
printf("# Set the correct dir for disk '%s'\n", map->name);
|
||||
fout("# Set the correct dir for disk '%s'\n", map->name);
|
||||
if (map->uuid[0])
|
||||
printf("# Disk '%s' is the one with id '%s'\n", map->name, map->uuid);
|
||||
fout("# Disk '%s' is the one with id '%s'\n", map->name, map->uuid);
|
||||
disk = find_disk(&state, map->name);
|
||||
if (disk && disk->filelist) {
|
||||
struct snapraid_file* file = disk->filelist->data;
|
||||
if (file) {
|
||||
printf("# and containing: %s\n", file->sub);
|
||||
fout("# and containing: %s\n", file->sub);
|
||||
}
|
||||
}
|
||||
printf("disk %s ENTER_HERE_THE_DIR\n", map->name);
|
||||
printf("\n");
|
||||
fout("disk %s ENTER_HERE_THE_DIR\n", map->name);
|
||||
fout("\n");
|
||||
}
|
||||
|
||||
state_done(&state);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,13 @@ void fout(const char* format, ...)
|
|||
va_start(ap, format);
|
||||
vfprintf(stdout, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (stdlog) {
|
||||
va_start(ap, format);
|
||||
fprintf(stdlog, "stdout: ");
|
||||
vfprintf(stdlog, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
void ferr(const char* format, ...)
|
||||
|
|
@ -41,7 +48,7 @@ void ferr(const char* format, ...)
|
|||
|
||||
if (stdlog) {
|
||||
va_start(ap, format);
|
||||
fprintf(stdlog, "msg: ");
|
||||
fprintf(stdlog, "stderr: ");
|
||||
vfprintf(stdlog, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
|
@ -53,7 +60,7 @@ void flog(const char* format, ...)
|
|||
|
||||
if (stdlog) {
|
||||
va_start(ap, format);
|
||||
fprintf(stdlog, "msg: ");
|
||||
fprintf(stdlog, "stdlog: ");
|
||||
vfprintf(stdlog, format, ap);
|
||||
va_start(ap, format);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -22,27 +22,30 @@
|
|||
/* log */
|
||||
|
||||
/**
|
||||
* Output message targgeted for the screen.
|
||||
* Output messages targgeted for the screen.
|
||||
*
|
||||
* Messages are in human readable format.
|
||||
* They must include the full line output and terminate with '\n'.
|
||||
*
|
||||
* These messages go in stdout.
|
||||
*/
|
||||
void fout(const char* format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
/**
|
||||
* Error message printed before an early termination.
|
||||
* Error messages printed before an early termination.
|
||||
*
|
||||
* Messages are in human readable format.
|
||||
* They must include the full line output and terminate with '\n'.
|
||||
*
|
||||
* 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.
|
||||
* Log messages printed after an error.
|
||||
*
|
||||
* Messages are in human readable format.
|
||||
* They must include the full line output and terminate with '\n'.
|
||||
*
|
||||
* These messages go in the log file if specified, otherwise in stderr.
|
||||
*/
|
||||
|
|
@ -54,7 +57,7 @@ void flog(const char* format, ...) __attribute__((format(printf, 1, 2)));
|
|||
void fflush_log(void);
|
||||
|
||||
/**
|
||||
* Tag message.
|
||||
* Tag messages.
|
||||
*
|
||||
* Messages are in tag format, like "tag:entry:...".
|
||||
*
|
||||
|
|
|
|||
|
|
@ -310,14 +310,14 @@ end:
|
|||
state_progress_end(state, countpos, countmax, countsize);
|
||||
|
||||
if (error || io_error) {
|
||||
printf("\n");
|
||||
printf("%8u file errors\n", error);
|
||||
printf("%8u io errors\n", io_error);
|
||||
printf("WARNING! There are errors!\n");
|
||||
fout("\n");
|
||||
fout("%8u file errors\n", error);
|
||||
fout("%8u io errors\n", io_error);
|
||||
fout("WARNING! There are errors!\n");
|
||||
} else {
|
||||
/* print the result only if processed something */
|
||||
if (countpos != 0)
|
||||
printf("Everything OK\n");
|
||||
fout("Everything OK\n");
|
||||
}
|
||||
|
||||
ftag("hash_summary:error_file:%u\n", error);
|
||||
|
|
@ -1074,7 +1074,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
|
||||
state_progress_stop(state);
|
||||
|
||||
printf("Autosaving...\n");
|
||||
fout("Autosaving...\n");
|
||||
|
||||
/* before writing the new content file we ensure that */
|
||||
/* the parity is really written flushing the disk cache */
|
||||
|
|
@ -1133,15 +1133,15 @@ end:
|
|||
}
|
||||
|
||||
if (error || silent_error || io_error) {
|
||||
printf("\n");
|
||||
printf("%8u file errors\n", error);
|
||||
printf("%8u io errors\n", io_error);
|
||||
printf("%8u data errors\n", silent_error);
|
||||
printf("WARNING! There are errors!\n");
|
||||
fout("\n");
|
||||
fout("%8u file errors\n", error);
|
||||
fout("%8u io errors\n", io_error);
|
||||
fout("%8u data errors\n", silent_error);
|
||||
fout("WARNING! There are errors!\n");
|
||||
} else {
|
||||
/* print the result only if processed something */
|
||||
if (countpos != 0)
|
||||
printf("Everything OK\n");
|
||||
fout("Everything OK\n");
|
||||
}
|
||||
|
||||
ftag("summary:error_file:%u\n", error);
|
||||
|
|
@ -1201,7 +1201,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
unsigned l;
|
||||
int skip_sync = 0;
|
||||
|
||||
printf("Initializing...\n");
|
||||
fout("Initializing...\n");
|
||||
|
||||
blockmax = parity_allocated_size(state);
|
||||
size = blockmax * (data_off_t)state->block_size;
|
||||
|
|
@ -1291,7 +1291,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
unrecoverable_error = 0;
|
||||
|
||||
if (state->opt.prehash) {
|
||||
printf("Hashing...\n");
|
||||
fout("Hashing...\n");
|
||||
|
||||
ret = state_hash_process(state, blockstart, blockmax, &skip_sync);
|
||||
if (ret == -1) {
|
||||
|
|
@ -1306,7 +1306,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
}
|
||||
|
||||
if (!skip_sync) {
|
||||
printf("Syncing...\n");
|
||||
fout("Syncing...\n");
|
||||
|
||||
/* skip degenerated cases of empty parity, or skipping all */
|
||||
if (blockstart < blockmax) {
|
||||
|
|
@ -1318,7 +1318,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
} else {
|
||||
printf("Nothing to do\n");
|
||||
fout("Nothing to do\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ static void* thread_spinup(void* arg)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
printf("Spunup device '%s' for disk '%s' in %" PRIu64 " ms.\n", devinfo->file, devinfo->name, tick_ms() - start);
|
||||
fout("Spunup device '%s' for disk '%s' in %" PRIu64 " ms.\n", devinfo->file, devinfo->name, tick_ms() - start);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -793,7 +793,7 @@ static void* thread_spindown(void* arg)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
printf("Spundown device '%s' for disk '%s' in %" PRIu64 " ms.\n", devinfo->file, devinfo->name, tick_ms() - start);
|
||||
fout("Spundown device '%s' for disk '%s' in %" PRIu64 " ms.\n", devinfo->file, devinfo->name, tick_ms() - start);
|
||||
|
||||
return 0;
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue