-# $OpenBSD: Makefile,v 1.12 2021/10/22 11:10:34 claudio Exp $
+# $OpenBSD: Makefile,v 1.13 2021/10/29 08:00:59 claudio Exp $
PROG= openrsync
SRCS= blocks.c client.c copy.c downloader.c fargs.c flist.c hash.c ids.c \
io.c log.c main.c misc.c mkpath.c mktemp.c receiver.c rmatch.c \
rules.c sender.c server.c session.c socket.c symlinks.c uploader.c
-LDADD+= -lcrypto -lm
-DPADD+= ${LIBCRYPTO} ${LIBM}
+LDADD+= -lcrypto -lm -lutil
+DPADD+= ${LIBCRYPTO} ${LIBM} ${LIBUTIL}
MAN= openrsync.1
CFLAGS+= -Wall -Wextra
-/* $OpenBSD: extern.h,v 1.42 2021/10/22 11:10:34 claudio Exp $ */
+/* $OpenBSD: extern.h,v 1.43 2021/10/29 08:00:59 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
int numeric_ids; /* --numeric-ids */
int one_file_system; /* -x */
int alt_base_mode;
+ off_t max_size; /* --max-size */
+ off_t min_size; /* --min-size */
char *rsync_path; /* --rsync-path */
char *ssh_prog; /* --rsh or -e */
char *port; /* --port */
-/* $OpenBSD: fargs.c,v 1.20 2021/10/22 11:10:34 claudio Exp $ */
+/* $OpenBSD: fargs.c,v 1.21 2021/10/29 08:00:59 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
if (!sess->opts->specials && sess->opts->devices)
/* --devices is sent as -D --no-specials */
addargs(&args, "--no-specials");
+ if (sess->opts->max_size >= 0)
+ addargs(&args, "--max-size=%lld", sess->opts->max_size);
+ if (sess->opts->min_size >= 0)
+ addargs(&args, "--min-size=%lld", sess->opts->min_size);
/* only add --compare-dest, etc if this is the sender */
if (sess->opts->alt_base_mode != 0 &&
-/* $OpenBSD: main.c,v 1.61 2021/10/28 13:07:43 claudio Exp $ */
+/* $OpenBSD: main.c,v 1.62 2021/10/29 08:00:59 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <util.h>
#include "extern.h"
pid_t child;
int fds[2], sd = -1, rc, c, st, i, lidx;
size_t basedir_cnt = 0;
- struct sess sess;
+ struct sess sess;
struct fargs *fargs;
char **args;
const char *errstr;
NULL) == -1)
err(ERR_IPC, "pledge");
+ opts.max_size = opts.min_size = -1;
+
while ((c = getopt_long(argc, argv, "Dae:ghlnoprtvxz", lopts, &lidx))
!= -1) {
switch (c) {
opts.basedir[basedir_cnt++] = optarg;
break;
case OP_MAX_SIZE:
+ if (scan_scaled(optarg, &opts.max_size) == -1)
+ err(1, "bad max-size");
+ break;
case OP_MIN_SIZE:
- /* for now simply ignore */
+ if (scan_scaled(optarg, &opts.min_size) == -1)
+ err(1, "bad min-size");
break;
case OP_VERSION:
fprintf(stderr, "openrsync: protocol version %u\n",
-.\" $OpenBSD: rsync.1,v 1.27 2021/10/22 16:42:28 jmc Exp $
+.\" $OpenBSD: rsync.1,v 1.28 2021/10/29 08:00:59 claudio Exp $
.\"
.\" Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 22 2021 $
+.Dd $Mdocdate: October 29 2021 $
.Dt OPENRSYNC 1
.Os
.Sh NAME
.Op Fl -exclude-from Ns = Ns Ar file
.Op Fl -include Ar pattern
.Op Fl -include-from Ns = Ns Ar file
+.Op Fl -max-size Ns = Ns size
+.Op Fl -min-size Ns = Ns size
.Op Fl -no-motd
.Op Fl -numeric-ids
.Op Fl -port Ns = Ns Ar service
Also transfer symbolic links.
The link is transferred as a standalone file: if the destination does
not exist, it will be broken.
+.It Fl -max-size Ar size
+Don't transfer any file that is larger than
+.Ar size
+bytes.
+Alternatively
+.Ar size
+may instead use a multiplier, as documented in
+.Xr scan_scaled 3 ,
+to specify the size.
+.It Fl -min-size Ar size
+Don't transfer any file that is smaller than
+.Ar size
+bytes.
+See
+.Fl -max-size
+on the definiton of size.
.It Fl n , -dry-run
Do not actually modify the destination.
Mainly useful in combination with
-/* $OpenBSD: uploader.c,v 1.31 2021/10/24 21:24:17 deraadt Exp $ */
+/* $OpenBSD: uploader.c,v 1.32 2021/10/29 08:00:59 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2019 Florian Obser <florian@openbsd.org>
return 0;
}
+ if (sess->opts->max_size >= 0 && f->st.size > sess->opts->max_size) {
+ WARNX("skipping over max-size file %s", f->path);
+ return 0;
+ }
+ if (sess->opts->min_size >= 0 && f->st.size < sess->opts->min_size) {
+ WARNX("skipping under min-size file %s", f->path);
+ return 0;
+ }
+
/*
* For non dry-run cases, we'll write the acknowledgement later
* in the rsync_uploader() function.