mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Changes the meaning of the -G, --gui option to now remove only
the interactive output. All the other log options are not enabled by default.
This commit is contained in:
parent
7014486bb7
commit
70244133f4
13 changed files with 153 additions and 228 deletions
2
HISTORY
2
HISTORY
|
|
@ -16,6 +16,8 @@ SnapRAID HISTORY
|
|||
performance in scanning.
|
||||
* Removed the detailed list of errors from the screen output.
|
||||
To get it you must explicitely uses the -l, --log option.
|
||||
It's now too detailed for the screen, because it now contains a lot
|
||||
of more info.
|
||||
* For files with changes only in some blocks, updates the parity
|
||||
only for blocks that really are changed.
|
||||
* Reduced memory usage avoiding to allocate unnecessary memory.
|
||||
|
|
|
|||
97
check.c
97
check.c
|
|
@ -1113,9 +1113,8 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
|
|||
goto bail;
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:unrecoverable:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:unrecoverable:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Unrecoverable '%s'\n", path);
|
||||
}
|
||||
|
||||
|
|
@ -1129,9 +1128,8 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
|
|||
goto close_and_continue;
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Recovered '%s'\n", path);
|
||||
}
|
||||
|
||||
|
|
@ -1172,28 +1170,24 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
|
|||
/* print just the final status */
|
||||
if (file_flag_has(file, FILE_IS_DAMAGED)) {
|
||||
if (!check) {
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:damaged:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:damaged:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Damaged '%s'\n", path);
|
||||
}
|
||||
} else {
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:unrecoverable:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:unrecoverable:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Unrecoverable '%s'\n", path);
|
||||
}
|
||||
}
|
||||
} else if (file_flag_has(file, FILE_IS_FIXED)) {
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:recoverable:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:recoverable:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Recoverable '%s'\n", path);
|
||||
}
|
||||
} else {
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:correct:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:correct:%s:%s\n", handle[j].disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Correct '%s'\n", path);
|
||||
}
|
||||
}
|
||||
|
|
@ -1322,9 +1316,8 @@ close_and_continue:
|
|||
fprintf(stdlog, "fixed:%s:%s: Fixed empty file\n", disk->name, file->sub);
|
||||
++recovered_error;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", disk->name, file->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", disk->name, file->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Recovered '%s%s'\n", disk->dir, file->sub);
|
||||
}
|
||||
}
|
||||
|
|
@ -1488,9 +1481,8 @@ close_and_continue:
|
|||
++recovered_error;
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", disk->name, link->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:recovered:%s:%s\n", disk->name, link->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Recovered '%s%s'\n", disk->dir, link->sub);
|
||||
}
|
||||
}
|
||||
|
|
@ -1557,9 +1549,8 @@ close_and_continue:
|
|||
fprintf(stdlog, "dir_fixed:%s:%s: Fixed dir error\n", disk->name, dir->sub);
|
||||
++recovered_error;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "status:ok:%s:%s\n", disk->name, dir->sub);
|
||||
} else if (state->opt.verbose) {
|
||||
fprintf(stdlog, "status:ok:%s:%s\n", disk->name, dir->sub);
|
||||
if (state->opt.verbose) {
|
||||
printf("Recovered '%s%s'\n", disk->dir, dir->sub);
|
||||
}
|
||||
}
|
||||
|
|
@ -1650,34 +1641,32 @@ bail:
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:error:%u\n", error);
|
||||
if (fix)
|
||||
fprintf(stdlog, "summary:error_recovered:%u\n", recovered_error);
|
||||
if (check)
|
||||
fprintf(stdlog, "summary:error_unrecoverable:%u\n", unrecoverable_error);
|
||||
if (fix) {
|
||||
if (error + recovered_error + unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else if (unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:recovered\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:unrecoverable\n");
|
||||
} else if (check) {
|
||||
if (error + unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else if (unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:recoverable\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:unrecoverable\n");
|
||||
} else { /* audit only */
|
||||
if (error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
fprintf(stdlog, "summary:error:%u\n", error);
|
||||
if (fix)
|
||||
fprintf(stdlog, "summary:error_recovered:%u\n", recovered_error);
|
||||
if (check)
|
||||
fprintf(stdlog, "summary:error_unrecoverable:%u\n", unrecoverable_error);
|
||||
if (fix) {
|
||||
if (error + recovered_error + unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else if (unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:recovered\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:unrecoverable\n");
|
||||
} else if (check) {
|
||||
if (error + unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else if (unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:recoverable\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:unrecoverable\n");
|
||||
} else { /* audit only */
|
||||
if (error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
|
||||
free(failed);
|
||||
free(failed_map);
|
||||
|
|
|
|||
25
dup.c
25
dup.c
|
|
@ -123,12 +123,9 @@ void state_dup(struct snapraid_state* state)
|
|||
if (dup) {
|
||||
++count;
|
||||
size += dup->file->size;
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "dup:%s:%s:%s:%s:%"PRIu64": dup\n", disk->name, file->sub, dup->disk->name, dup->file->sub, dup->file->size);
|
||||
} else {
|
||||
printf("%"PRIu64" '%s%s'\n", file->size / (1024*1024), disk->dir, file->sub);
|
||||
printf("dup '%s%s'\n", dup->disk->dir, dup->file->sub);
|
||||
}
|
||||
fprintf(stdlog, "dup:%s:%s:%s:%s:%"PRIu64": dup\n", disk->name, file->sub, dup->disk->name, dup->file->sub, dup->file->size);
|
||||
printf("%"PRIu64" '%s%s'\n", file->size / (1024*1024), disk->dir, file->sub);
|
||||
printf("dup '%s%s'\n", dup->disk->dir, dup->file->sub);
|
||||
hash_free(hash);
|
||||
} else {
|
||||
tommy_hashdyn_insert(&hashset, &hash->nodeset, hash, hash32);
|
||||
|
|
@ -145,15 +142,13 @@ void state_dup(struct snapraid_state* state)
|
|||
else
|
||||
printf("No duplicate\n");
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:dup_count:%u\n", count);
|
||||
fprintf(stdlog, "summary:dup_size:%"PRIu64"\n", size);
|
||||
if (count == 0) {
|
||||
fprintf(stdlog, "summary:exit:unique\n");
|
||||
} else {
|
||||
fprintf(stdlog, "summary:exit:dup\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
fprintf(stdlog, "summary:dup_count:%u\n", count);
|
||||
fprintf(stdlog, "summary:dup_size:%"PRIu64"\n", size);
|
||||
if (count == 0) {
|
||||
fprintf(stdlog, "summary:exit:unique\n");
|
||||
} else {
|
||||
fprintf(stdlog, "summary:exit:dup\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
|
|
|
|||
6
parity.c
6
parity.c
|
|
@ -75,10 +75,8 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
|
|||
|
||||
if (file->blockmax > 0) {
|
||||
if (file->blockvec[0].parity_pos >= blockalloc) {
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "outofparity:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "outofparity:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stdlog);
|
||||
if (first) {
|
||||
first = 0;
|
||||
printf("Files outside the parity:\n");
|
||||
|
|
|
|||
14
pool.c
14
pool.c
|
|
@ -204,11 +204,13 @@ void state_pool(struct snapraid_state* state)
|
|||
/* we ignore empty dirs in disk->dir */
|
||||
}
|
||||
|
||||
if (!state->opt.gui) {
|
||||
if (count)
|
||||
printf("%u links created\n", count);
|
||||
else
|
||||
printf("No link created\n");
|
||||
}
|
||||
if (count)
|
||||
printf("%u links created\n", count);
|
||||
else
|
||||
printf("No link created\n");
|
||||
|
||||
fprintf(stdlog, "summary:link::%u\n", count);
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
|
|
|
|||
82
scan.c
82
scan.c
|
|
@ -95,7 +95,6 @@ static void scan_link(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, link->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
} else {
|
||||
/* it's an update */
|
||||
|
|
@ -105,10 +104,7 @@ static void scan_link(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
|
||||
++scan->count_change;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:update:%s:%s\n", disk->name, link->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:update:%s:%s\n", disk->name, link->sub);
|
||||
if (output) {
|
||||
printf("Update '%s%s'\n", disk->dir, link->sub);
|
||||
}
|
||||
|
|
@ -125,10 +121,7 @@ static void scan_link(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
/* create the new link */
|
||||
++scan->count_insert;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:add:%s:%s\n", disk->name, sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:add:%s:%s\n", disk->name, sub);
|
||||
if (output) {
|
||||
printf("Add '%s%s'\n", disk->dir, sub);
|
||||
}
|
||||
|
|
@ -365,10 +358,7 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
/* if the path is different, it means a moved file with the same inode */
|
||||
++scan->count_move;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:move:%s:%s:%s\n", disk->name, file->sub, sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:move:%s:%s:%s\n", disk->name, file->sub, sub);
|
||||
if (output) {
|
||||
printf("Move '%s%s' '%s%s'\n", disk->dir, file->sub, disk->dir, sub);
|
||||
}
|
||||
|
|
@ -390,7 +380,6 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -490,10 +479,7 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
/* like when restoring a backup that restores also the timestamp */
|
||||
++scan->count_restore;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:restore:%s:%s\n", disk->name, sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:restore:%s:%s\n", disk->name, sub);
|
||||
if (output) {
|
||||
printf("Restore '%s%s'\n", disk->dir, sub);
|
||||
}
|
||||
|
|
@ -517,7 +503,6 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -542,10 +527,7 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
/* it has the same name, so it's an update */
|
||||
++scan->count_change;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:update:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:update:%s:%s\n", disk->name, file->sub);
|
||||
if (output) {
|
||||
if (file->size != st->st_size)
|
||||
printf("Update '%s%s' new size\n", disk->dir, file->sub);
|
||||
|
|
@ -561,10 +543,7 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state,
|
|||
/* if the name doesn't exist, it's a new file */
|
||||
++scan->count_insert;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:add:%s:%s\n", disk->name, sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:add:%s:%s\n", disk->name, sub);
|
||||
if (output) {
|
||||
printf("Add '%s%s'\n", disk->dir, sub);
|
||||
}
|
||||
|
|
@ -639,7 +618,6 @@ static void scan_emptydir(struct snapraid_scan* scan, struct snapraid_state* sta
|
|||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, dir->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
/* nothing more to do */
|
||||
|
|
@ -648,10 +626,7 @@ static void scan_emptydir(struct snapraid_scan* scan, struct snapraid_state* sta
|
|||
/* create the new dir */
|
||||
++scan->count_insert;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:add:%s:%s\n", disk->name, sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:add:%s:%s\n", disk->name, sub);
|
||||
if (output) {
|
||||
printf("Add '%s%s'\n", disk->dir, sub);
|
||||
}
|
||||
|
|
@ -1060,10 +1035,7 @@ void state_scan(struct snapraid_state* state, int output)
|
|||
if (!file_flag_has(file, FILE_IS_PRESENT)) {
|
||||
++scan->count_remove;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:remove:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:remove:%s:%s\n", disk->name, file->sub);
|
||||
if (output) {
|
||||
printf("Remove '%s%s'\n", disk->dir, file->sub);
|
||||
}
|
||||
|
|
@ -1084,10 +1056,7 @@ void state_scan(struct snapraid_state* state, int output)
|
|||
if (!link_flag_has(link, FILE_IS_PRESENT)) {
|
||||
++scan->count_remove;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:remove:%s:%s\n", disk->name, link->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:remove:%s:%s\n", disk->name, link->sub);
|
||||
if (output) {
|
||||
printf("Remove '%s%s'\n", disk->dir, link->sub);
|
||||
}
|
||||
|
|
@ -1108,10 +1077,7 @@ void state_scan(struct snapraid_state* state, int output)
|
|||
if (!dir_flag_has(dir, FILE_IS_PRESENT)) {
|
||||
++scan->count_remove;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "scan:remove:%s:%s\n", disk->name, dir->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "scan:remove:%s:%s\n", disk->name, dir->sub);
|
||||
if (output) {
|
||||
printf("Remove '%s%s'\n", disk->dir, dir->sub);
|
||||
}
|
||||
|
|
@ -1290,15 +1256,12 @@ void state_scan(struct snapraid_state* state, int output)
|
|||
printf("\tadded %d\n", total.count_insert);
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:equal:%u\n", total.count_equal);
|
||||
fprintf(stdlog, "summary:moved:%u\n", total.count_move);
|
||||
fprintf(stdlog, "summary:restored:%u\n", total.count_restore);
|
||||
fprintf(stdlog, "summary:changed:%u\n", total.count_change);
|
||||
fprintf(stdlog, "summary:removed:%u\n", total.count_remove);
|
||||
fprintf(stdlog, "summary:added:%u\n", total.count_insert);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "summary:equal:%u\n", total.count_equal);
|
||||
fprintf(stdlog, "summary:moved:%u\n", total.count_move);
|
||||
fprintf(stdlog, "summary:restored:%u\n", total.count_restore);
|
||||
fprintf(stdlog, "summary:changed:%u\n", total.count_change);
|
||||
fprintf(stdlog, "summary:removed:%u\n", total.count_remove);
|
||||
fprintf(stdlog, "summary:added:%u\n", total.count_insert);
|
||||
|
||||
no_difference = !total.count_move && !total.count_restore && !total.count_change && !total.count_remove && !total.count_insert;
|
||||
|
||||
|
|
@ -1310,15 +1273,12 @@ void state_scan(struct snapraid_state* state, int output)
|
|||
}
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
if (no_difference) {
|
||||
fprintf(stdlog, "summary:exit:equal\n");
|
||||
fflush(stdlog);
|
||||
} else {
|
||||
fprintf(stdlog, "summary:exit:diff\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
if (no_difference) {
|
||||
fprintf(stdlog, "summary:exit:equal\n");
|
||||
} else {
|
||||
fprintf(stdlog, "summary:exit:diff\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
tommy_list_foreach(&scanlist, (tommy_foreach_func*)free);
|
||||
|
|
|
|||
16
scrub.c
16
scrub.c
|
|
@ -393,15 +393,13 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:error_read:%u\n", error);
|
||||
fprintf(stdlog, "summary:error_data:%u\n", silent_error);
|
||||
if (error + silent_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "summary:error_read:%u\n", error);
|
||||
fprintf(stdlog, "summary:error_data:%u\n", silent_error);
|
||||
if (error + silent_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
fflush(stdlog);
|
||||
|
||||
bail:
|
||||
for(j=0;j<diskmax;++j) {
|
||||
|
|
|
|||
10
selftest.c
10
selftest.c
|
|
@ -482,13 +482,11 @@ static void crc32ctest(void)
|
|||
}
|
||||
}
|
||||
|
||||
void selftest(int gui)
|
||||
void selftest()
|
||||
{
|
||||
if (gui) {
|
||||
fprintf(stdlog, "selftest:\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
fprintf(stdlog, "selftest:\n");
|
||||
fflush(stdlog);
|
||||
|
||||
printf("Self test...\n");
|
||||
|
||||
/* large file check */
|
||||
|
|
|
|||
23
snapraid.c
23
snapraid.c
|
|
@ -79,13 +79,10 @@ void usage(void)
|
|||
printf(" " SWITCH_GETOPT_LONG("-V, --version ", "-V") " Version\n");
|
||||
}
|
||||
|
||||
void memory(int gui)
|
||||
void memory(void)
|
||||
{
|
||||
if (gui) {
|
||||
fprintf(stdlog, "memory:used:%"PRIu64"\n", (uint64_t)malloc_counter());
|
||||
} else {
|
||||
printf("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024));
|
||||
}
|
||||
fprintf(stdlog, "memory:used:%"PRIu64"\n", (uint64_t)malloc_counter());
|
||||
printf("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024));
|
||||
}
|
||||
|
||||
#define OPT_TEST_SKIP_SELF 256
|
||||
|
|
@ -549,7 +546,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
if (!opt.skip_self)
|
||||
selftest(opt.gui);
|
||||
selftest();
|
||||
|
||||
state_init(&state);
|
||||
|
||||
|
|
@ -592,7 +589,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
state_scan(&state, 0);
|
||||
|
||||
memory(state.opt.gui);
|
||||
memory();
|
||||
|
||||
/* intercept Ctrl+C */
|
||||
signal(SIGINT, &signal_handler);
|
||||
|
|
@ -639,7 +636,7 @@ int main(int argc, char* argv[])
|
|||
/* apply the command line filter */
|
||||
state_filter(&state, &filterlist_file, &filterlist_disk, filter_missing, filter_error);
|
||||
|
||||
memory(state.opt.gui);
|
||||
memory();
|
||||
|
||||
/* intercept Ctrl+C */
|
||||
signal(SIGINT, &signal_handler);
|
||||
|
|
@ -659,7 +656,7 @@ int main(int argc, char* argv[])
|
|||
} else if (operation == OPERATION_SCRUB) {
|
||||
state_read(&state);
|
||||
|
||||
memory(state.opt.gui);
|
||||
memory();
|
||||
|
||||
/* intercept Ctrl+C */
|
||||
signal(SIGINT, &signal_handler);
|
||||
|
|
@ -678,11 +675,11 @@ int main(int argc, char* argv[])
|
|||
|
||||
state_write(&state);
|
||||
|
||||
memory(state.opt.gui);
|
||||
memory();
|
||||
} else if (operation == OPERATION_STATUS) {
|
||||
state_read(&state);
|
||||
|
||||
memory(state.opt.gui);
|
||||
memory();
|
||||
|
||||
state_status(&state);
|
||||
} else if (operation == OPERATION_DUP) {
|
||||
|
|
@ -702,7 +699,7 @@ int main(int argc, char* argv[])
|
|||
/* apply the command line filter */
|
||||
state_filter(&state, &filterlist_file, &filterlist_disk, filter_missing, filter_error);
|
||||
|
||||
memory(state.opt.gui);
|
||||
memory();
|
||||
|
||||
/* intercept Ctrl+C */
|
||||
signal(SIGINT, &signal_handler);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
/* snapraid */
|
||||
|
||||
void speed(void);
|
||||
void selftest(int gui);
|
||||
void selftest(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
56
state.c
56
state.c
|
|
@ -270,6 +270,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
STREAM* f;
|
||||
unsigned line;
|
||||
tommy_node* i;
|
||||
unsigned l;
|
||||
|
||||
/* copy the options */
|
||||
state->opt = *opt;
|
||||
|
|
@ -280,11 +281,9 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
|
||||
state->command = command;
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "version:%s\n", PACKAGE_VERSION);
|
||||
fprintf(stdlog, "conf:%s\n", path);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "version:%s\n", PACKAGE_VERSION);
|
||||
fprintf(stdlog, "conf:%s\n", path);
|
||||
fflush(stdlog);
|
||||
|
||||
f = sopen_read(path);
|
||||
if (!f) {
|
||||
|
|
@ -643,30 +642,25 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
|
||||
/* intentionally not set the prevhashseed, if used valgrind will warn about it */
|
||||
|
||||
if (state->opt.gui) {
|
||||
tommy_node* i;
|
||||
unsigned l;
|
||||
|
||||
fprintf(stdlog, "blocksize:%u\n", state->block_size);
|
||||
for(i=state->disklist;i!=0;i=i->next) {
|
||||
struct snapraid_disk* disk = i->data;
|
||||
fprintf(stdlog, "disk:%s:%s\n", disk->name, disk->dir);
|
||||
}
|
||||
|
||||
switch (state->level) {
|
||||
case 1 : fprintf(stdlog, "mode:raid5\n"); break;
|
||||
case 2 : fprintf(stdlog, "mode:raid6\n"); break;
|
||||
case 3 : fprintf(stdlog, "mode:raidTP\n"); break;
|
||||
case 4 : fprintf(stdlog, "mode:raidQP\n"); break;
|
||||
}
|
||||
|
||||
for(l=0;l<state->level;++l) {
|
||||
fprintf(stdlog, "%s:%s\n", lev_config_name(l), state->parity_path[l]);
|
||||
}
|
||||
if (state->pool[0] != 0)
|
||||
fprintf(stdlog, "pool:%s\n", state->pool);
|
||||
fflush(stdlog);
|
||||
fprintf(stdlog, "blocksize:%u\n", state->block_size);
|
||||
for(i=state->disklist;i!=0;i=i->next) {
|
||||
struct snapraid_disk* disk = i->data;
|
||||
fprintf(stdlog, "disk:%s:%s\n", disk->name, disk->dir);
|
||||
}
|
||||
|
||||
switch (state->level) {
|
||||
case 1 : fprintf(stdlog, "mode:raid5\n"); break;
|
||||
case 2 : fprintf(stdlog, "mode:raid6\n"); break;
|
||||
case 3 : fprintf(stdlog, "mode:raidTP\n"); break;
|
||||
case 4 : fprintf(stdlog, "mode:raidQP\n"); break;
|
||||
}
|
||||
|
||||
for(l=0;l<state->level;++l) {
|
||||
fprintf(stdlog, "%s:%s\n", lev_config_name(l), state->parity_path[l]);
|
||||
}
|
||||
if (state->pool[0] != 0)
|
||||
fprintf(stdlog, "pool:%s\n", state->pool);
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -3119,10 +3113,8 @@ void state_read(struct snapraid_state* state)
|
|||
struct snapraid_content* content = node->data;
|
||||
pathcpy(path, sizeof(path), content->content);
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "content:%s\n", path);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "content:%s\n", path);
|
||||
fflush(stdlog);
|
||||
printf("Loading state from %s...\n", path);
|
||||
|
||||
f = sopen_read(path);
|
||||
|
|
|
|||
32
status.c
32
status.c
|
|
@ -178,13 +178,11 @@ int state_status(struct snapraid_state* state)
|
|||
}
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:has_unsynched:%u\n", unsynched_blocks);
|
||||
fprintf(stdlog, "summary:has_rehash:%u\n", rehash);
|
||||
fprintf(stdlog, "summary:has_bad:%u\n", bad);
|
||||
fprintf(stdlog, "time_count:%u\n", count);
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "summary:has_unsynched:%u\n", unsynched_blocks);
|
||||
fprintf(stdlog, "summary:has_rehash:%u\n", rehash);
|
||||
fprintf(stdlog, "summary:has_bad:%u\n", bad);
|
||||
fprintf(stdlog, "time_count:%u\n", count);
|
||||
fflush(stdlog);
|
||||
|
||||
if (!count) {
|
||||
fprintf(stderr, "The array is empty.\n");
|
||||
|
|
@ -195,18 +193,16 @@ int state_status(struct snapraid_state* state)
|
|||
/* sort the info to get the time info */
|
||||
qsort(infomap, count, sizeof(snapraid_info), info_time_compare);
|
||||
|
||||
if (state->opt.gui) {
|
||||
/* info for making the graph */
|
||||
i = 0;
|
||||
while (i < count) {
|
||||
unsigned j = i + 1;
|
||||
while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j]))
|
||||
++j;
|
||||
fprintf(stdlog, "time:%"PRIu64":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
|
||||
i = j;
|
||||
}
|
||||
fflush(stdlog);
|
||||
/* info for making the graph */
|
||||
i = 0;
|
||||
while (i < count) {
|
||||
unsigned j = i + 1;
|
||||
while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j]))
|
||||
++j;
|
||||
fprintf(stdlog, "time:%"PRIu64":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
|
||||
i = j;
|
||||
}
|
||||
fflush(stdlog);
|
||||
|
||||
oldest = info_get_time(infomap[0]);
|
||||
median = info_get_time(infomap[count / 2]);
|
||||
|
|
|
|||
16
sync.c
16
sync.c
|
|
@ -453,15 +453,13 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:error_readwrite:%u\n", error);
|
||||
fprintf(stdlog, "summary:error_data:%u\n", silent_error);
|
||||
if (error + silent_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
fprintf(stdlog, "summary:error_readwrite:%u\n", error);
|
||||
fprintf(stdlog, "summary:error_data:%u\n", silent_error);
|
||||
if (error + silent_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
fflush(stdlog);
|
||||
|
||||
bail:
|
||||
for(j=0;j<diskmax;++j) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue