From: job Date: Thu, 23 Nov 2023 11:59:53 +0000 (+0000) Subject: Add --omit-dir-times / -O X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=97d9fd37e27fb4968e1a79cdd5d38fcdf4d29b14;p=openbsd Add --omit-dir-times / -O OK claudio@ --- diff --git a/usr.bin/rsync/extern.h b/usr.bin/rsync/extern.h index 858c00212ae..abb59987345 100644 --- a/usr.bin/rsync/extern.h +++ b/usr.bin/rsync/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.45 2023/04/28 10:24:38 claudio Exp $ */ +/* $OpenBSD: extern.h,v 1.46 2023/11/23 11:59:53 job Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -146,6 +146,7 @@ struct opts { int numeric_ids; /* --numeric-ids */ int one_file_system; /* -x */ int ignore_times; /* -I */ + int ignore_dir_times; /* -O */ 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 826260f7165..bafa6c1841c 100644 --- a/usr.bin/rsync/fargs.c +++ b/usr.bin/rsync/fargs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fargs.c,v 1.24 2023/04/28 10:24:38 claudio Exp $ */ +/* $OpenBSD: fargs.c,v 1.25 2023/11/23 11:59:53 job Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -140,6 +140,8 @@ fargs_cmdline(struct sess *sess, const struct fargs *f, size_t *skip) /* extra options for the receiver (local is sender) */ if (f->mode == FARGS_SENDER) { + if (sess->opts->ignore_dir_times) + addargs(&args, "-O"); if (sess->opts->size_only) addargs(&args, "--size-only"); diff --git a/usr.bin/rsync/main.c b/usr.bin/rsync/main.c index 30231f34cb4..f6c47eb71b7 100644 --- a/usr.bin/rsync/main.c +++ b/usr.bin/rsync/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.68 2023/04/28 10:24:38 claudio Exp $ */ +/* $OpenBSD: main.c,v 1.69 2023/11/23 11:59:53 job Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -321,6 +321,7 @@ const struct option lopts[] = { { "no-links", no_argument, &opts.preserve_links, 0 }, { "no-motd", no_argument, &opts.no_motd, 1 }, { "numeric-ids", no_argument, &opts.numeric_ids, 1 }, + { "omit-dir-times", no_argument, &opts.ignore_dir_times, 1 }, { "owner", no_argument, &opts.preserve_uids, 1 }, { "no-owner", no_argument, &opts.preserve_uids, 0 }, { "perms", no_argument, &opts.preserve_perms, 1 }, @@ -363,7 +364,7 @@ main(int argc, char *argv[]) opts.max_size = opts.min_size = -1; - while ((c = getopt_long(argc, argv, "aDe:ghIlnoprtVvxz", lopts, &lidx)) + while ((c = getopt_long(argc, argv, "aDe:ghIlnOoprtVvxz", lopts, &lidx)) != -1) { switch (c) { case 'D': @@ -395,6 +396,9 @@ main(int argc, char *argv[]) case 'n': opts.dry_run = 1; break; + case 'O': + opts.ignore_dir_times = 1; + break; case 'o': opts.preserve_uids = 1; break; @@ -637,7 +641,7 @@ basedir: exit(rc); usage: fprintf(stderr, "usage: %s" - " [-aDgIlnoprtVvx] [-e program] [--address=sourceaddr]\n" + " [-aDgIlnOoprtVvx] [-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/rsync.1 b/usr.bin/rsync/rsync.1 index bc8b53631bb..e1b4a8f5de4 100644 --- a/usr.bin/rsync/rsync.1 +++ b/usr.bin/rsync/rsync.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rsync.1,v 1.33 2023/04/28 10:24:38 claudio Exp $ +.\" $OpenBSD: rsync.1,v 1.34 2023/11/23 11:59:53 job Exp $ .\" .\" Copyright (c) 2019 Kristaps Dzonsons .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 28 2023 $ +.Dd $Mdocdate: November 23 2023 $ .Dt OPENRSYNC 1 .Os .Sh NAME @@ -22,7 +22,7 @@ .Nd synchronise local and remote files .Sh SYNOPSIS .Nm openrsync -.Op Fl aDgIlnoprtVvx +.Op Fl aDgIlnOoprtVvx .Op Fl e Ar program .Op Fl -address Ns = Ns Ar sourceaddr .Op Fl -compare-dest Ns = Ns Ar directory @@ -165,6 +165,10 @@ Has no effect unless or .Fl o is also given. +.It Fl O , -omit-dir-times +Don't set directory modification times to match the source. +Takes precedence over +.Fl t . .It Fl o , -owner Set the user name to match the source, with similar matching logic as for .Fl g . diff --git a/usr.bin/rsync/uploader.c b/usr.bin/rsync/uploader.c index ddc54c8cef7..25b3be6ee77 100644 --- a/usr.bin/rsync/uploader.c +++ b/usr.bin/rsync/uploader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uploader.c,v 1.34 2023/04/28 10:24:39 claudio Exp $ */ +/* $OpenBSD: uploader.c,v 1.35 2023/11/23 11:59:53 job Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * Copyright (c) 2019 Florian Obser @@ -608,19 +608,21 @@ post_dir(struct sess *sess, const struct upload *u, size_t idx) * FIXME: run rsync_set_metadata()? */ - if (u->newdir[idx] || - (sess->opts->preserve_times && - st.st_mtime != f->st.mtime)) { - tv[0].tv_sec = time(NULL); - tv[0].tv_nsec = 0; - tv[1].tv_sec = f->st.mtime; - tv[1].tv_nsec = 0; - rc = utimensat(u->rootfd, f->path, tv, 0); - if (rc == -1) { - ERR("%s: utimensat", f->path); - return 0; + if (!sess->opts->ignore_dir_times) { + if (u->newdir[idx] || + (sess->opts->preserve_times && + st.st_mtime != f->st.mtime)) { + tv[0].tv_sec = time(NULL); + tv[0].tv_nsec = 0; + tv[1].tv_sec = f->st.mtime; + tv[1].tv_nsec = 0; + rc = utimensat(u->rootfd, f->path, tv, 0); + if (rc == -1) { + ERR("%s: utimensat", f->path); + return 0; + } + LOG4("%s: updated date", f->path); } - LOG4("%s: updated date", f->path); } /*