+diff --git a/flist.c b/flist.c
+index 09b4fc5..570bcee 100644
+--- a/flist.c
++++ b/flist.c
+@@ -73,6 +73,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];
+@@ -881,7 +882,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+ 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
+index 0000000..15e2a73
+--- /dev/null
++++ b/hashlink.c