checksum_seed

Craig Barratt craig at atheros.com
Mon Feb 16 20:44:50 GMT 2004


jw schultz writes:

> 1.  Yes, you may contribute a patch.  I favor the idea of
> being able to supply a checksum seed.
> 
> 2.  Lets get the option name down to a more reasonable
> length.  --checksum-seed should be sufficient.

I submitted a patch against 2.5.6pre1 last January for --checksum-seed=NUM:

    http://lists.samba.org/archive/rsync/2003-January/004845.html

but in that thread Dave Dykstra correctly pointed out there wasn't
much point in letting the user specify a particular value.

Therefore, I switched to just a flag that forces the fixed value of
32761 (same as batch mode).  I picked the option named --fixed-csumseed,
which is long but hopefully informative.

Here's a patch against CVS using --fixed-csumseed.  I also added it to
the usage and documentation, but it's not clear this option needs to be
exposed to the user.

Craig

diff -bur rsync/options.c rsync-fixedcsum/options.c
--- rsync/options.c	Tue Feb 10 20:30:41 2004
+++ rsync-fixedcsum/options.c	Mon Feb 16 12:32:23 2004
@@ -89,6 +89,7 @@
 int modify_window = 0;
 int blocking_io = -1;
 int checksum_seed = 0;
+int fixed_csumseed = 0;
 unsigned int block_size = 0;
 
 
@@ -288,6 +289,7 @@
   rprintf(F,"     --bwlimit=KBPS          limit I/O bandwidth, KBytes per second\n");
   rprintf(F,"     --write-batch=PREFIX    write batch fileset starting with PREFIX\n");
   rprintf(F,"     --read-batch=PREFIX     read batch fileset starting with PREFIX\n");
+  rprintf(F,"     --fixed-csumseed        use fixed MD4 block/file checksum seed\n");
   rprintf(F," -h, --help                  show this help screen\n");
 #ifdef INET6
   rprintf(F," -4                          prefer IPv4\n");
@@ -303,7 +305,7 @@
 enum {OPT_VERSION = 1000, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
       OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED, OPT_LINK_DEST,
       OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
-      OPT_READ_BATCH, OPT_WRITE_BATCH};
+      OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_FIXED_CSUMSEED};
 
 static struct poptOption long_options[] = {
   /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
@@ -379,6 +381,7 @@
   {"hard-links",      'H', POPT_ARG_NONE,   &preserve_hard_links, 0, 0, 0 },
   {"read-batch",       0,  POPT_ARG_STRING, &batch_prefix,  OPT_READ_BATCH, 0, 0 },
   {"write-batch",      0,  POPT_ARG_STRING, &batch_prefix,  OPT_WRITE_BATCH, 0, 0 },
+  {"fixed-csumseed",   0,  POPT_ARG_NONE,   0,		    OPT_FIXED_CSUMSEED, 0, 0 },
   {"files-from",       0,  POPT_ARG_STRING, &files_from, 0, 0, 0 },
   {"from0",           '0', POPT_ARG_NONE,   &eol_nulls, 0, 0, 0},
   {"no-implied-dirs",  0,  POPT_ARG_VAL,    &implied_dirs, 0, 0, 0 },
@@ -564,6 +567,11 @@
 			checksum_seed = FIXED_CHECKSUM_SEED;
 			break;
 
+		case OPT_FIXED_CSUMSEED:
+			fixed_csumseed = 1;
+			checksum_seed = FIXED_CHECKSUM_SEED;
+			break;
+
 		case OPT_LINK_DEST:
 #if HAVE_LINK
 			compare_dest = (char *)poptGetOptArg(pc);
@@ -931,6 +939,10 @@
 			args[ac++] = "--files-from=-";
 			args[ac++] = "--from0";
 		}
+	}
+
+	if (fixed_csumseed) {
+		args[ac++] = "--fixed-csumseed";
 	}
 
 	*argc = ac;
diff -bur rsync/rsync.yo rsync-fixedcsum/rsync.yo
--- rsync/rsync.yo	Mon Feb  2 10:23:09 2004
+++ rsync-fixedcsum/rsync.yo	Mon Feb 16 12:36:08 2004
@@ -348,6 +348,7 @@
      --bwlimit=KBPS          limit I/O bandwidth, KBytes per second
      --write-batch=PREFIX    write batch fileset starting with PREFIX
      --read-batch=PREFIX     read batch fileset starting with PREFIX
+     --fixed-csumseed        use fixed MD4 block/file checksum seed
  -h, --help                  show this help screen
 
 
@@ -879,6 +880,15 @@
 dit(bf(--read-batch=PREFIX)) Apply a previously generated change batch,
 using the fileset whose filenames start with PREFIX. See the "BATCH
 MODE" section for details.
+
+dit(bf(--fixed-csumseed)) Set the MD4 checksum seed to the fixed
+value 32761.  This 4 byte checksum seed is included in each block and
+file MD4 checksum calculation.  By default the checksum seed is generated
+by the server and defaults to the current time(), or 32761 if
+bf(--write-batch) or bf(--read-batch) are specified.  This default
+causes the MD4 block and file checksums to be different each time rsync
+is run. For applications that cache the block or file checksums the
+checksum seed needs to be fixed each time rsync runs using this option.
 
 enddit()
 


More information about the rsync mailing list