From 512dec9d68b4ca2e09786f34c406f7a5d2ee882f Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 30 Apr 2011 10:57:53 +0200 Subject: [PATCH] Allow dry to work without Q-Parity file. --- dry.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dry.c b/dry.c index 04263181..70ee15eb 100644 --- a/dry.c +++ b/dry.c @@ -102,10 +102,12 @@ static int state_dry_process(struct snapraid_state* state, int parity_f, int qar /* read the qarity */ if (state->level >= 2) { - ret = parity_read(state->qarity, qarity_f, i, buffer, state->block_size); - if (ret == -1) { - fprintf(stderr, "%u: Syndrome read error\n", i); - ++error; + if (qarity_f != -1) { + ret = parity_read(state->qarity, qarity_f, i, buffer, state->block_size); + if (ret == -1) { + fprintf(stderr, "%u: Q-Parity read error\n", i); + ++error; + } } } @@ -177,19 +179,20 @@ void state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t } pathcpy(parity_path, sizeof(parity_path), state->parity); - /* if drying, open the file for reading */ + pathcpy(qarity_path, sizeof(qarity_path), state->qarity); + + /* open the file for reading */ /* it may fail if the file doesn't exist, in this case we continue to dry the files */ parity_f = parity_open(parity_path); if (parity_f == -1) { - printf("No accessible parity file.\n"); + printf("No accessible Parity file.\n"); /* continue anyway */ } if (state->level >= 2) { - pathcpy(qarity_path, sizeof(qarity_path), state->qarity); qarity_f = parity_open(qarity_path); if (qarity_f == -1) { - printf("No accessible qarity file.\n"); + printf("No accessible Q-Parity file.\n"); /* continue anyway */ } } else {