From 0ba25d53048d1db2ed0738bee3bad48100c12b4a Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 31 Aug 2015 22:01:34 +0200 Subject: [PATCH] Fix an invalid assumption when using the -e option With -e we cannot postprocess files as we don't have any guarantee to fully process them, as the select blocks cover likely only a subset of the file. --- cmdline/check.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmdline/check.c b/cmdline/check.c index 7d35b629..1e14694e 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -588,12 +588,21 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign * Post process all the files at the specified block index ::i. * For each file, if we are at the last block, closes it, * adjust the timestamp, and prints the result. + * + * This works with the assumption to always process the whole files to + * fix. This assumption is not always correct, and in such case we have to + * skip the whole postprocessing. And example, is when fixing only bad blocks. */ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct snapraid_handle* handle, unsigned diskmax) { unsigned j; int ret; + /* if we are processing only bad blocks, we don't have to do any postprocessing */ + /* as we don't have any guarantee to process the last block of the fixed files */ + if (state->opt.badonly) + return 0; + /* for all the files prints the final status, and does the final time fix */ /* we also ensure to close files after processing the last block */ for (j = 0; j < diskmax; ++j) {