From: claudio Date: Mon, 27 Nov 2023 11:30:49 +0000 (+0000) Subject: Implement --omit-link-times / -J based on the --omit-dir-times work X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=16f87427420335af008672fbc170824c1ff9669c;p=openbsd Implement --omit-link-times / -J based on the --omit-dir-times work done by job@. OK tb@ --- diff --git a/usr.bin/rsync/extern.h b/usr.bin/rsync/extern.h index abb59987345..a36d9371542 100644 --- a/usr.bin/rsync/extern.h +++ b/usr.bin/rsync/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.46 2023/11/23 11:59:53 job Exp $ */ +/* $OpenBSD: extern.h,v 1.47 2023/11/27 11:30:49 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -147,6 +147,7 @@ struct opts { int one_file_system; /* -x */ int ignore_times; /* -I */ int ignore_dir_times; /* -O */ + int ignore_link_times; /* -J */ int size_only; /* --size-only */ int alt_base_mode; off_t max_size; /* --max-size */ diff --git a/usr.bin/rsync/fargs.c b/usr.bin/rsync/fargs.c index bafa6c1841c..cbc8537f38c 100644 --- a/usr.bin/rsync/fargs.c +++ b/usr.bin/rsync/fargs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fargs.c,v 1.25 2023/11/23 11:59:53 job Exp $ */ +/* $OpenBSD: fargs.c,v 1.26 2023/11/27 11:30:49 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -142,6 +142,8 @@ fargs_cmdline(struct sess *sess, const struct fargs *f, size_t *skip) if (f->mode == FARGS_SENDER) { if (sess->opts->ignore_dir_times) addargs(&args, "-O"); + if (sess->opts->ignore_link_times) + addargs(&args, "-J"); if (sess->opts->size_only) addargs(&args, "--size-only"); diff --git a/usr.bin/rsync/main.c b/usr.bin/rsync/main.c index 0bbdbb0352c..15d936411b1 100644 --- a/usr.bin/rsync/main.c +++ b/usr.bin/rsync/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.70 2023/11/27 10:14:19 claudio Exp $ */ +/* $OpenBSD: main.c,v 1.71 2023/11/27 11:30:49 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -323,7 +323,10 @@ const struct option lopts[] = { { "numeric-ids", no_argument, &opts.numeric_ids, 1 }, { "omit-dir-times", no_argument, &opts.ignore_dir_times, 1 }, { "no-O", no_argument, &opts.ignore_dir_times, 0 }, - { "no-omit-dir-times", no_argument, &opts.ignore_dir_times, 0 }, + { "no-omit-dir-times", no_argument, &opts.ignore_dir_times, 0 }, + { "omit-link-times", no_argument, &opts.ignore_link_times, 1 }, + { "no-J", no_argument, &opts.ignore_link_times, 0 }, + { "no-omit-link-times", no_argument, &opts.ignore_link_times, 0 }, { "owner", no_argument, &opts.preserve_uids, 1 }, { "no-owner", no_argument, &opts.preserve_uids, 0 }, { "perms", no_argument, &opts.preserve_perms, 1 }, @@ -366,8 +369,8 @@ main(int argc, char *argv[]) opts.max_size = opts.min_size = -1; - while ((c = getopt_long(argc, argv, "aDe:ghIlnOoprtVvxz", lopts, &lidx)) - != -1) { + while ((c = getopt_long(argc, argv, "aDe:ghIJlnOoprtVvxz", + lopts, &lidx)) != -1) { switch (c) { case 'D': opts.devices = 1; @@ -392,6 +395,9 @@ main(int argc, char *argv[]) case 'I': opts.ignore_times = 1; break; + case 'J': + opts.ignore_link_times = 1; + break; case 'l': opts.preserve_links = 1; break; @@ -643,7 +649,7 @@ basedir: exit(rc); usage: fprintf(stderr, "usage: %s" - " [-aDgIlnOoprtVvx] [-e program] [--address=sourceaddr]\n" + " [-aDgIJlnOoprtVvx] [-e program] [--address=sourceaddr]\n" "\t[--contimeout=seconds] [--compare-dest=dir] [--del] [--exclude]\n" "\t[--exclude-from=file] [--include] [--include-from=file]\n" "\t[--no-motd] [--numeric-ids] [--port=portnumber]\n" diff --git a/usr.bin/rsync/receiver.c b/usr.bin/rsync/receiver.c index 90f54189415..2d055f38a3e 100644 --- a/usr.bin/rsync/receiver.c +++ b/usr.bin/rsync/receiver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: receiver.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */ +/* $OpenBSD: receiver.c,v 1.32 2023/11/27 11:30:49 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons @@ -114,7 +114,8 @@ rsync_set_metadata_at(struct sess *sess, int newfile, int rootfd, /* Conditionally adjust file modification time. */ - if (sess->opts->preserve_times) { + if (sess->opts->preserve_times && + !(S_ISLNK(f->st.mode) && sess->opts->ignore_link_times)) { ts[0].tv_nsec = UTIME_NOW; ts[1].tv_sec = f->st.mtime; ts[1].tv_nsec = 0;