From a64e24d50330766c19f1ebcb3d53c2e42028b593 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 26 Nov 2013 18:43:12 +0100 Subject: [PATCH] Fixes the gen-conf command. --- HISTORY | 4 ++++ Makefile.am | 2 ++ state.c | 24 ++++++++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/HISTORY b/HISTORY index 27a0d011..92e660d2 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,10 @@ SnapRAID HISTORY ================ +5.1 2013/12 (BETA) +================== + * Fixed the -C, --gen-conf command. + 5.0 2013/11 =========== * Added support for up to six levels of parity. diff --git a/Makefile.am b/Makefile.am index fd5b2583..93d55fff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -151,6 +151,8 @@ endif $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) check $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -a check + echo --- Check the --gen-conf command + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --gen-conf test/content echo --- Delete some files and sync rm test/disk4/9* rm test/disk5/9* diff --git a/state.c b/state.c index 3c28b116..77ac3010 100644 --- a/state.c +++ b/state.c @@ -855,6 +855,10 @@ static void state_map(struct snapraid_state* state) exit(EXIT_FAILURE); } + /* without configuration don't check for number of data disks */ + if (state->no_conf) + return; + /* count the number of data disks, including holes left after removing some */ diskcount = 0; for(i=state->maplist;i!=0;i=i->next) { @@ -1643,6 +1647,11 @@ static void state_read_text(struct snapraid_state* state, const char* path, STRE exit(EXIT_FAILURE); } + /* without configuration, auto assign the block size */ + if (state->no_conf) { + state->block_size = blksize; + } + if (blksize != state->block_size) { fprintf(stderr, "Mismatching 'blksize' and 'block_size' specification in '%s' at line %u\n", path, line); fprintf(stderr, "Please restore the 'block_size' value in the configuration file to '%u'\n", blksize / 1024); @@ -2709,6 +2718,11 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST exit(EXIT_FAILURE); } + /* without configuration, auto assign the block size */ + if (state->no_conf) { + state->block_size = blksize; + } + if (blksize != state->block_size) { decoding_error(path, f); fprintf(stderr, "Mismatching 'blksize' and 'block_size' specification!\n"); @@ -3222,8 +3236,10 @@ void state_read(struct snapraid_state* state) struct snapraid_content* content = node->data; pathcpy(path, sizeof(path), content->content); - fprintf(stdlog, "content:%s\n", path); - fflush(stdlog); + if (!state->no_conf) { + fprintf(stdlog, "content:%s\n", path); + fflush(stdlog); + } printf("Loading state from %s...\n", path); f = sopen_read(path); @@ -3252,10 +3268,10 @@ void state_read(struct snapraid_state* state) /* if not found, assume empty */ if (!f) { + fprintf(stderr, "No content file found. Assuming empty.\n"); + /* create the initial mapping */ state_map(state); - - fprintf(stderr, "No content file found. Assuming empty.\n"); return; }