X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/854a1aad352cb8c7236bbed38d2a1985e54b8da7..b20fe0e6ac3aaee633580d44bb03501688185a5a:/options.c diff --git a/options.c b/options.c index bc56b0cd..984fc72b 100644 --- a/options.c +++ b/options.c @@ -82,6 +82,7 @@ char *files_from = NULL; int filesfrom_fd = -1; char *filesfrom_host = NULL; int eol_nulls = 0; +int human_readable = 0; int recurse = 0; int xfer_dirs = -1; int am_daemon = 0; @@ -144,6 +145,7 @@ char *log_format = NULL; char *password_file = NULL; char *rsync_path = RSYNC_PATH; char *backup_dir = NULL; +char *chmod_mode = NULL; char backup_dir_buf[MAXPATHLEN]; int rsync_port = 0; int compare_dest = 0; @@ -163,6 +165,8 @@ int list_only = 0; #define MAX_BATCH_NAME_LEN 256 /* Must be less than MAXPATHLEN-13 */ char *batch_name = NULL; +struct chmod_mode_struct *chmod_modes = NULL; + static int daemon_opt; /* sets am_daemon after option error-reporting */ static int F_option_cnt = 0; static int modify_window_set; @@ -291,6 +295,7 @@ void usage(enum logcode F) rprintf(F," -D, --devices preserve devices (root only)\n"); rprintf(F," -t, --times preserve times\n"); rprintf(F," -O, --omit-dir-times omit directories when preserving times\n"); + rprintf(F," --chmod=CHMOD change destination permissions\n"); rprintf(F," -S, --sparse handle sparse files efficiently\n"); rprintf(F," -n, --dry-run show what would have been transferred\n"); rprintf(F," -W, --whole-file copy files whole (without rsync algorithm)\n"); @@ -341,6 +346,8 @@ void usage(enum logcode F) rprintf(F," --port=PORT specify double-colon alternate port number\n"); rprintf(F," --blocking-io use blocking I/O for the remote shell\n"); rprintf(F," --stats give some file-transfer stats\n"); + rprintf(F," -m, --human-readable output numbers in a human-readable format\n"); + rprintf(F," --si like human-readable, but use powers of 1000\n"); rprintf(F," --progress show progress during transfer\n"); rprintf(F," -P same as --partial --progress\n"); rprintf(F," -i, --itemize-changes output a change-summary for all updates\n"); @@ -379,6 +386,8 @@ static struct poptOption long_options[] = { {"no-v", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 }, {"quiet", 'q', POPT_ARG_NONE, 0, 'q', 0, 0 }, {"stats", 0, POPT_ARG_NONE, &do_stats, 0, 0, 0 }, + {"human-readable", 'm', POPT_ARG_VAL, &human_readable, 1, 0, 0}, + {"si", 0, POPT_ARG_VAL, &human_readable, 2, 0, 0}, {"dry-run", 'n', POPT_ARG_NONE, &dry_run, 0, 0, 0 }, {"archive", 'a', POPT_ARG_NONE, 0, 'a', 0, 0 }, {"recursive", 'r', POPT_ARG_VAL, &recurse, 2, 0, 0 }, @@ -416,6 +425,7 @@ static struct poptOption long_options[] = { {"no-relative", 0, POPT_ARG_VAL, &relative_paths, 0, 0, 0 }, {"no-R", 0, POPT_ARG_VAL, &relative_paths, 0, 0, 0 }, {"no-implied-dirs", 0, POPT_ARG_VAL, &implied_dirs, 0, 0, 0 }, + {"chmod", 0, POPT_ARG_STRING, &chmod_mode, 0, 0, 0 }, {"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 }, {"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 }, {"one-file-system", 'x', POPT_ARG_NONE, &one_file_system, 0, 0, 0 }, @@ -667,7 +677,7 @@ static OFF_T parse_size_arg(char **size_arg, char def_suf) for (arg = *size_arg; isdigit(*(uchar*)arg); arg++) {} if (*arg == '.') for (arg++; isdigit(*(uchar*)arg); arg++) {} - if (*arg && (arg[1] == 't' || arg[1] == 'T')) + if (*arg && (arg[1] == 'b' || arg[1] == 'B')) mult = 1000, make_compatible = 1; else mult = 1024; @@ -698,12 +708,10 @@ static OFF_T parse_size_arg(char **size_arg, char def_suf) if (size > 0 && make_compatible) { /* We convert this manually because we may need %lld precision, * and that's not a portable sprintf() escape. */ - char buf[128], *s = buf + sizeof buf; + char buf[128], *s = buf + sizeof buf - 1; OFF_T num = size; - *--s = '\0'; + *s = '\0'; while (num) { - if (s == buf) /* impossible... */ - out_of_memory("parse_size_arg@buf"); *--s = (num % 10) + '0'; num /= 10; } @@ -1195,6 +1203,12 @@ int parse_arguments(int *argc, const char ***argv, int frommain) if (make_backups && !backup_dir) omit_dir_times = 1; + if (chmod_mode && !(chmod_modes = parse_chmod(chmod_mode))) { + snprintf(err_buf, sizeof err_buf, + "Invalid argument passed to chmod\n"); + return 0; + } + if (log_format) { if (log_format_has(log_format, 'i')) log_format_has_i = 1; @@ -1600,6 +1614,11 @@ void server_options(char **args,int *argc) } } + if (chmod_mode && !am_sender) { + args[ac++] = "--chmod"; + args[ac++] = chmod_mode; + } + if (files_from && (!am_sender || filesfrom_host)) { if (filesfrom_host) { args[ac++] = "--files-from";