📄 options.c
字号:
} else if (omit_dir_times) { if (preserve_times > 1) preserve_times = 1; } if (stdout_format) { if (am_server && log_format_has(stdout_format, 'I')) stdout_format_has_i = 2; else if (log_format_has(stdout_format, 'i')) stdout_format_has_i = itemize_changes | 1; if (!log_format_has(stdout_format, 'b') && !log_format_has(stdout_format, 'c')) log_before_transfer = !am_server; } else if (itemize_changes) { stdout_format = "%i %n%L"; stdout_format_has_i = itemize_changes; log_before_transfer = !am_server; } if (do_progress && !verbose && !log_before_transfer && !am_server) verbose = 1; if (dry_run) do_xfers = 0; set_io_timeout(io_timeout); if (verbose && !stdout_format) { stdout_format = "%n%L"; log_before_transfer = !am_server; } if (stdout_format_has_i || log_format_has(stdout_format, 'o')) stdout_format_has_o_or_i = 1; if (logfile_name && !am_daemon) { if (!logfile_format) { logfile_format = "%i %n%L"; logfile_format_has_i = logfile_format_has_o_or_i = 1; } else { if (log_format_has(logfile_format, 'i')) logfile_format_has_i = 1; if (logfile_format_has_i || log_format_has(logfile_format, 'o')) logfile_format_has_o_or_i = 1; } log_init(0); } else if (!am_daemon) logfile_format = NULL; if (daemon_bwlimit && (!bwlimit || bwlimit > daemon_bwlimit)) bwlimit = daemon_bwlimit; if (bwlimit) { bwlimit_writemax = (size_t)bwlimit * 128; if (bwlimit_writemax < 512) bwlimit_writemax = 512; } if (sparse_files && inplace) { /* Note: we don't check for this below, because --append is * OK with --sparse (as long as redos are handled right). */ snprintf(err_buf, sizeof err_buf, "--sparse cannot be used with --inplace\n"); return 0; } if (append_mode) { if (whole_file > 0) { snprintf(err_buf, sizeof err_buf, "--append cannot be used with --whole-file\n"); return 0; } if (refused_inplace) { create_refuse_error(refused_inplace); return 0; } inplace = 1; } if (delay_updates && !partial_dir) partial_dir = tmp_partialdir; if (inplace) {#ifdef HAVE_FTRUNCATE if (partial_dir) { snprintf(err_buf, sizeof err_buf, "--%s cannot be used with --%s\n", append_mode ? "append" : "inplace", delay_updates ? "delay-updates" : "partial-dir"); return 0; } /* --inplace implies --partial for refusal purposes, but we * clear the keep_partial flag for internal logic purposes. */ if (refused_partial) { create_refuse_error(refused_partial); return 0; } keep_partial = 0;#else snprintf(err_buf, sizeof err_buf, "--%s is not supported on this %s\n", append_mode ? "append" : "inplace", am_server ? "server" : "client"); return 0;#endif } else { if (keep_partial && !partial_dir && !am_server) { if ((arg = getenv("RSYNC_PARTIAL_DIR")) != NULL && *arg) partial_dir = strdup(arg); } if (partial_dir) { if (*partial_dir) clean_fname(partial_dir, CFN_COLLAPSE_DOT_DOT_DIRS); if (!*partial_dir || strcmp(partial_dir, ".") == 0) partial_dir = NULL; if (!partial_dir && refused_partial) { create_refuse_error(refused_partial); return 0; } keep_partial = 1; } } if (files_from) { char *h, *p; int q; if (argc > 2 || (!am_daemon && argc == 1)) { usage(FERROR); exit_cleanup(RERR_SYNTAX); } if (strcmp(files_from, "-") == 0) { filesfrom_fd = 0; if (am_server) filesfrom_host = ""; /* reading from socket */ } else if ((p = check_for_hostspec(files_from, &h, &q)) != 0) { if (am_server) { snprintf(err_buf, sizeof err_buf, "The --files-from sent to the server cannot specify a host.\n"); return 0; } files_from = p; filesfrom_host = h; if (strcmp(files_from, "-") == 0) { snprintf(err_buf, sizeof err_buf, "Invalid --files-from remote filename\n"); return 0; } } else { if (sanitize_paths) files_from = sanitize_path(NULL, files_from, NULL, 0, SP_DEFAULT); if (daemon_filter_list.head) { char *dir; if (!*files_from) goto options_rejected; dir = files_from + (*files_from == '/' ? module_dirlen : 0); clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS); if (check_filter(&daemon_filter_list, FLOG, dir, 0) < 0) goto options_rejected; } filesfrom_fd = open(files_from, O_RDONLY|O_BINARY); if (filesfrom_fd < 0) { snprintf(err_buf, sizeof err_buf, "failed to open files-from file %s: %s\n", files_from, strerror(errno)); return 0; } } } am_starting_up = 0; return 1; options_rejected: snprintf(err_buf, sizeof err_buf, "Your options have been rejected by the server.\n"); return 0;}/** * Construct a filtered list of options to pass through from the * client to the server. * * This involves setting options that will tell the server how to * behave, and also filtering out options that are processed only * locally. **/void server_options(char **args, int *argc_p){ static char argstr[64]; int ac = *argc_p; char *arg; int i, x; /* This should always remain first on the server's command-line. */ args[ac++] = "--server"; if (daemon_over_rsh > 0) { args[ac++] = "--daemon"; *argc_p = ac; /* if we're passing --daemon, we're done */ return; } if (!am_sender) args[ac++] = "--sender"; x = 1; argstr[0] = '-'; if (protect_args) argstr[x++] = 's'; for (i = 0; i < verbose; i++) argstr[x++] = 'v'; /* the -q option is intentionally left out */ if (make_backups) argstr[x++] = 'b'; if (update_only) argstr[x++] = 'u'; if (!do_xfers) /* Note: NOT "dry_run"! */ argstr[x++] = 'n'; if (preserve_links) argstr[x++] = 'l'; if ((xfer_dirs >= 2 && xfer_dirs < 4) || (xfer_dirs && !recurse && (list_only || (delete_mode && am_sender)))) argstr[x++] = 'd'; if (am_sender) { if (keep_dirlinks) argstr[x++] = 'K'; if (prune_empty_dirs) argstr[x++] = 'm'; if (omit_dir_times) argstr[x++] = 'O'; } else { if (copy_links) argstr[x++] = 'L'; if (copy_dirlinks) argstr[x++] = 'k'; } if (whole_file > 0) argstr[x++] = 'W'; /* We don't need to send --no-whole-file, because it's the * default for remote transfers, and in any case old versions * of rsync will not understand it. */ if (preserve_hard_links) { argstr[x++] = 'H'; if (preserve_hard_links > 1) argstr[x++] = 'H'; } if (preserve_uid) argstr[x++] = 'o'; if (preserve_gid) argstr[x++] = 'g'; if (preserve_devices) /* ignore preserve_specials here */ argstr[x++] = 'D'; if (preserve_times) argstr[x++] = 't'; if (preserve_perms) argstr[x++] = 'p'; else if (preserve_executability && am_sender) argstr[x++] = 'E';#ifdef SUPPORT_ACLS if (preserve_acls) argstr[x++] = 'A';#endif#ifdef SUPPORT_XATTRS if (preserve_xattrs) { argstr[x++] = 'X'; if (preserve_xattrs > 1) argstr[x++] = 'X'; }#endif if (recurse) argstr[x++] = 'r'; if (always_checksum) argstr[x++] = 'c'; if (cvs_exclude) argstr[x++] = 'C'; if (ignore_times) argstr[x++] = 'I'; if (relative_paths) argstr[x++] = 'R'; if (one_file_system) { argstr[x++] = 'x'; if (one_file_system > 1) argstr[x++] = 'x'; } if (sparse_files) argstr[x++] = 'S'; if (do_compression) argstr[x++] = 'z'; set_allow_inc_recurse(); /* Checking the pre-negotiated value allows --protocol=29 override. */ if (protocol_version >= 30) { /* We make use of the -e option to let the server know about * any pre-release protocol version && some behavior flags. */ argstr[x++] = 'e';#if SUBPROTOCOL_VERSION != 0 if (protocol_version == PROTOCOL_VERSION) { x += snprintf(argstr+x, sizeof argstr - x, "%d.%d", PROTOCOL_VERSION, SUBPROTOCOL_VERSION); } else#endif argstr[x++] = '.'; if (allow_inc_recurse) argstr[x++] = 'i';#if defined HAVE_LUTIMES && defined HAVE_UTIMES argstr[x++] = 'L';#endif#ifdef ICONV_OPTION argstr[x++] = 's';#endif } if (x >= (int)sizeof argstr) { /* Not possible... */ rprintf(FERROR, "argstr overflow in server_options().\n"); exit_cleanup(RERR_MALLOC); } argstr[x] = '\0'; if (x > 1) args[ac++] = argstr;#ifdef ICONV_OPTION if (iconv_opt) { char *set = strchr(iconv_opt, ','); if (set) set++; else set = iconv_opt; if (asprintf(&arg, "--iconv=%s", set) < 0) goto oom; args[ac++] = arg; }#endif if (protect_args && !local_server) /* unprotected args stop here */ args[ac++] = NULL; if (list_only > 1) args[ac++] = "--list-only"; /* This makes sure that the remote rsync can handle deleting with -d * sans -r because the --no-r option was added at the same time. */ if (xfer_dirs && !recurse && delete_mode && am_sender) args[ac++] = "--no-r"; if (do_compression && def_compress_level != Z_DEFAULT_COMPRESSION) { if (asprintf(&arg, "--compress-level=%d", def_compress_level) < 0) goto oom; args[ac++] = arg; } if (preserve_devices) { /* Note: sending "--devices" would not be backward-compatible. */ if (!preserve_specials) args[ac++] = "--no-specials"; /* -D is already set. */ } else if (preserve_specials) args[ac++] = "--specials"; /* The server side doesn't use our log-format, but in certain * circumstances they need to know a little about the option. */ if (stdout_format && am_sender) { /* Use --log-format, not --out-format, for compatibility. */ if (stdout_format_has_i > 1) args[ac++] = "--log-format=%i%I"; else if (stdout_format_has_i) args[ac++] = "--log-format=%i"; else if (stdout_format_has_o_or_i) ar
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -