From 3a81e5d781279f9f0ff6f56b9aeda90460ab563f Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Fri, 29 Oct 2021 08:01:00 +0000 Subject: Properly implement --max-size and --min-size. This uses scan_scaled(3) from libutil which is very similar to how rsync behaves. Not implemented are the +/-1 math and the 1000 vs 1024 multipliers. OK benno@ job@ --- usr.bin/rsync/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'usr.bin/rsync/main.c') diff --git a/usr.bin/rsync/main.c b/usr.bin/rsync/main.c index eeeabec8fb7..d1214a4d25f 100644 --- a/usr.bin/rsync/main.c +++ b/usr.bin/rsync/main.c @@ -1,4 +1,4 @@ -/* $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 * @@ -26,6 +26,7 @@ #include #include #include +#include #include "extern.h" @@ -341,7 +342,7 @@ main(int argc, char *argv[]) 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; @@ -352,6 +353,8 @@ main(int argc, char *argv[]) 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) { @@ -472,8 +475,12 @@ basedir: 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", -- cgit v1.2.3