1 Please CC me. I'm not subscribed.
3 Attached is a patch against 2.5.4pre1 CVS current to add the
4 --link-dest option so rsync will create hardlinks for
5 unchanged regular files to a directory on the destination.
6 This is like --compare-dest except that the result is not a
9 Also included is extension to --(ex|in)clude-from to allow -
12 Could one of the maintainers please add this to the
15 Thanks to Dave Dykstra for feedback on this.
18 ________________________________________________________________
19 J.W. Schultz Pegasystems Technologies
20 email address: jw@pegasys.ws
22 Remember Cernan and Schmitt
25 ===================================================================
26 RCS file: /cvsroot/rsync/exclude.c,v
27 retrieving revision 1.42
28 diff -u -r1.42 exclude.c
29 --- exclude.c 18 Feb 2002 19:10:28 -0000 1.42
30 +++ exclude.c 21 Mar 2002 23:31:25 -0000
32 int fatal, int include)
34 struct exclude_struct **list=list1;
35 - FILE *f = fopen(fname,"r");
37 char line[MAXPATHLEN];
39 + if (strcmp(fname, "-")) {
40 + f = fopen(fname,"r");
46 rsyserr(FERROR, errno,
48 ===================================================================
49 RCS file: /cvsroot/rsync/generator.c,v
50 retrieving revision 1.37
51 diff -u -r1.37 generator.c
52 --- generator.c 19 Mar 2002 20:16:42 -0000 1.37
53 +++ generator.c 21 Mar 2002 23:31:26 -0000
55 extern int always_checksum;
56 extern int modify_window;
57 extern char *compare_dest;
58 +extern int link_dest;
61 /* choose whether to skip a particular file */
63 if (st->st_size != file->length) {
67 + if((st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT)) {
70 + if (st->st_uid != file->uid || st->st_gid != file->gid) {
76 /* if always checksum is set then we use the checksum instead
77 of the file time to determine whether to sync */
84 + if (do_link(fnamecmpbuf, fname) != 0) {
86 + rprintf(FINFO,"link %s => %s : %s\n",
90 + fnamecmp = fnamecmpbuf;
94 fnamecmp = fnamecmpbuf;
97 ===================================================================
98 RCS file: /cvsroot/rsync/options.c,v
99 retrieving revision 1.89
100 diff -u -r1.89 options.c
101 --- options.c 19 Mar 2002 20:16:42 -0000 1.89
102 +++ options.c 21 Mar 2002 23:31:27 -0000
104 char *rsync_path = RSYNC_PATH;
105 char *backup_dir = NULL;
106 int rsync_port = RSYNC_PORT;
112 OPT_EXCLUDE_FROM, OPT_DELETE, OPT_DELETE_EXCLUDED, OPT_NUMERIC_IDS,
113 OPT_RSYNC_PATH, OPT_FORCE, OPT_TIMEOUT, OPT_DAEMON, OPT_CONFIG, OPT_PORT,
114 OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS, OPT_PARTIAL, OPT_PROGRESS,
115 - OPT_COPY_UNSAFE_LINKS, OPT_SAFE_LINKS, OPT_COMPARE_DEST,
116 + OPT_COPY_UNSAFE_LINKS, OPT_SAFE_LINKS, OPT_COMPARE_DEST, OPT_LINK_DEST,
117 OPT_LOG_FORMAT, OPT_PASSWORD_FILE, OPT_SIZE_ONLY, OPT_ADDRESS,
118 OPT_DELETE_AFTER, OPT_EXISTING, OPT_MAX_DELETE, OPT_BACKUP_DIR,
119 OPT_IGNORE_ERRORS, OPT_BWLIMIT, OPT_BLOCKING_IO,
121 {"timeout", 0, POPT_ARG_INT, &io_timeout , 0, 0, 0 },
122 {"temp-dir", 'T', POPT_ARG_STRING, &tmpdir , 0, 0, 0 },
123 {"compare-dest", 0, POPT_ARG_STRING, &compare_dest , 0, 0, 0 },
124 + {"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
125 /* TODO: Should this take an optional int giving the compression level? */
126 {"compress", 'z', POPT_ARG_NONE, &do_compression , 0, 0, 0 },
127 {"daemon", 0, POPT_ARG_NONE, &am_daemon , 0, 0, 0 },
129 /* popt stores the filename in batch_prefix for us */
132 + case OPT_LINK_DEST:
134 + compare_dest = poptGetOptArg(pc);
138 + snprintf(err_buf,sizeof(err_buf),
139 + "hard links are not supported on this %s\n",
140 + am_server ? "server" : "client");
141 + rprintf(FERROR,"ERROR: hard links not supported on this platform\n");
147 /* FIXME: If --daemon is specified, then errors for later
149 * and it may be an older version that doesn't know this
150 * option, so don't send it if client is the sender.
152 - args[ac++] = "--compare-dest";
153 + args[ac++] = link_dest ? "--link-dest" : "--compare-dest";
154 args[ac++] = compare_dest;
158 ===================================================================
159 RCS file: /cvsroot/rsync/rsync.yo,v
160 retrieving revision 1.95
161 diff -u -r1.95 rsync.yo
162 --- rsync.yo 6 Feb 2002 21:20:49 -0000 1.95
163 +++ rsync.yo 21 Mar 2002 23:31:28 -0000
165 --modify-window=NUM Timestamp window (seconds) for file match (default=0)
166 -T --temp-dir=DIR create temporary files in directory DIR
167 --compare-dest=DIR also compare destination files relative to DIR
168 + --link-dest=DIR create hardlinks to DIR for unchanged files
169 -P equivalent to --partial --progress
170 -z, --compress compress file data
171 --exclude=PATTERN exclude files matching PATTERN
173 option, but instead it adds all exclude patterns listed in the file
174 FILE to the exclude list. Blank lines in FILE and lines starting with
175 ';' or '#' are ignored.
176 +If \fIFILE\fP is \fB-\fP the list will be read from standard input.
178 dit(bf(--include=PATTERN)) This option tells rsync to not exclude the
179 specified pattern of filenames. This is useful as it allows you to
182 dit(bf(--include-from=FILE)) This specifies a list of include patterns
184 +If \fIFILE\fP is \fB-\fP the list will be read from standard input.
186 dit(bf(-C, --cvs-exclude)) This is a useful shorthand for excluding a
187 broad range of files that you often don't want to transfer between
189 --partial because partially transferred files will remain in the new
190 temporary destination until they have a chance to be completed. If DIR is
191 a relative path, it is relative to the destination directory.
193 +dit(bf(--link-dest=DIR)) This option behaves like \fB--compare-dest\fP but
194 +also will create hard links from \fIDIR\fP to the destination directory for
195 +unchanged files. Files with changed ownership or permissions will not be
198 dit(bf(-z, --compress)) With this option, rsync compresses any data from
199 the files that it sends to the destination machine. This