Opens filtered out files in read-only mode.

This commit is contained in:
Andrea Mazzoleni 2013-03-01 00:12:57 +01:00
parent 4c058d25e2
commit e0acbda4bd
2 changed files with 14 additions and 4 deletions

16
check.c
View file

@ -602,7 +602,8 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
}
}
if (fix) {
/* if fixing, and the file is not excluded, we must open for writing */
if (fix && !file_flag_has(block_file_get(block), FILE_IS_EXCLUDED)) {
/* if fixing, create the file, open for writing and resize if required */
ret = handle_create(&handle[j], block_file_get(block));
if (ret == -1) {
@ -627,7 +628,7 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
++recovered_error;
}
} else {
/* if checking or hashing, open the file for reading */
/* if checking or hashing, open the file only for reading */
ret = handle_open(&handle[j], block_file_get(block));
if (ret == -1) {
/* save the failed block for the check/fix */
@ -914,6 +915,17 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
continue;
}
/* if the file is excluded, we have nothing to fix */
/* note that this check is required, because if the file is excluded */
/* it's also possible to have it not opened, */
/* and have the handle[j].file pointing to NULL. */
/* A typical case is if the file is missing, */
/* and the read-only open failed before. */
if (file_flag_has(block_file_get(block), FILE_IS_EXCLUDED)) {
/* nothing to do */
continue;
}
/* if it isn't the last block in the file */
if (!block_is_last(block)) {
/* nothing to do */