From 5e3c6c93f546d8015f6b061348d8815c807d8f1a Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Fri, 1 Dec 2006 18:39:13 +0000 Subject: [PATCH] Fixed failing hunks and added preallocate.diff. --- acls.diff | 51 ++++----- backup-dir-dels.diff | 34 +++--- flags.diff | 69 ++++++------ openssl-support.diff | 51 +++++---- preallocate.diff | 249 +++++++++++++++++++++++++++++++++++++++++++ slp.diff | 27 +++-- xattrs.diff | 52 ++++----- 7 files changed, 383 insertions(+), 150 deletions(-) create mode 100644 preallocate.diff diff --git a/acls.diff b/acls.diff index a5644cf..e36c1d7 100644 --- a/acls.diff +++ b/acls.diff @@ -1179,9 +1179,9 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. } } *p = '/'; -@@ -172,15 +183,18 @@ static int robust_move(char *src, char * +@@ -172,15 +183,18 @@ static int robust_move(const char *src, * We will move the file to be deleted into a parallel directory tree. */ - static int keep_backup(char *fname) + static int keep_backup(const char *fname) { - STRUCT_STAT st; + statx sx; @@ -1200,7 +1200,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. if (!(file = make_file(fname, NULL, NULL, 0, NO_FILTERS))) return 1; /* the file could have disappeared */ -@@ -188,6 +202,13 @@ static int keep_backup(char *fname) +@@ -188,6 +202,13 @@ static int keep_backup(const char *fname if (!(buf = get_backup_name(fname))) return 0; @@ -1214,7 +1214,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. /* Check to see if this is a device file, or link */ if ((am_root && preserve_devices && IS_DEVICE(file->mode)) || (preserve_specials && IS_SPECIAL(file->mode))) { -@@ -256,7 +277,7 @@ static int keep_backup(char *fname) +@@ -256,7 +277,7 @@ static int keep_backup(const char *fname if (robust_move(fname, buf) != 0) { rsyserr(FERROR, errno, "keep_backup failed: %s -> \"%s\"", full_fname(fname), buf); @@ -5660,31 +5660,18 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. #ifdef SUPPORT_LINKS links = ""; #endif -@@ -227,17 +233,16 @@ static void print_rsync_version(enum log - RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION); - rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n"); - rprintf(f, "\n"); -- rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, " -- "%shard links, %ssymlinks, batchfiles,\n", -- (int) (sizeof (OFF_T) * 8), -- got_socketpair, hardlinks, links); -+ rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, %shard links, %ssymlinks,\n", -+ (int) (sizeof (OFF_T) * 8), got_socketpair, hardlinks, links); -+ -+ rprintf(f, " batchfiles, %sinplace, %sIPv6, %sACLs,\n", -+ have_inplace, ipv6, acls); +@@ -233,8 +239,8 @@ static void print_rsync_version(enum log + (int)(sizeof (int64) * 8)); + rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", + got_socketpair, hardlinks, links, ipv6, have_inplace); +- rprintf(f, " %sappend\n", +- have_inplace); ++ rprintf(f, " %sappend, %sACLs\n", ++ have_inplace, acls); - /* Note that this field may not have type ino_t. It depends - * on the complicated interaction between largefile feature - * macros. */ -- rprintf(f, " %sinplace, %sIPv6, " -- "%d-bit system inums, %d-bit internal inums\n", -- have_inplace, ipv6, -+ rprintf(f, " %d-bit system inums, %d-bit internal inums\n", - (int) (sizeof dumstat->st_ino * 8), - (int) (sizeof (int64) * 8)); #ifdef MAINTAINER_MODE -@@ -284,7 +289,7 @@ void usage(enum logcode F) + rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); +@@ -280,7 +286,7 @@ void usage(enum logcode F) rprintf(F," -q, --quiet suppress non-error messages\n"); rprintf(F," --no-motd suppress daemon-mode MOTD (see manpage caveat)\n"); rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n"); @@ -5693,7 +5680,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n"); rprintf(F," -r, --recursive recurse into directories\n"); rprintf(F," -R, --relative use relative path names\n"); -@@ -306,6 +311,9 @@ void usage(enum logcode F) +@@ -302,6 +308,9 @@ void usage(enum logcode F) rprintf(F," -p, --perms preserve permissions\n"); rprintf(F," -E, --executability preserve the file's executability\n"); rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n"); @@ -5703,7 +5690,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); rprintf(F," --devices preserve device files (super-user only)\n"); -@@ -426,6 +434,9 @@ static struct poptOption long_options[] +@@ -422,6 +431,9 @@ static struct poptOption long_options[] {"no-perms", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 }, {"no-p", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 }, {"executability", 'E', POPT_ARG_NONE, &preserve_executability, 0, 0, 0 }, @@ -5713,7 +5700,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 }, {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, -@@ -1091,6 +1102,24 @@ int parse_arguments(int *argc, const cha +@@ -1087,6 +1099,24 @@ int parse_arguments(int *argc, const cha usage(FINFO); exit_cleanup(0); @@ -5738,7 +5725,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. default: /* A large opt value means that set_refuse_options() * turned this option off. */ -@@ -1533,6 +1562,10 @@ void server_options(char **args,int *arg +@@ -1529,6 +1559,10 @@ void server_options(char **args,int *arg if (preserve_hard_links) argstr[x++] = 'H'; @@ -6823,7 +6810,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. for (i = 0; i < flist->count; i++) --- old/util.c +++ new/util.c -@@ -1468,3 +1468,31 @@ int bitbag_next_bit(struct bitbag *bb, i +@@ -1467,3 +1467,31 @@ int bitbag_next_bit(struct bitbag *bb, i return -1; } diff --git a/backup-dir-dels.diff b/backup-dir-dels.diff index d9ab750..29fb760 100644 --- a/backup-dir-dels.diff +++ b/backup-dir-dels.diff @@ -44,13 +44,13 @@ To use this patch, run these commands for a successful build: +static int deleting; + /* make a complete pathname for backup file */ - char *get_backup_name(char *fname) + char *get_backup_name(const char *fname) { -@@ -51,11 +58,28 @@ char *get_backup_name(char *fname) +@@ -51,11 +58,28 @@ char *get_backup_name(const char *fname) return NULL; } -+static char *get_delete_name(char *fname) ++static char *get_delete_name(const char *fname) +{ + if (backup_dir_dels) { + if (stringjoin(backup_dir_dels_buf + backup_dir_dels_len, backup_dir_dels_remainder, @@ -67,12 +67,12 @@ To use this patch, run these commands for a successful build: +} + /* simple backup creates a backup with a suffix in the same directory */ - static int make_simple_backup(char *fname) + static int make_simple_backup(const char *fname) { int rename_errno; -- char *fnamebak = get_backup_name(fname); -+ char *fnamebak = deleting ? get_delete_name(fname) -+ : get_backup_name(fname); +- const char *fnamebak = get_backup_name(fname); ++ const char *fnamebak = deleting ? get_delete_name(fname) ++ : get_backup_name(fname); if (!fnamebak) return 0; @@ -86,7 +86,7 @@ To use this patch, run these commands for a successful build: char *end = rel + strlen(rel); char *p = end; -@@ -185,7 +210,8 @@ static int keep_backup(char *fname) +@@ -185,7 +210,8 @@ static int keep_backup(const char *fname if (!(file = make_file(fname, NULL, NULL, 0, NO_FILTERS))) return 1; /* the file could have disappeared */ @@ -96,7 +96,7 @@ To use this patch, run these commands for a successful build: return 0; /* Check to see if this is a device file, or link */ -@@ -280,3 +306,13 @@ int make_backup(char *fname) +@@ -280,3 +306,13 @@ int make_backup(const char *fname) return keep_backup(fname); return make_simple_backup(fname); } @@ -177,7 +177,7 @@ To use this patch, run these commands for a successful build: char *sockopts = NULL; int rsync_port = 0; int compare_dest = 0; -@@ -292,6 +298,8 @@ void usage(enum logcode F) +@@ -288,6 +294,8 @@ void usage(enum logcode F) rprintf(F," -b, --backup make backups (see --suffix & --backup-dir)\n"); rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n"); rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX); @@ -186,7 +186,7 @@ To use this patch, run these commands for a successful build: rprintf(F," -u, --update skip files that are newer on the receiver\n"); rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n"); rprintf(F," --append append data onto shorter files\n"); -@@ -520,7 +528,9 @@ static struct poptOption long_options[] +@@ -516,7 +524,9 @@ static struct poptOption long_options[] {"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 }, {"backup", 'b', POPT_ARG_NONE, &make_backups, 0, 0, 0 }, {"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 }, @@ -196,7 +196,7 @@ To use this patch, run these commands for a successful build: {"list-only", 0, POPT_ARG_VAL, &list_only, 2, 0, 0 }, {"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 }, {"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 }, -@@ -1234,6 +1244,8 @@ int parse_arguments(int *argc, const cha +@@ -1230,6 +1240,8 @@ int parse_arguments(int *argc, const cha tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, NULL); if (backup_dir) backup_dir = sanitize_path(NULL, backup_dir, NULL, 0, NULL); @@ -205,7 +205,7 @@ To use this patch, run these commands for a successful build: } if (server_filter_list.head && !am_sender) { struct filter_list_struct *elp = &server_filter_list; -@@ -1251,6 +1263,14 @@ int parse_arguments(int *argc, const cha +@@ -1247,6 +1259,14 @@ int parse_arguments(int *argc, const cha if (check_filter(elp, backup_dir, 1) < 0) goto options_rejected; } @@ -220,7 +220,7 @@ To use this patch, run these commands for a successful build: } if (!backup_suffix) -@@ -1262,6 +1282,16 @@ int parse_arguments(int *argc, const cha +@@ -1258,6 +1278,16 @@ int parse_arguments(int *argc, const cha backup_suffix); return 0; } @@ -237,7 +237,7 @@ To use this patch, run these commands for a successful build: if (backup_dir) { backup_dir_len = strlcpy(backup_dir_buf, backup_dir, sizeof backup_dir_buf); backup_dir_remainder = sizeof backup_dir_buf - backup_dir_len; -@@ -1285,6 +1315,31 @@ int parse_arguments(int *argc, const cha +@@ -1281,6 +1311,31 @@ int parse_arguments(int *argc, const cha "P *%s", backup_suffix); parse_rule(&filter_list, backup_dir_buf, 0, 0); } @@ -269,7 +269,7 @@ To use this patch, run these commands for a successful build: if (make_backups && !backup_dir) omit_dir_times = 1; -@@ -1649,6 +1704,10 @@ void server_options(char **args,int *arg +@@ -1645,6 +1700,10 @@ void server_options(char **args,int *arg args[ac++] = "--backup-dir"; args[ac++] = backup_dir; } @@ -280,7 +280,7 @@ To use this patch, run these commands for a successful build: /* Only send --suffix if it specifies a non-default value. */ if (strcmp(backup_suffix, backup_dir ? "" : BACKUP_SUFFIX) != 0) { -@@ -1657,7 +1716,13 @@ void server_options(char **args,int *arg +@@ -1653,7 +1712,13 @@ void server_options(char **args,int *arg goto oom; args[ac++] = arg; } diff --git a/flags.diff b/flags.diff index 0f16462..0035017 100644 --- a/flags.diff +++ b/flags.diff @@ -27,7 +27,7 @@ TODO: fix --delete-delay to work with --flags option. extern int preserve_hard_links; extern int preserve_devices; extern int preserve_specials; -+extern int preserve_flags; ++extern int preserve_fileflags; extern int preserve_uid; extern int preserve_gid; extern int relative_paths; @@ -54,18 +54,18 @@ TODO: fix --delete-delay to work with --flags option. if ((preserve_devices && IS_DEVICE(mode)) || (preserve_specials && IS_SPECIAL(mode))) { if (protocol_version < 28) { -@@ -418,6 +428,10 @@ static void send_file_entry(struct file_ +@@ -417,6 +427,10 @@ static void send_file_entry(struct file_ write_int(f, modtime); if (!(flags & XMIT_SAME_MODE)) write_int(f, to_wire_mode(mode)); +#ifdef SUPPORT_FLAGS -+ if (preserve_flags && !(flags & XMIT_SAME_FLAGS)) ++ if (preserve_fileflags && !(flags & XMIT_SAME_FLAGS)) + write_int(f, (int)fileflags); +#endif if (preserve_uid && !(flags & XMIT_SAME_UID)) { if (!numeric_ids) add_uid(uid); -@@ -485,6 +499,9 @@ static struct file_struct *receive_file_ +@@ -484,6 +498,9 @@ static struct file_struct *receive_file_ { static time_t modtime; static mode_t mode; @@ -75,7 +75,7 @@ TODO: fix --delete-delay to work with --flags option. static int64 dev; static dev_t rdev; static uint32 rdev_major; -@@ -558,9 +575,12 @@ static struct file_struct *receive_file_ +@@ -557,9 +574,12 @@ static struct file_struct *receive_file_ modtime = (time_t)read_int(f); if (!(flags & XMIT_SAME_MODE)) mode = from_wire_mode(read_int(f)); @@ -83,13 +83,13 @@ TODO: fix --delete-delay to work with --flags option. if (chmod_modes && !S_ISLNK(mode)) mode = tweak_mode(mode, chmod_modes); +#ifdef SUPPORT_FLAGS -+ if (preserve_flags && !(flags & XMIT_SAME_FLAGS)) ++ if (preserve_fileflags && !(flags & XMIT_SAME_FLAGS)) + fileflags = (uint32)read_int(f); +#endif if (preserve_uid && !(flags & XMIT_SAME_UID)) uid = (uid_t)read_int(f); -@@ -611,6 +631,9 @@ static struct file_struct *receive_file_ +@@ -610,6 +630,9 @@ static struct file_struct *receive_file_ file->modtime = modtime; file->length = file_length; file->mode = mode; @@ -99,7 +99,7 @@ TODO: fix --delete-delay to work with --flags option. file->uid = uid; file->gid = gid; -@@ -871,6 +894,9 @@ struct file_struct *make_file(char *fnam +@@ -870,6 +893,9 @@ struct file_struct *make_file(const char file->modtime = st.st_mtime; file->length = st.st_size; file->mode = st.st_mode; @@ -220,7 +220,7 @@ TODO: fix --delete-delay to work with --flags option. int preserve_links = 0; int preserve_hard_links = 0; int preserve_perms = 0; -+int preserve_flags = 0; ++int preserve_fileflags = 0; int preserve_executability = 0; int preserve_devices = 0; int preserve_specials = 0; @@ -228,7 +228,7 @@ TODO: fix --delete-delay to work with --flags option. char const *hardlinks = "no "; char const *links = "no "; char const *ipv6 = "no "; -+ char const *flags = "no "; ++ char const *fileflags = "no "; STRUCT_STAT *dumstat; #ifdef HAVE_SOCKETPAIR @@ -237,47 +237,46 @@ TODO: fix --delete-delay to work with --flags option. #endif +#ifdef SUPPORT_FLAGS -+ flags = ""; ++ fileflags = ""; +#endif + rprintf(f, "%s version %s protocol version %d\n", RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION); rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n"); -@@ -235,9 +241,9 @@ static void print_rsync_version(enum log - /* Note that this field may not have type ino_t. It depends - * on the complicated interaction between largefile feature - * macros. */ -- rprintf(f, " %sinplace, %sIPv6, " -+ rprintf(f, " %sinplace, %sIPv6, %sfile flags, " - "%d-bit system inums, %d-bit internal inums\n", -- have_inplace, ipv6, -+ have_inplace, ipv6, flags, - (int) (sizeof dumstat->st_ino * 8), - (int) (sizeof (int64) * 8)); +@@ -233,8 +239,8 @@ static void print_rsync_version(enum log + (int)(sizeof (int64) * 8)); + rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", + got_socketpair, hardlinks, links, ipv6, have_inplace); +- rprintf(f, " %sappend\n", +- have_inplace); ++ rprintf(f, " %sappend, %sfile-flags\n", ++ have_inplace, fileflags); + #ifdef MAINTAINER_MODE -@@ -304,6 +310,7 @@ void usage(enum logcode F) + rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); +@@ -300,6 +306,7 @@ void usage(enum logcode F) rprintf(F," -K, --keep-dirlinks treat symlinked dir on receiver as dir\n"); rprintf(F," -H, --hard-links preserve hard links\n"); rprintf(F," -p, --perms preserve permissions\n"); -+ rprintf(F," --flags preserve file flags\n"); ++ rprintf(F," --fileflags preserve file-flags\n"); rprintf(F," -E, --executability preserve the file's executability\n"); rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n"); rprintf(F," -o, --owner preserve owner (super-user only)\n"); -@@ -425,6 +432,8 @@ static struct poptOption long_options[] +@@ -421,6 +428,8 @@ static struct poptOption long_options[] {"perms", 'p', POPT_ARG_VAL, &preserve_perms, 1, 0, 0 }, {"no-perms", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 }, {"no-p", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 }, -+ {"flags", 0, POPT_ARG_VAL, &preserve_flags, 1, 0, 0 }, -+ {"no-flags", 0, POPT_ARG_VAL, &preserve_flags, 0, 0, 0 }, ++ {"fileflags", 0, POPT_ARG_VAL, &preserve_fileflags, 1, 0, 0 }, ++ {"no-fileflags", 0, POPT_ARG_VAL, &preserve_fileflags, 0, 0, 0 }, {"executability", 'E', POPT_ARG_NONE, &preserve_executability, 0, 0, 0 }, {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 }, {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, -@@ -1130,6 +1139,15 @@ int parse_arguments(int *argc, const cha +@@ -1126,6 +1135,15 @@ int parse_arguments(int *argc, const cha } #endif +#ifndef SUPPORT_FLAGS -+ if (preserve_flags) { ++ if (preserve_fileflags) { + snprintf(err_buf, sizeof err_buf, + "file flags are not supported on this %s\n", + am_server ? "server" : "client"); @@ -288,11 +287,11 @@ TODO: fix --delete-delay to work with --flags option. if (write_batch && read_batch) { snprintf(err_buf, sizeof err_buf, "--write-batch and --read-batch can not be used together\n"); -@@ -1584,6 +1602,9 @@ void server_options(char **args,int *arg +@@ -1580,6 +1598,9 @@ void server_options(char **args,int *arg if (xfer_dirs && !recurse && delete_mode && am_sender) args[ac++] = "--no-r"; -+ if (preserve_flags) ++ if (preserve_fileflags) + args[ac++] = "--flags"; + if (do_compression && def_compress_level != Z_DEFAULT_COMPRESSION) { @@ -309,7 +308,7 @@ TODO: fix --delete-delay to work with --flags option. extern int verbose; extern int dry_run; extern int preserve_perms; -+extern int preserve_flags; ++extern int preserve_fileflags; extern int preserve_executability; extern int preserve_times; extern int omit_dir_times; @@ -334,7 +333,7 @@ TODO: fix --delete-delay to work with --flags option. +/* Remove immutable flags from an object, so it can be altered/removed. */ +void make_mutable(char *fname, mode_t mode, uint32 fileflags) +{ -+ if (!preserve_flags && S_ISLNK(mode)) ++ if (!preserve_fileflags && S_ISLNK(mode)) + return; + + if (fileflags & NOCHANGE_FLAGS) @@ -344,7 +343,7 @@ TODO: fix --delete-delay to work with --flags option. +/* Undo a prior make_mutable() call. */ +void undo_make_mutable(char *fname, mode_t mode, uint32 fileflags) +{ -+ if (!preserve_flags && S_ISLNK(mode)) ++ if (!preserve_fileflags && S_ISLNK(mode)) + return; + + if (fileflags & NOCHANGE_FLAGS) @@ -360,7 +359,7 @@ TODO: fix --delete-delay to work with --flags option. #endif +#ifdef SUPPORT_FLAGS -+ if (preserve_flags && !S_ISLNK(st->st_mode) ++ if (preserve_fileflags && !S_ISLNK(st->st_mode) + && st->st_flags != file->fileflags) { + if (!set_fileflags(fname, file->fileflags)) + return 0; diff --git a/openssl-support.diff b/openssl-support.diff index c6c7e40..708ae3d 100644 --- a/openssl-support.diff +++ b/openssl-support.diff @@ -104,8 +104,8 @@ To use this patch, run these commands for a successful build: + return client_run(fd, fd, -1, argc, argv); } - int start_inband_exchange(char *user, char *path, int f_in, int f_out, -@@ -168,6 +181,33 @@ int start_inband_exchange(char *user, ch + int start_inband_exchange(const char *user, char *path, int f_in, int f_out, +@@ -168,6 +181,33 @@ int start_inband_exchange(const char *us if (verbose > 1) print_child_argv(sargs); @@ -139,7 +139,7 @@ To use this patch, run these commands for a successful build: p = strchr(path,'/'); if (p) *p = 0; io_printf(f_out, "%s\n", path); -@@ -196,6 +236,10 @@ int start_inband_exchange(char *user, ch +@@ -196,6 +236,10 @@ int start_inband_exchange(const char *us * server to terminate the listing of modules. * We don't want to go on and transfer * anything; just exit. */ @@ -150,7 +150,7 @@ To use this patch, run these commands for a successful build: exit(0); } -@@ -203,6 +247,10 @@ int start_inband_exchange(char *user, ch +@@ -203,6 +247,10 @@ int start_inband_exchange(const char *us rprintf(FERROR, "%s\n", line); /* This is always fatal; the server will now * close the socket. */ @@ -252,19 +252,18 @@ To use this patch, run these commands for a successful build: rprintf(f, "%s version %s protocol version %d\n", RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION); rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n"); -@@ -235,9 +248,9 @@ static void print_rsync_version(enum log - /* Note that this field may not have type ino_t. It depends - * on the complicated interaction between largefile feature - * macros. */ -- rprintf(f, " %sinplace, %sIPv6, " -+ rprintf(f, " %sinplace, %sIPv6, %sSSL, " - "%d-bit system inums, %d-bit internal inums\n", -- have_inplace, ipv6, -+ have_inplace, ipv6, ssl, - (int) (sizeof dumstat->st_ino * 8), - (int) (sizeof (int64) * 8)); +@@ -233,8 +246,8 @@ static void print_rsync_version(enum log + (int)(sizeof (int64) * 8)); + rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", + got_socketpair, hardlinks, links, ipv6, have_inplace); +- rprintf(f, " %sappend\n", +- have_inplace); ++ rprintf(f, " %sappend, %sSSL\n", ++ have_inplace, ssl); + #ifdef MAINTAINER_MODE -@@ -385,6 +398,13 @@ void usage(enum logcode F) + rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); +@@ -382,6 +395,13 @@ void usage(enum logcode F) rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); #endif @@ -278,7 +277,7 @@ To use this patch, run these commands for a successful build: rprintf(F," --version print version number\n"); rprintf(F,"(-h) --help show this help (-h works with no other options)\n"); -@@ -398,7 +418,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OP +@@ -395,7 +415,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OP OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP, OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD, OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE, @@ -287,7 +286,7 @@ To use this patch, run these commands for a successful build: OPT_SERVER, OPT_REFUSED_BASE = 9000}; static struct poptOption long_options[] = { -@@ -545,6 +565,13 @@ static struct poptOption long_options[] +@@ -543,6 +563,13 @@ static struct poptOption long_options[] {"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 }, {"server", 0, POPT_ARG_NONE, 0, OPT_SERVER, 0, 0 }, {"sender", 0, POPT_ARG_NONE, 0, OPT_SENDER, 0, 0 }, @@ -301,7 +300,7 @@ To use this patch, run these commands for a successful build: /* All the following options switch us into daemon-mode option-parsing. */ {"config", 0, POPT_ARG_STRING, 0, OPT_DAEMON, 0, 0 }, {"daemon", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 }, -@@ -572,6 +599,13 @@ static void daemon_usage(enum logcode F) +@@ -570,6 +597,13 @@ static void daemon_usage(enum logcode F) rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); #endif @@ -315,7 +314,7 @@ To use this patch, run these commands for a successful build: rprintf(F," --help show this help screen\n"); rprintf(F,"\n"); -@@ -598,6 +632,13 @@ static struct poptOption long_daemon_opt +@@ -596,6 +630,13 @@ static struct poptOption long_daemon_opt {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 }, {"server", 0, POPT_ARG_NONE, &am_server, 0, 0, 0 }, {"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 }, @@ -329,7 +328,7 @@ To use this patch, run these commands for a successful build: {"verbose", 'v', POPT_ARG_NONE, 0, 'v', 0, 0 }, {"no-verbose", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 }, {"no-v", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 }, -@@ -855,6 +896,12 @@ int parse_arguments(int *argc, const cha +@@ -853,6 +894,12 @@ int parse_arguments(int *argc, const cha verbose++; break; @@ -342,7 +341,7 @@ To use this patch, run these commands for a successful build: default: rprintf(FERROR, "rsync: %s: %s (in daemon mode)\n", -@@ -878,6 +925,17 @@ int parse_arguments(int *argc, const cha +@@ -876,6 +923,17 @@ int parse_arguments(int *argc, const cha exit_cleanup(RERR_SYNTAX); } @@ -360,7 +359,7 @@ To use this patch, run these commands for a successful build: *argv = poptGetArgs(pc); *argc = count_args(*argv); am_starting_up = 0; -@@ -1089,6 +1147,12 @@ int parse_arguments(int *argc, const cha +@@ -1087,6 +1145,12 @@ int parse_arguments(int *argc, const cha usage(FINFO); exit_cleanup(0); @@ -373,7 +372,7 @@ To use this patch, run these commands for a successful build: default: /* A large opt value means that set_refuse_options() * turned this option off. */ -@@ -1365,6 +1429,17 @@ int parse_arguments(int *argc, const cha +@@ -1359,6 +1423,17 @@ int parse_arguments(int *argc, const cha if (delay_updates && !partial_dir) partial_dir = tmp_partialdir; @@ -391,7 +390,7 @@ To use this patch, run these commands for a successful build: if (inplace) { #ifdef HAVE_FTRUNCATE if (partial_dir) { -@@ -1782,10 +1857,27 @@ char *check_for_hostspec(char *s, char * +@@ -1783,10 +1858,27 @@ char *check_for_hostspec(char *s, char * char *p; int not_host; int hostlen; @@ -431,7 +430,7 @@ To use this patch, run these commands for a successful build: #define BACKUP_SUFFIX "~" -@@ -419,6 +420,11 @@ enum msgcode { +@@ -420,6 +421,11 @@ enum msgcode { # define SIZEOF_INT64 SIZEOF_OFF_T #endif diff --git a/preallocate.diff b/preallocate.diff new file mode 100644 index 0000000..9d2ccb3 --- /dev/null +++ b/preallocate.diff @@ -0,0 +1,249 @@ +This patch adds the --preallocate option that asks rsync to preallocate the +copied files. This slows down the copy, but should reduce fragmentation on +systems that need that. + +To use this patch, run these commands for a successful build: + + patch -p1 0) { ++ /* Preallocate enough space for file's eventual length if ++ * possible; seems to reduce fragmentation on Windows. */ ++ if (posix_fallocate(fd, 0, total_size) == 0) ++ preallocated_len = total_size; ++ else ++ rsyserr(FINFO, errno, "preallocate %s", full_fname(fname)); ++ } ++#endif ++ + read_sum_head(f_in, &sum); + + if (fd_r >= 0 && size_r > 0) { +@@ -244,8 +258,18 @@ static int receive_data(int f_in, char * + goto report_write_error; + + #ifdef HAVE_FTRUNCATE +- if (inplace && fd != -1) +- ftruncate(fd, offset); ++ /* inplace: New data could be shorter than old data. ++ * preallocate_files: total_size could have been an overestimate. ++ * Cut off any extra preallocated zeros from dest file. */ ++ if ((inplace ++#ifdef SUPPORT_PREALLOCATION ++ || preallocated_len > offset ++#endif ++ ) && fd != -1) ++ if (ftruncate(fd, offset) < 0) ++ /* If we fail to truncate, the dest file may be wrong, so we ++ * must trigger the "partial transfer" error. */ ++ rsyserr(FERROR, errno, "ftruncate %s", full_fname(fname)); + #endif + + if (do_progress) +--- old/rsync.h ++++ new/rsync.h +@@ -493,6 +493,10 @@ struct idev { + #define IN_LOOPBACKNET 127 + #endif + ++#if defined HAVE_FTRUNCATE && defined HAVE_POSIX_FALLOCATE ++#define SUPPORT_PREALLOCATION 1 ++#endif ++ + #define GID_NONE ((gid_t)-1) + + #define HL_CHECK_MASTER 0 +--- old/t_stub.c ++++ new/t_stub.c +@@ -23,6 +23,7 @@ + #include "rsync.h" + + int modify_window = 0; ++int preallocate_files = 0; + int module_id = -1; + int relative_paths = 0; + int human_readable = 0; +--- old/util.c ++++ new/util.c +@@ -25,6 +25,7 @@ + + extern int verbose; + extern int dry_run; ++extern int preallocate_files; + extern int module_id; + extern int modify_window; + extern int relative_paths; +@@ -270,6 +271,10 @@ int copy_file(const char *source, const + int ofd; + char buf[1024 * 8]; + int len; /* Number of bytes read into `buf'. */ ++#ifdef SUPPORT_PREALLOCATION ++ int preallocated_len = 0; ++ int offset = 0; ++#endif + + ifd = do_open(source, O_RDONLY, 0); + if (ifd == -1) { +@@ -289,7 +294,27 @@ int copy_file(const char *source, const + return -1; + } + ++#ifdef SUPPORT_PREALLOCATION ++ if (preallocate_files) { ++ /* Preallocate enough space for file's eventual length if ++ * possible; seems to reduce fragmentation on Windows. */ ++ STRUCT_STAT srcst; ++ if (do_fstat(ifd, &srcst) == 0) { ++ if (srcst.st_size > 0) { ++ if (posix_fallocate(ofd, 0, srcst.st_size) == 0) ++ preallocated_len = srcst.st_size; ++ else ++ rsyserr(FINFO, errno, "posix_fallocate %s", full_fname(dest)); ++ } ++ } else ++ rsyserr(FINFO, errno, "fstat %s", full_fname(source)); ++ } ++#endif ++ + while ((len = safe_read(ifd, buf, sizeof buf)) > 0) { ++#ifdef SUPPORT_PREALLOCATION ++ offset += len; ++#endif + if (full_write(ofd, buf, len) < 0) { + rsyserr(FERROR, errno, "write %s", full_fname(dest)); + close(ifd); +@@ -310,6 +335,16 @@ int copy_file(const char *source, const + full_fname(source)); + } + ++#ifdef SUPPORT_PREALLOCATION ++ /* Source file might have shrunk since we fstatted it. ++ * Cut off any extra preallocated zeros from dest file. */ ++ if (preallocated_len > offset) ++ if (ftruncate(ofd, offset) < 0) ++ /* If we fail to truncate, the dest file may be wrong, so we ++ * must trigger the "partial transfer" error. */ ++ rsyserr(FERROR, errno, "ftruncate %s", full_fname(dest)); ++#endif ++ + if (close(ofd) < 0) { + rsyserr(FERROR, errno, "close failed on %s", + full_fname(dest)); diff --git a/slp.diff b/slp.diff index 4283bcc..0bd50dd 100644 --- a/slp.diff +++ b/slp.diff @@ -57,7 +57,7 @@ and we can't honor that request. int fd; --- old/configure.in +++ new/configure.in -@@ -592,6 +592,29 @@ if test $rsync_cv_can_hardlink_special = +@@ -614,6 +614,29 @@ if test $rsync_cv_can_hardlink_special = AC_DEFINE(CAN_HARDLINK_SPECIAL, 1, [Define to 1 if link() can hard-link special files.]) fi @@ -121,7 +121,7 @@ and we can't honor that request. FN_LOCAL_STRING(lp_comment, comment) --- old/main.c +++ new/main.c -@@ -1058,6 +1058,18 @@ static int start_client(int argc, char * +@@ -1059,6 +1059,18 @@ static int start_client(int argc, char * if (!read_batch) { /* for read_batch, NO source is specified */ shell_path = check_for_hostspec(argv[0], &shell_machine, &rsync_port); @@ -161,21 +161,20 @@ and we can't honor that request. rprintf(f, "%s version %s protocol version %d\n", RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION); rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n"); -@@ -235,9 +240,9 @@ static void print_rsync_version(enum log - /* Note that this field may not have type ino_t. It depends - * on the complicated interaction between largefile feature - * macros. */ -- rprintf(f, " %sinplace, %sIPv6, " -+ rprintf(f, " %sinplace, %sIPv6, %sSLP, " - "%d-bit system inums, %d-bit internal inums\n", -- have_inplace, ipv6, -+ have_inplace, ipv6, slp, - (int) (sizeof dumstat->st_ino * 8), - (int) (sizeof (int64) * 8)); +@@ -233,8 +238,8 @@ static void print_rsync_version(enum log + (int)(sizeof (int64) * 8)); + rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", + got_socketpair, hardlinks, links, ipv6, have_inplace); +- rprintf(f, " %sappend\n", +- have_inplace); ++ rprintf(f, " %sappend, %sSLP\n", ++ have_inplace, slp); + #ifdef MAINTAINER_MODE + rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); --- old/rsync.h +++ new/rsync.h -@@ -157,6 +157,9 @@ +@@ -158,6 +158,9 @@ #define SIGNIFICANT_ITEM_FLAGS (~(\ ITEM_BASIS_TYPE_FOLLOWS | ITEM_XNAME_FOLLOWS | ITEM_LOCAL_CHANGE)) diff --git a/xattrs.diff b/xattrs.diff index eba634b..f66f8e0 100644 --- a/xattrs.diff +++ b/xattrs.diff @@ -120,7 +120,7 @@ TODO: set_file_attrs(fullpath, file, NULL, 0); free(file); } -@@ -195,6 +205,9 @@ static int keep_backup(char *fname) +@@ -195,6 +205,9 @@ static int keep_backup(const char *fname #ifdef SUPPORT_ACLS sx.acc_acl = sx.def_acl = NULL; #endif @@ -130,7 +130,7 @@ TODO: if (!(file = make_file(fname, NULL, NULL, 0, NO_FILTERS))) return 1; /* the file could have disappeared */ -@@ -208,6 +221,12 @@ static int keep_backup(char *fname) +@@ -208,6 +221,12 @@ static int keep_backup(const char *fname cache_acl(file, &sx); } #endif @@ -145,7 +145,7 @@ TODO: if ((am_root && preserve_devices && IS_DEVICE(file->mode)) --- old/configure.in +++ new/configure.in -@@ -856,6 +856,40 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_ +@@ -878,6 +878,40 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_ AC_MSG_RESULT(no) ) @@ -196,7 +196,7 @@ TODO: extern int preserve_links; extern int preserve_hard_links; extern int preserve_devices; -@@ -498,7 +499,7 @@ static struct file_struct *receive_file_ +@@ -499,7 +500,7 @@ static struct file_struct *receive_file_ char thisname[MAXPATHLEN]; unsigned int l1 = 0, l2 = 0; int alloc_len, basename_len, dirname_len, linkname_len, sum_len; @@ -205,7 +205,7 @@ TODO: int xtra_len; #endif OFF_T file_length; -@@ -610,10 +611,16 @@ static struct file_struct *receive_file_ +@@ -611,10 +612,16 @@ static struct file_struct *receive_file_ xtra_len = (S_ISDIR(mode) ? 2 : 1) * 4; else xtra_len = 0; @@ -223,7 +223,7 @@ TODO: + xtra_len #endif + linkname_len + sum_len; -@@ -622,7 +629,7 @@ static struct file_struct *receive_file_ +@@ -623,7 +630,7 @@ static struct file_struct *receive_file_ file = (struct file_struct *)bp; memset(bp, 0, file_struct_len); bp += file_struct_len; @@ -232,7 +232,7 @@ TODO: bp += xtra_len; #endif -@@ -723,6 +730,10 @@ static struct file_struct *receive_file_ +@@ -724,6 +731,10 @@ static struct file_struct *receive_file_ if (preserve_acls) receive_acl(file, f); #endif @@ -243,7 +243,7 @@ TODO: return file; } -@@ -974,7 +985,7 @@ static struct file_struct *send_file_nam +@@ -982,7 +993,7 @@ static struct file_struct *send_file_nam unsigned short flags) { struct file_struct *file; @@ -252,7 +252,7 @@ TODO: statx sx; #endif -@@ -994,6 +1005,13 @@ static struct file_struct *send_file_nam +@@ -1002,6 +1013,13 @@ static struct file_struct *send_file_nam return NULL; } #endif @@ -266,7 +266,7 @@ TODO: maybe_emit_filelist_progress(flist->count + flist_count_offset); -@@ -1006,11 +1024,19 @@ static struct file_struct *send_file_nam +@@ -1014,11 +1032,19 @@ static struct file_struct *send_file_nam if (preserve_acls && f >= 0) send_acl(&sx, f); #endif @@ -482,18 +482,18 @@ TODO: #ifdef SUPPORT_LINKS links = ""; #endif -@@ -236,8 +240,8 @@ static void print_rsync_version(enum log - rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, %shard links, %ssymlinks,\n", - (int) (sizeof (OFF_T) * 8), got_socketpair, hardlinks, links); +@@ -239,8 +243,8 @@ static void print_rsync_version(enum log + (int)(sizeof (int64) * 8)); + rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", + got_socketpair, hardlinks, links, ipv6, have_inplace); +- rprintf(f, " %sappend, %sACLs\n", +- have_inplace, acls); ++ rprintf(f, " %sappend, %sACLs, %sxattrs\n", ++ have_inplace, acls, xattrs); -- rprintf(f, " batchfiles, %sinplace, %sIPv6, %sACLs,\n", -- have_inplace, ipv6, acls); -+ rprintf(f, " batchfiles, %sinplace, %sIPv6, %sACLs, %sxattrs,\n", -+ have_inplace, ipv6, acls, xattrs); - - /* Note that this field may not have type ino_t. It depends - * on the complicated interaction between largefile feature -@@ -289,7 +293,7 @@ void usage(enum logcode F) + #ifdef MAINTAINER_MODE + rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); +@@ -286,7 +290,7 @@ void usage(enum logcode F) rprintf(F," -q, --quiet suppress non-error messages\n"); rprintf(F," --no-motd suppress daemon-mode MOTD (see manpage caveat)\n"); rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n"); @@ -502,7 +502,7 @@ TODO: rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n"); rprintf(F," -r, --recursive recurse into directories\n"); rprintf(F," -R, --relative use relative path names\n"); -@@ -314,6 +318,9 @@ void usage(enum logcode F) +@@ -311,6 +315,9 @@ void usage(enum logcode F) #ifdef SUPPORT_ACLS rprintf(F," -A, --acls preserve ACLs (implies --perms)\n"); #endif @@ -512,7 +512,7 @@ TODO: rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); rprintf(F," --devices preserve device files (super-user only)\n"); -@@ -436,6 +443,9 @@ static struct poptOption long_options[] +@@ -434,6 +441,9 @@ static struct poptOption long_options[] {"acls", 'A', POPT_ARG_NONE, 0, 'A', 0, 0 }, {"no-acls", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 }, {"no-A", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 }, @@ -522,7 +522,7 @@ TODO: {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 }, {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, -@@ -1117,6 +1127,17 @@ int parse_arguments(int *argc, const cha +@@ -1116,6 +1126,17 @@ int parse_arguments(int *argc, const cha return 0; #endif @@ -585,7 +585,7 @@ TODO: #define GID_NONE ((gid_t)-1) #define HL_CHECK_MASTER 0 -@@ -692,6 +696,9 @@ typedef struct { +@@ -699,6 +703,9 @@ typedef struct { struct rsync_acl *acc_acl; /* access ACL */ struct rsync_acl *def_acl; /* default ACL */ #endif @@ -614,7 +614,7 @@ TODO: -o, --owner preserve owner (super-user only) -g, --group preserve group --devices preserve device files (super-user only) -@@ -818,6 +819,11 @@ version makes it incompatible with sendi +@@ -819,6 +820,11 @@ version makes it incompatible with sendi rsync unless you double the bf(--acls) option (e.g. bf(-AA)). This doubling is not needed when pulling files from an older rsync. -- 2.34.1