From 1b0a38f924a6f221e2ac6a4c6d862a891dd44ae0 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 22 Jun 2013 18:26:21 +0200 Subject: [PATCH] Moves the seed info in the checksum line. --- snapraid.1 | 5 +++-- snapraid.d | 5 +++-- snapraid.txt | 22 +++++++++++++++------- state.c | 30 ++++++++++++++---------------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/snapraid.1 b/snapraid.1 index 833db42e..c47c5b22 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -1007,8 +1007,9 @@ This file is read and written by the \(a"sync\(a" command, and only read by .SS blk_size SIZE Defines the size of the block in bytes. It must match the size defined in the configuration file. -.SS checksum CHECKSUM -Defines the checksum kind used. It can be only \(a"murmur3\(a". +.SS checksum CHECKSUM SEED +Defines the checksum kind used. It can be \(a"murmur3\(a" or \(a"spooky2\(a". +SEED is a 128 bits seed used in all the hash operations. From SnapRAID 2.0 the old \(a"md5\(a" checksum is not supported anymore. .SS map NAME INDEX [UUID] Defines the position INDEX of the disk NAME in the parity computation. diff --git a/snapraid.d b/snapraid.d index f4fa6a31..184cb493 100644 --- a/snapraid.d +++ b/snapraid.d @@ -724,8 +724,9 @@ Content Defines the size of the block in bytes. It must match the size defined in the configuration file. - checksum CHECKSUM - Defines the checksum kind used. It can be only "murmur3". + checksum CHECKSUM SEED + Defines the checksum kind used. It can be "murmur3" or "spooky2". + SEED is a 128 bits seed used in all the hash operations. From SnapRAID 2.0 the old "md5" checksum is not supported anymore. map NAME INDEX [UUID] diff --git a/snapraid.txt b/snapraid.txt index 06ab7e60..b7f6dcf3 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -797,10 +797,11 @@ This file is read and written by the "sync" command, and only read by Defines the size of the block in bytes. It must match the size defined in the configuration file. -10.2 checksum CHECKSUM ----------------------- +10.2 checksum CHECKSUM SEED +--------------------------- -Defines the checksum kind used. It can be only "murmur3". +Defines the checksum kind used. It can be "murmur3" or "spooky2". +SEED is a 128 bits seed used in all the hash operations. From SnapRAID 2.0 the old "md5" checksum is not supported anymore. 10.3 map NAME INDEX [UUID] @@ -884,22 +885,29 @@ for which the parity is computed using the previous value. This field is used only when you interrupt manually the "sync" command. -10.11 symlink DISK PATH +10.11 inf BLOCK TIME +-------------------- + +Information shared by all the block at the specified offset. +TIME is the last time of the hash/parity verification done at this +block. + +10.12 symlink DISK PATH ----------------------- Defines a symbolic link in the specified DISK. -10.12 hardlink DISK PATH +10.13 hardlink DISK PATH ------------------------ Defines a hard link in the specified DISK. -10.13 to PATH +10.14 to PATH ------------- Defines where the previous symlink or hardlink links to. -10.14 dir DISK PATH +10.15 dir DISK PATH ------------------- Defines an empty directory in the specified DISK. diff --git a/state.c b/state.c index 3a8eb0d8..34b1004c 100644 --- a/state.c +++ b/state.c @@ -894,7 +894,7 @@ void state_read(struct snapraid_state* state) /* it's for compatibility with version 1.0 where MD5 was implicit. */ state->hash = HASH_UNDEFINED; - /* start with a zero seed */ + /* start with a zero seed, it was the default in old versions */ memset(state->hashseed, 0, HASH_SIZE); disk = 0; @@ -1494,15 +1494,20 @@ void state_read(struct snapraid_state* state) fprintf(stderr, "Invalid 'checksum' specification '%s' in '%s' at line %u\n", buffer, path, line); exit(EXIT_FAILURE); } - } else if (strcmp(tag, "seed") == 0) { - hash = oathash8(hash, 'e'); - ret = sgethex(f, state->hashseed, HASH_SIZE); - if (ret < 0) { - fprintf(stderr, "Invalid 'seed' specification in '%s' at line %u\n", path, line); - exit(EXIT_FAILURE); + c = sgetc(f); + if (c == ' ') { + /* read the seed if present */ + ret = sgethex(f, state->hashseed, HASH_SIZE); + if (ret < 0) { + fprintf(stderr, "Invalid 'seed' specification in '%s' at line %u\n", path, line); + exit(EXIT_FAILURE); + } + hash = oathashm(hash, state->hashseed, HASH_SIZE); + } else { + sungetc(c, f); + memset(state->hashseed, 0, HASH_SIZE); } - hash = oathashm(hash, state->hashseed, HASH_SIZE); } else if (strcmp(tag, "blksize") == 0) { block_off_t blksize; @@ -1728,14 +1733,7 @@ void state_write(struct snapraid_state* state) fprintf(stderr, "Unexpected hash when writing the content file '%s'.\n", serrorfile(f)); exit(EXIT_FAILURE); } - sputeol(f); - if (serror(f)) { - fprintf(stderr, "Error writing the content file '%s'. %s.\n", serrorfile(f), strerror(errno)); - exit(EXIT_FAILURE); - } - - sputsl("seed ", f); - hash = oathash8(hash, 'e'); + sputc(' ', f); sputhex(state->hashseed, HASH_SIZE, f); hash = oathashm(hash, state->hashseed, HASH_SIZE); sputeol(f);