Commit | Line | Data |
---|---|---|
7a6421fa AT |
1 | /* |
2 | Copyright (C) Andrew Tridgell 1998 | |
3 | ||
4 | This program is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU General Public License as published by | |
6 | the Free Software Foundation; either version 2 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
15 | along with this program; if not, write to the Free Software | |
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
17 | */ | |
18 | ||
19 | /* options parsing code */ | |
20 | ||
21 | #include "rsync.h" | |
22 | ||
23 | ||
24 | int make_backups = 0; | |
25 | int whole_file = 0; | |
26 | int copy_links = 0; | |
27 | int preserve_links = 0; | |
28 | int preserve_hard_links = 0; | |
29 | int preserve_perms = 0; | |
30 | int preserve_devices = 0; | |
31 | int preserve_uid = 0; | |
32 | int preserve_gid = 0; | |
33 | int preserve_times = 0; | |
34 | int update_only = 0; | |
35 | int cvs_exclude = 0; | |
36 | int dry_run=0; | |
37 | int local_server=0; | |
38 | int ignore_times=0; | |
39 | int delete_mode=0; | |
40 | int one_file_system=0; | |
41 | int remote_version=0; | |
42 | int sparse_files=0; | |
43 | int do_compression=0; | |
44 | int am_root=0; | |
45 | int orig_umask=0; | |
46 | int relative_paths=0; | |
47 | int numeric_ids = 0; | |
48 | int force_delete = 0; | |
49 | int io_timeout = 0; | |
50 | int io_error = 0; | |
51 | int read_only = 0; | |
52 | int module_id = -1; | |
53 | int am_server = 0; | |
54 | int am_sender=0; | |
55 | int recurse = 0; | |
56 | int am_daemon=0; | |
8d9dc9f9 | 57 | int am_client=0; |
a800434a | 58 | int do_stats=0; |
eb86d661 | 59 | int do_progress=0; |
c95da96a | 60 | int keep_partial=0; |
d853783f | 61 | int safe_symlinks=0; |
7a6421fa AT |
62 | int block_size=BLOCK_SIZE; |
63 | ||
64 | char *backup_suffix = BACKUP_SUFFIX; | |
65 | char *tmpdir = NULL; | |
375a4556 | 66 | char *compare_dest = NULL; |
7a6421fa AT |
67 | char *config_file = RSYNCD_CONF; |
68 | char *shell_cmd = NULL; | |
b6062654 | 69 | char *log_format = NULL; |
65575e96 | 70 | char *password_file = NULL; |
7a6421fa AT |
71 | char *rsync_path = RSYNC_NAME; |
72 | int rsync_port = RSYNC_PORT; | |
73 | ||
74 | int verbose = 0; | |
b86f0cef | 75 | int quiet = 0; |
7a6421fa | 76 | int always_checksum = 0; |
f7632fc6 | 77 | int list_only = 0; |
7a6421fa AT |
78 | |
79 | void usage(int F) | |
80 | { | |
81 | rprintf(F,"rsync version %s Copyright Andrew Tridgell and Paul Mackerras\n\n", | |
82 | VERSION); | |
704f908e AT |
83 | |
84 | rprintf(F,"rsync is a file transfer program capable of efficient remote update\nvia a fast differencing algorithm.\n\n"); | |
85 | ||
86 | rprintf(F,"Usage: rsync [OPTION]... SRC [USER@]HOST:DEST\n"); | |
87 | rprintf(F," or rsync [OPTION]... [USER@]HOST:SRC DEST\n"); | |
88 | rprintf(F," or rsync [OPTION]... SRC DEST\n"); | |
14d43f1f | 89 | rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n"); |
704f908e | 90 | rprintf(F," or rsync [OPTION]... SRC [USER@]HOST::DEST\n"); |
14d43f1f | 91 | rprintf(F," or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n"); |
704f908e AT |
92 | rprintf(F,"\nOptions\n"); |
93 | rprintf(F," -v, --verbose increase verbosity\n"); | |
b86f0cef | 94 | rprintf(F," -q, --quiet decrease verbosity\n"); |
704f908e AT |
95 | rprintf(F," -c, --checksum always checksum\n"); |
96 | rprintf(F," -a, --archive archive mode\n"); | |
97 | rprintf(F," -r, --recursive recurse into directories\n"); | |
98 | rprintf(F," -R, --relative use relative path names\n"); | |
99 | rprintf(F," -b, --backup make backups (default ~ extension)\n"); | |
100 | rprintf(F," -u, --update update only (don't overwrite newer files)\n"); | |
101 | rprintf(F," -l, --links preserve soft links\n"); | |
102 | rprintf(F," -L, --copy-links treat soft links like regular files\n"); | |
d853783f | 103 | rprintf(F," --safe-links ignore links outside the destination tree\n"); |
704f908e AT |
104 | rprintf(F," -H, --hard-links preserve hard links\n"); |
105 | rprintf(F," -p, --perms preserve permissions\n"); | |
106 | rprintf(F," -o, --owner preserve owner (root only)\n"); | |
107 | rprintf(F," -g, --group preserve group\n"); | |
108 | rprintf(F," -D, --devices preserve devices (root only)\n"); | |
109 | rprintf(F," -t, --times preserve times\n"); | |
110 | rprintf(F," -S, --sparse handle sparse files efficiently\n"); | |
111 | rprintf(F," -n, --dry-run show what would have been transferred\n"); | |
112 | rprintf(F," -W, --whole-file copy whole files, no incremental checks\n"); | |
113 | rprintf(F," -x, --one-file-system don't cross filesystem boundaries\n"); | |
114 | rprintf(F," -B, --block-size=SIZE checksum blocking size\n"); | |
115 | rprintf(F," -e, --rsh=COMMAND specify rsh replacement\n"); | |
116 | rprintf(F," --rsync-path=PATH specify path to rsync on the remote machine\n"); | |
117 | rprintf(F," -C, --cvs-exclude auto ignore files in the same way CVS does\n"); | |
118 | rprintf(F," --delete delete files that don't exist on the sending side\n"); | |
c95da96a | 119 | rprintf(F," --partial keep partially transferred files\n"); |
704f908e AT |
120 | rprintf(F," --force force deletion of directories even if not empty\n"); |
121 | rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n"); | |
122 | rprintf(F," --timeout=TIME set IO timeout in seconds\n"); | |
123 | rprintf(F," -I, --ignore-times don't exclude files that match length and time\n"); | |
124 | rprintf(F," -T --temp-dir=DIR create temporary files in directory DIR\n"); | |
375a4556 | 125 | rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n"); |
704f908e | 126 | rprintf(F," -z, --compress compress file data\n"); |
2acf81eb | 127 | rprintf(F," --exclude=PATTERN exclude files matching PATTERN\n"); |
858fb9eb | 128 | rprintf(F," --exclude-from=FILE exclude patterns listed in FILE\n"); |
2acf81eb | 129 | rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n"); |
858fb9eb | 130 | rprintf(F," --include-from=FILE don't exclude patterns listed in FILE\n"); |
704f908e AT |
131 | rprintf(F," --suffix=SUFFIX override backup suffix\n"); |
132 | rprintf(F," --version print version number\n"); | |
133 | rprintf(F," --daemon run as a rsync daemon\n"); | |
134 | rprintf(F," --config=FILE specify alternate rsyncd.conf file\n"); | |
135 | rprintf(F," --port=PORT specify alternate rsyncd port number\n"); | |
136 | rprintf(F," --stats give some file transfer stats\n"); | |
eb86d661 | 137 | rprintf(F," --progress show progress during transfer\n"); |
b6062654 | 138 | rprintf(F," --log-format=FORMAT log file transfers using specified format\n"); |
65575e96 | 139 | rprintf(F," --password-file=FILE get password from FILE\n"); |
704f908e | 140 | rprintf(F," -h, --help show this help screen\n"); |
7a6421fa AT |
141 | |
142 | rprintf(F,"\n"); | |
143 | rprintf(F,"the backup suffix defaults to %s\n",BACKUP_SUFFIX); | |
144 | rprintf(F,"the block size defaults to %d\n",BLOCK_SIZE); | |
b72f24c7 AT |
145 | |
146 | rprintf(F,"\nPlease see the rsync(1) and rsyncd.conf(5) man pages for full documentation\n"); | |
9e3c856a | 147 | rprintf(F,"See http://rsync.samba.org/ for updates and bug reports\n"); |
7a6421fa AT |
148 | } |
149 | ||
150 | enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE, | |
151 | OPT_EXCLUDE_FROM,OPT_DELETE,OPT_NUMERIC_IDS,OPT_RSYNC_PATH, | |
2b6b4d53 | 152 | OPT_FORCE,OPT_TIMEOUT,OPT_DAEMON,OPT_CONFIG,OPT_PORT, |
d853783f | 153 | OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS, OPT_PARTIAL, OPT_PROGRESS, |
65575e96 | 154 | OPT_SAFE_LINKS, OPT_COMPARE_DEST, OPT_LOG_FORMAT,OPT_PASSWORD_FILE}; |
7a6421fa | 155 | |
b86f0cef | 156 | static char *short_options = "oblLWHpguDCtcahvqrRIxnSe:B:T:z"; |
7a6421fa AT |
157 | |
158 | static struct option long_options[] = { | |
159 | {"version", 0, 0, OPT_VERSION}, | |
160 | {"server", 0, 0, OPT_SERVER}, | |
161 | {"sender", 0, 0, OPT_SENDER}, | |
162 | {"delete", 0, 0, OPT_DELETE}, | |
163 | {"force", 0, 0, OPT_FORCE}, | |
164 | {"numeric-ids", 0, 0, OPT_NUMERIC_IDS}, | |
165 | {"exclude", 1, 0, OPT_EXCLUDE}, | |
166 | {"exclude-from",1, 0, OPT_EXCLUDE_FROM}, | |
2b6b4d53 AT |
167 | {"include", 1, 0, OPT_INCLUDE}, |
168 | {"include-from",1, 0, OPT_INCLUDE_FROM}, | |
7a6421fa | 169 | {"rsync-path", 1, 0, OPT_RSYNC_PATH}, |
65575e96 | 170 | {"password-file", 1, 0, OPT_PASSWORD_FILE}, |
7a6421fa AT |
171 | {"one-file-system",0, 0, 'x'}, |
172 | {"ignore-times",0, 0, 'I'}, | |
173 | {"help", 0, 0, 'h'}, | |
174 | {"dry-run", 0, 0, 'n'}, | |
175 | {"sparse", 0, 0, 'S'}, | |
176 | {"cvs-exclude", 0, 0, 'C'}, | |
177 | {"archive", 0, 0, 'a'}, | |
178 | {"checksum", 0, 0, 'c'}, | |
179 | {"backup", 0, 0, 'b'}, | |
180 | {"update", 0, 0, 'u'}, | |
181 | {"verbose", 0, 0, 'v'}, | |
b86f0cef | 182 | {"quiet", 0, 0, 'q'}, |
7a6421fa AT |
183 | {"recursive", 0, 0, 'r'}, |
184 | {"relative", 0, 0, 'R'}, | |
185 | {"devices", 0, 0, 'D'}, | |
186 | {"perms", 0, 0, 'p'}, | |
187 | {"links", 0, 0, 'l'}, | |
188 | {"copy-links", 0, 0, 'L'}, | |
d853783f | 189 | {"safe-links", 0, 0, OPT_SAFE_LINKS}, |
7a6421fa AT |
190 | {"whole-file", 0, 0, 'W'}, |
191 | {"hard-links", 0, 0, 'H'}, | |
192 | {"owner", 0, 0, 'o'}, | |
193 | {"group", 0, 0, 'g'}, | |
194 | {"times", 0, 0, 't'}, | |
195 | {"rsh", 1, 0, 'e'}, | |
196 | {"suffix", 1, 0, OPT_SUFFIX}, | |
197 | {"block-size", 1, 0, 'B'}, | |
198 | {"timeout", 1, 0, OPT_TIMEOUT}, | |
199 | {"temp-dir", 1, 0, 'T'}, | |
375a4556 | 200 | {"compare-dest", 1, 0, OPT_COMPARE_DEST}, |
7a6421fa AT |
201 | {"compress", 0, 0, 'z'}, |
202 | {"daemon", 0, 0, OPT_DAEMON}, | |
a800434a | 203 | {"stats", 0, 0, OPT_STATS}, |
eb86d661 | 204 | {"progress", 0, 0, OPT_PROGRESS}, |
c95da96a | 205 | {"partial", 0, 0, OPT_PARTIAL}, |
7a6421fa AT |
206 | {"config", 1, 0, OPT_CONFIG}, |
207 | {"port", 1, 0, OPT_PORT}, | |
b6062654 | 208 | {"log-format", 1, 0, OPT_LOG_FORMAT}, |
7a6421fa AT |
209 | {0,0,0,0}}; |
210 | ||
b11ed3b1 | 211 | |
cd8185f2 AT |
212 | static char err_buf[100]; |
213 | ||
214 | void option_error(void) | |
215 | { | |
216 | if (err_buf[0]) { | |
217 | rprintf(FLOG,"%s", err_buf); | |
218 | rprintf(FERROR,"%s", err_buf); | |
219 | } else { | |
220 | rprintf(FLOG,"Error parsing options - unsupported option?\n"); | |
221 | rprintf(FERROR,"Error parsing options - unsupported option?\n"); | |
222 | } | |
223 | exit_cleanup(RERR_UNSUPPORTED); | |
224 | } | |
225 | ||
226 | /* check to see if we should refuse this option */ | |
227 | static int check_refuse_options(char *ref, int opt) | |
228 | { | |
229 | int i, len; | |
230 | char *p; | |
231 | const char *name; | |
232 | ||
233 | for (i=0; long_options[i].name; i++) { | |
234 | if (long_options[i].val == opt) break; | |
235 | } | |
236 | ||
237 | if (!long_options[i].name) return 0; | |
238 | ||
239 | name = long_options[i].name; | |
240 | len = strlen(name); | |
241 | ||
242 | while ((p = strstr(ref,name))) { | |
055af776 AT |
243 | if ((p==ref || p[-1]==' ') && |
244 | (p[len] == ' ' || p[len] == 0)) { | |
cd8185f2 AT |
245 | slprintf(err_buf,sizeof(err_buf), |
246 | "The '%s' option is not supported by this server\n", name); | |
247 | return 1; | |
248 | } | |
249 | ref += len; | |
250 | } | |
251 | return 0; | |
252 | } | |
253 | ||
254 | ||
b86f0cef | 255 | int parse_arguments(int argc, char *argv[], int frommain) |
7a6421fa | 256 | { |
d853783f AT |
257 | int opt; |
258 | int option_index; | |
cd8185f2 | 259 | char *ref = lp_refuse_options(module_id); |
d853783f AT |
260 | |
261 | while ((opt = getopt_long(argc, argv, | |
262 | short_options, long_options, &option_index)) | |
263 | != -1) { | |
cd8185f2 AT |
264 | |
265 | if (ref) { | |
266 | if (check_refuse_options(ref, opt)) return 0; | |
267 | } | |
268 | ||
d853783f AT |
269 | switch (opt) { |
270 | case OPT_VERSION: | |
271 | rprintf(FINFO,"rsync version %s protocol version %d\n\n", | |
272 | VERSION,PROTOCOL_VERSION); | |
273 | rprintf(FINFO,"Written by Andrew Tridgell and Paul Mackerras\n"); | |
274 | exit_cleanup(0); | |
275 | ||
276 | case OPT_SUFFIX: | |
277 | backup_suffix = optarg; | |
278 | break; | |
279 | ||
280 | case OPT_RSYNC_PATH: | |
281 | rsync_path = optarg; | |
282 | break; | |
65575e96 AT |
283 | |
284 | case OPT_PASSWORD_FILE: | |
285 | password_file =optarg; | |
286 | break; | |
d853783f AT |
287 | case 'I': |
288 | ignore_times = 1; | |
289 | break; | |
290 | ||
291 | case 'x': | |
292 | one_file_system=1; | |
293 | break; | |
294 | ||
295 | case OPT_DELETE: | |
296 | delete_mode = 1; | |
297 | break; | |
298 | ||
299 | case OPT_FORCE: | |
300 | force_delete = 1; | |
301 | break; | |
302 | ||
303 | case OPT_NUMERIC_IDS: | |
304 | numeric_ids = 1; | |
305 | break; | |
306 | ||
307 | case OPT_EXCLUDE: | |
308 | add_exclude(optarg, 0); | |
309 | break; | |
310 | ||
311 | case OPT_INCLUDE: | |
312 | add_exclude(optarg, 1); | |
313 | break; | |
314 | ||
315 | case OPT_EXCLUDE_FROM: | |
316 | add_exclude_file(optarg,1, 0); | |
317 | break; | |
318 | ||
319 | case OPT_INCLUDE_FROM: | |
320 | add_exclude_file(optarg,1, 1); | |
321 | break; | |
322 | ||
323 | case OPT_SAFE_LINKS: | |
324 | safe_symlinks=1; | |
325 | break; | |
326 | ||
327 | case 'h': | |
328 | usage(FINFO); | |
329 | exit_cleanup(0); | |
330 | ||
331 | case 'b': | |
332 | make_backups=1; | |
333 | break; | |
334 | ||
335 | case 'n': | |
336 | dry_run=1; | |
337 | break; | |
338 | ||
339 | case 'S': | |
340 | sparse_files=1; | |
341 | break; | |
342 | ||
343 | case 'C': | |
344 | cvs_exclude=1; | |
345 | break; | |
346 | ||
347 | case 'u': | |
348 | update_only=1; | |
349 | break; | |
350 | ||
351 | case 'l': | |
352 | preserve_links=1; | |
353 | break; | |
354 | ||
355 | case 'L': | |
356 | copy_links=1; | |
357 | break; | |
358 | ||
359 | case 'W': | |
360 | whole_file=1; | |
361 | break; | |
362 | ||
363 | case 'H': | |
7a6421fa | 364 | #if SUPPORT_HARD_LINKS |
d853783f | 365 | preserve_hard_links=1; |
7a6421fa | 366 | #else |
cd8185f2 | 367 | slprintf(err_buf,sizeof(err_buf),"hard links are not supported on this server\n"); |
d853783f | 368 | rprintf(FERROR,"ERROR: hard links not supported on this platform\n"); |
b11ed3b1 | 369 | return 0; |
7a6421fa | 370 | #endif |
d853783f | 371 | break; |
7a6421fa | 372 | |
d853783f AT |
373 | case 'p': |
374 | preserve_perms=1; | |
375 | break; | |
7a6421fa | 376 | |
d853783f AT |
377 | case 'o': |
378 | preserve_uid=1; | |
379 | break; | |
7a6421fa | 380 | |
d853783f AT |
381 | case 'g': |
382 | preserve_gid=1; | |
383 | break; | |
7a6421fa | 384 | |
d853783f AT |
385 | case 'D': |
386 | preserve_devices=1; | |
387 | break; | |
7a6421fa | 388 | |
d853783f AT |
389 | case 't': |
390 | preserve_times=1; | |
391 | break; | |
7a6421fa | 392 | |
d853783f AT |
393 | case 'c': |
394 | always_checksum=1; | |
395 | break; | |
7a6421fa | 396 | |
d853783f AT |
397 | case 'v': |
398 | verbose++; | |
399 | break; | |
7a6421fa | 400 | |
b86f0cef DD |
401 | case 'q': |
402 | if (frommain) quiet++; | |
403 | break; | |
404 | ||
d853783f AT |
405 | case 'a': |
406 | recurse=1; | |
7a6421fa | 407 | #if SUPPORT_LINKS |
d853783f | 408 | preserve_links=1; |
7a6421fa | 409 | #endif |
d853783f AT |
410 | preserve_perms=1; |
411 | preserve_times=1; | |
412 | preserve_gid=1; | |
413 | if (am_root) { | |
414 | preserve_devices=1; | |
415 | preserve_uid=1; | |
416 | } | |
417 | break; | |
418 | ||
419 | case OPT_SERVER: | |
420 | am_server = 1; | |
421 | break; | |
422 | ||
423 | case OPT_SENDER: | |
424 | if (!am_server) { | |
425 | usage(FERROR); | |
65417579 | 426 | exit_cleanup(RERR_SYNTAX); |
d853783f AT |
427 | } |
428 | am_sender = 1; | |
429 | break; | |
430 | ||
431 | case 'r': | |
432 | recurse = 1; | |
433 | break; | |
434 | ||
435 | case 'R': | |
436 | relative_paths = 1; | |
437 | break; | |
438 | ||
439 | case 'e': | |
440 | shell_cmd = optarg; | |
441 | break; | |
442 | ||
443 | case 'B': | |
444 | block_size = atoi(optarg); | |
445 | break; | |
446 | ||
447 | case OPT_TIMEOUT: | |
448 | io_timeout = atoi(optarg); | |
449 | break; | |
450 | ||
451 | case 'T': | |
452 | tmpdir = optarg; | |
453 | break; | |
454 | ||
375a4556 DD |
455 | case OPT_COMPARE_DEST: |
456 | compare_dest = optarg; | |
457 | break; | |
458 | ||
d853783f AT |
459 | case 'z': |
460 | do_compression = 1; | |
461 | break; | |
462 | ||
463 | case OPT_DAEMON: | |
464 | am_daemon = 1; | |
465 | break; | |
466 | ||
467 | case OPT_STATS: | |
468 | do_stats = 1; | |
469 | break; | |
470 | ||
471 | case OPT_PROGRESS: | |
472 | do_progress = 1; | |
473 | break; | |
474 | ||
475 | case OPT_PARTIAL: | |
476 | keep_partial = 1; | |
477 | break; | |
478 | ||
479 | case OPT_CONFIG: | |
480 | config_file = optarg; | |
481 | break; | |
482 | ||
483 | case OPT_PORT: | |
484 | rsync_port = atoi(optarg); | |
485 | break; | |
486 | ||
b6062654 AT |
487 | case OPT_LOG_FORMAT: |
488 | log_format = optarg; | |
489 | break; | |
490 | ||
d853783f | 491 | default: |
cd8185f2 | 492 | slprintf(err_buf,sizeof(err_buf),"unrecognised option\n"); |
b11ed3b1 | 493 | return 0; |
d853783f | 494 | } |
7a6421fa | 495 | } |
b11ed3b1 | 496 | return 1; |
7a6421fa AT |
497 | } |
498 | ||
499 | ||
500 | void server_options(char **args,int *argc) | |
501 | { | |
d853783f AT |
502 | int ac = *argc; |
503 | static char argstr[50]; | |
504 | static char bsize[30]; | |
505 | static char iotime[30]; | |
506 | int i, x; | |
507 | ||
508 | args[ac++] = "--server"; | |
509 | ||
510 | if (!am_sender) | |
511 | args[ac++] = "--sender"; | |
512 | ||
513 | x = 1; | |
514 | argstr[0] = '-'; | |
515 | for (i=0;i<verbose;i++) | |
516 | argstr[x++] = 'v'; | |
b86f0cef | 517 | /* the -q option is intentionally left out */ |
d853783f AT |
518 | if (make_backups) |
519 | argstr[x++] = 'b'; | |
520 | if (update_only) | |
521 | argstr[x++] = 'u'; | |
522 | if (dry_run) | |
523 | argstr[x++] = 'n'; | |
524 | if (preserve_links) | |
525 | argstr[x++] = 'l'; | |
526 | if (copy_links) | |
527 | argstr[x++] = 'L'; | |
528 | if (whole_file) | |
529 | argstr[x++] = 'W'; | |
530 | if (preserve_hard_links) | |
531 | argstr[x++] = 'H'; | |
532 | if (preserve_uid) | |
533 | argstr[x++] = 'o'; | |
534 | if (preserve_gid) | |
535 | argstr[x++] = 'g'; | |
536 | if (preserve_devices) | |
537 | argstr[x++] = 'D'; | |
538 | if (preserve_times) | |
539 | argstr[x++] = 't'; | |
540 | if (preserve_perms) | |
541 | argstr[x++] = 'p'; | |
542 | if (recurse) | |
543 | argstr[x++] = 'r'; | |
544 | if (always_checksum) | |
545 | argstr[x++] = 'c'; | |
546 | if (cvs_exclude) | |
547 | argstr[x++] = 'C'; | |
548 | if (ignore_times) | |
549 | argstr[x++] = 'I'; | |
550 | if (relative_paths) | |
551 | argstr[x++] = 'R'; | |
552 | if (one_file_system) | |
553 | argstr[x++] = 'x'; | |
554 | if (sparse_files) | |
555 | argstr[x++] = 'S'; | |
556 | if (do_compression) | |
557 | argstr[x++] = 'z'; | |
558 | argstr[x] = 0; | |
559 | ||
560 | if (x != 1) args[ac++] = argstr; | |
561 | ||
562 | if (block_size != BLOCK_SIZE) { | |
563 | sprintf(bsize,"-B%d",block_size); | |
564 | args[ac++] = bsize; | |
565 | } | |
566 | ||
567 | if (io_timeout) { | |
568 | sprintf(iotime,"--timeout=%d",io_timeout); | |
569 | args[ac++] = iotime; | |
570 | } | |
571 | ||
572 | if (strcmp(backup_suffix, BACKUP_SUFFIX)) { | |
573 | args[ac++] = "--suffix"; | |
574 | args[ac++] = backup_suffix; | |
575 | } | |
576 | ||
577 | if (delete_mode) | |
578 | args[ac++] = "--delete"; | |
579 | ||
580 | if (keep_partial) | |
581 | args[ac++] = "--partial"; | |
582 | ||
583 | if (force_delete) | |
584 | args[ac++] = "--force"; | |
585 | ||
586 | if (safe_symlinks) | |
587 | args[ac++] = "--safe-links"; | |
588 | ||
589 | if (numeric_ids) | |
590 | args[ac++] = "--numeric-ids"; | |
591 | ||
592 | if (tmpdir) { | |
593 | args[ac++] = "--temp-dir"; | |
594 | args[ac++] = tmpdir; | |
595 | } | |
596 | ||
375a4556 DD |
597 | if (compare_dest && am_sender) { |
598 | /* the server only needs this option if it is not the sender, | |
599 | * and it may be an older version that doesn't know this | |
600 | * option, so don't send it if client is the sender. | |
601 | */ | |
602 | args[ac++] = "--compare-dest"; | |
603 | args[ac++] = compare_dest; | |
604 | } | |
605 | ||
606 | ||
d853783f | 607 | *argc = ac; |
7a6421fa AT |
608 | } |
609 |