Even better error management. More precise and explicative.

This commit is contained in:
Andrea Mazzoleni 2011-03-19 22:00:08 +01:00
parent 37c68721a1
commit e80009334b
7 changed files with 108 additions and 37 deletions

View file

@ -83,6 +83,7 @@ int main(int argc, char* argv[])
struct snapraid_state state;
int operation;
block_off_t blockstart;
int ret;
/* intercept Ctrl+C */
signal(SIGINT, &signal_handler);
@ -158,10 +159,16 @@ int main(int argc, char* argv[])
state_scan(&state);
state_sync(&state, blockstart);
ret = state_sync(&state, blockstart);
state_write(&state);
} else if (operation == OPERATION_CHECK || operation == OPERATION_FIX) {
/* save the new state if required */
if (state.need_write)
state_write(&state);
/* abort if required by the sync command */
if (ret == -1)
exit(EXIT_FAILURE);
} else {
state_read(&state);
state_check(&state, operation == OPERATION_FIX, blockstart);