summaryrefslogtreecommitdiff
path: root/usr.bin/rsync/main.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-10-29 08:01:00 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-10-29 08:01:00 +0000
commit3a81e5d781279f9f0ff6f56b9aeda90460ab563f (patch)
tree50ec6400523ccb0c4e064200a7d4d7bb2edff6d6 /usr.bin/rsync/main.c
parent7e0fdfd0f823c806ad64c70568f58b4679842bff (diff)
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@
Diffstat (limited to 'usr.bin/rsync/main.c')
-rw-r--r--usr.bin/rsync/main.c13
1 files changed, 10 insertions, 3 deletions
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 <kristaps@bsd.lv>
*
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <util.h>
#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",