+Jason M. Felice wrote:
+
+This patch adds the --link-by-hash=DIR option, which hard links received
+files in a link farm arranged by MD4 file hash. The result is that the system
+will only store one copy of the unique contents of each file, regardless of
+the file's name.
+
+To use this patch, run these commands for a successful build:
+
+ patch -p1 <patches/link-by-hash.diff
+ ./prepare-source
+ ./configure
+ make
+
+based-on: a01e3b490eb36ccf9e704840e1b6683dab867550
+diff --git a/Makefile.in b/Makefile.in
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -37,7 +37,7 @@ OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o \
+ util.o main.o checksum.o match.o syscall.o log.o backup.o delete.o
+ OBJS2=options.o io.o compat.o hlink.o token.o uidlist.o socket.o hashtable.o \
+ fileio.o batch.o clientname.o chmod.o acls.o xattrs.o
+-OBJS3=progress.o pipe.o
++OBJS3=progress.o pipe.o hashlink.o
+ DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o
+ popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \
+ popt/popthelp.o popt/poptparse.o
+diff --git a/flist.c b/flist.c
+--- a/flist.c
++++ b/flist.c
+@@ -74,6 +74,7 @@ extern int sender_keeps_checksum;
+ extern int unsort_ndx;
+ extern struct stats stats;
+ extern char *filesfrom_host;
++extern char *link_by_hash_dir;
+ extern char *usermap, *groupmap;
+
+ extern char curr_dir[MAXPATHLEN];
+@@ -910,7 +911,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+ extra_len += EXTRA_LEN;
+ #endif
+
+- if (always_checksum && S_ISREG(mode))
++ if ((always_checksum || link_by_hash_dir) && S_ISREG(mode))
+ extra_len += SUM_EXTRA_CNT * EXTRA_LEN;
+
+ #if SIZEOF_INT64 >= 8
+diff --git a/hashlink.c b/hashlink.c
+new file mode 100644
+--- /dev/null
++++ b/hashlink.c
+@@ -0,0 +1,339 @@