summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/rsync/TODO.md4
-rw-r--r--usr.bin/rsync/blocks.c28
-rw-r--r--usr.bin/rsync/child.c2
-rw-r--r--usr.bin/rsync/client.c2
-rw-r--r--usr.bin/rsync/downloader.c54
-rw-r--r--usr.bin/rsync/extern.h20
-rw-r--r--usr.bin/rsync/fargs.c11
-rw-r--r--usr.bin/rsync/flist.c22
-rw-r--r--usr.bin/rsync/hash.c22
-rw-r--r--usr.bin/rsync/io.c19
-rw-r--r--usr.bin/rsync/log.c2
-rw-r--r--usr.bin/rsync/main.c6
-rw-r--r--usr.bin/rsync/mkpath.c3
-rw-r--r--usr.bin/rsync/receiver.c32
-rw-r--r--usr.bin/rsync/rsync.12
-rw-r--r--usr.bin/rsync/rsync.52
-rw-r--r--usr.bin/rsync/rsyncd.52
-rw-r--r--usr.bin/rsync/sender.c10
-rw-r--r--usr.bin/rsync/server.c4
-rw-r--r--usr.bin/rsync/session.c9
-rw-r--r--usr.bin/rsync/socket.c8
-rw-r--r--usr.bin/rsync/symlinks.c2
-rw-r--r--usr.bin/rsync/uploader.c52
23 files changed, 157 insertions, 161 deletions
diff --git a/usr.bin/rsync/TODO.md b/usr.bin/rsync/TODO.md
index c66371a5181..3357ac7d864 100644
--- a/usr.bin/rsync/TODO.md
+++ b/usr.bin/rsync/TODO.md
@@ -8,13 +8,13 @@ I've included the specific security porting topics below.
This list also does not include adding support for features (e.g., **-u** and
so on).
-- Easy: add a hashtable to `blk_find()` in
+- Easy: add a hashtable to `blk_find()` in
[blocks.c](https://github.com/kristapsdz/openrsync/blob/master/blocks.c)
for quickly looking up fast-hash matches.
- Easy: print more statistics, such as transfer times and rates.
-- Easy: tighten the [pledge(2)](https://man.openbsd.org/pledge.2) and
+- Easy: tighten the [pledge(2)](https://man.openbsd.org/pledge.2) and
[unveil(2)](https://man.openbsd.org/unveil.2) to work with **-n**, as
it does not touch files.
diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c
index d6c26eec988..6f1d8d2fb6f 100644
--- a/usr.bin/rsync/blocks.c
+++ b/usr.bin/rsync/blocks.c
@@ -1,4 +1,4 @@
-/* $Id: blocks.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: blocks.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -161,7 +161,7 @@ static int
blk_match_send(struct sess *sess, const char *path, int fd,
const void *buf, off_t size, const struct blkset *blks)
{
- off_t offs, last, end, fromcopy = 0, fromdown = 0,
+ off_t offs, last, end, fromcopy = 0, fromdown = 0,
total = 0, sz;
int32_t tok;
struct blk *blk;
@@ -238,7 +238,7 @@ int
blk_match(struct sess *sess, int fd,
const struct blkset *blks, const char *path)
{
- int nfd, rc = 0, c;
+ int nfd, rc = 0, c;
struct stat st;
void *map = MAP_FAILED;
size_t mapsz;
@@ -293,7 +293,7 @@ blk_match(struct sess *sess, int fd,
"upload ratio", path, (intmax_t)st.st_size);
}
- /*
+ /*
* Now write the full file hash.
* Since we're seeding the hash, this always gives us some sort
* of data even if the file's zero-length.
@@ -408,7 +408,7 @@ blk_recv(struct sess *sess, int fd, const char *path)
}
}
- /*
+ /*
* Read each block individually.
* FIXME: read buffer and unbuffer.
*/
@@ -635,13 +635,13 @@ blk_send(struct sess *sess, int fd, size_t idx,
/* Put the entire send routine into a buffer. */
sz = sizeof(int32_t) + /* identifier */
- sizeof(int32_t) + /* block count */
- sizeof(int32_t) + /* block length */
- sizeof(int32_t) + /* checksum length */
- sizeof(int32_t) + /* block remainder */
- p->blksz *
- (sizeof(int32_t) + /* short checksum */
- p->csum); /* long checksum */
+ sizeof(int32_t) + /* block count */
+ sizeof(int32_t) + /* block length */
+ sizeof(int32_t) + /* checksum length */
+ sizeof(int32_t) + /* block remainder */
+ p->blksz *
+ (sizeof(int32_t) + /* short checksum */
+ p->csum); /* long checksum */
if (NULL == (buf = malloc(sz))) {
ERR(sess, "malloc");
@@ -655,9 +655,9 @@ blk_send(struct sess *sess, int fd, size_t idx,
io_buffer_int(sess, buf, &pos, sz, p->rem);
for (i = 0; i < p->blksz; i++) {
- io_buffer_int(sess, buf, &pos,
+ io_buffer_int(sess, buf, &pos,
sz, p->blks[i].chksum_short);
- io_buffer_buf(sess, buf, &pos, sz,
+ io_buffer_buf(sess, buf, &pos, sz,
p->blks[i].chksum_long, p->csum);
}
diff --git a/usr.bin/rsync/child.c b/usr.bin/rsync/child.c
index 686c58afc91..4e0a43ada5a 100644
--- a/usr.bin/rsync/child.c
+++ b/usr.bin/rsync/child.c
@@ -1,4 +1,4 @@
-/* $Id: child.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: child.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
diff --git a/usr.bin/rsync/client.c b/usr.bin/rsync/client.c
index 9a115136f8d..960927e9c8b 100644
--- a/usr.bin/rsync/client.c
+++ b/usr.bin/rsync/client.c
@@ -1,4 +1,4 @@
-/* $Id: client.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: client.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
diff --git a/usr.bin/rsync/downloader.c b/usr.bin/rsync/downloader.c
index 284e62b7f3c..7046568e0a8 100644
--- a/usr.bin/rsync/downloader.c
+++ b/usr.bin/rsync/downloader.c
@@ -1,4 +1,4 @@
-/* $Id: downloader.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: downloader.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -51,14 +51,14 @@ enum downloadst {
*/
struct download {
enum downloadst state; /* state of affairs */
- size_t idx; /* index of current file */
+ size_t idx; /* index of current file */
struct blkset blk; /* its blocks */
void *map; /* mmap of current file */
size_t mapsz; /* length of mapsz */
int ofd; /* open origin file */
int fd; /* open output file */
char *fname; /* output filename */
- MD4_CTX ctx; /* current hashing context */
+ MD4_CTX ctx; /* current hashing context */
off_t downloaded; /* total downloaded */
off_t total; /* total in file */
const struct flist *fl; /* file list */
@@ -75,7 +75,7 @@ struct download {
* Simply log the filename.
*/
static void
-log_file(struct sess *sess,
+log_file(struct sess *sess,
const struct download *dl, const struct flist *f)
{
float frac, tot = dl->total;
@@ -85,7 +85,7 @@ log_file(struct sess *sess,
if (sess->opts->server)
return;
- frac = 0 == dl->total ? 100.0 :
+ frac = 0 == dl->total ? 100.0 :
100.0 * dl->downloaded / dl->total;
if (dl->total > 1024 * 1024 * 1024) {
@@ -102,7 +102,7 @@ log_file(struct sess *sess,
unit = "KB";
}
- LOG1(sess, "%s (%.*f %s, %.1f%% downloaded)",
+ LOG1(sess, "%s (%.*f %s, %.1f%% downloaded)",
f->path, prec, tot, unit, frac);
}
@@ -155,7 +155,7 @@ download_cleanup(struct download *p, int cleanup)
}
if (-1 != p->fd) {
close(p->fd);
- if (cleanup && NULL != p->fname)
+ if (cleanup && NULL != p->fname)
unlinkat(p->rootfd, p->fname, 0);
p->fd = -1;
}
@@ -171,7 +171,7 @@ download_cleanup(struct download *p, int cleanup)
* On success, download_free() must be called with the pointer.
*/
struct download *
-download_alloc(struct sess *sess, int fdin,
+download_alloc(struct sess *sess, int fdin,
const struct flist *fl, size_t flsz, int rootfd)
{
struct download *p;
@@ -191,7 +191,7 @@ download_alloc(struct sess *sess, int fdin,
p->obuf = NULL;
p->obufmax = OBUF_SIZE;
if (p->obufmax &&
- NULL == (p->obuf = malloc(p->obufmax))) {
+ NULL == (p->obuf = malloc(p->obufmax))) {
ERR(sess, "malloc");
free(p);
return NULL;
@@ -223,7 +223,7 @@ download_free(struct download *p)
* Returns zero on failure, non-zero on success.
*/
static int
-buf_copy(struct sess *sess,
+buf_copy(struct sess *sess,
const char *buf, size_t sz, struct download *p)
{
size_t rem, tocopy;
@@ -231,7 +231,7 @@ buf_copy(struct sess *sess,
assert(p->obufsz <= p->obufmax);
- /*
+ /*
* Copy as much as we can.
* If we've copied everything, exit.
* If we have no pre-write buffer (obufmax of zero), this never
@@ -268,7 +268,7 @@ buf_copy(struct sess *sess,
p->obufsz = 0;
}
- /*
+ /*
* Now drain anything left.
* If we have no pre-write buffer, this is it.
*/
@@ -302,9 +302,9 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
size_t sz, dirlen, tok;
const char *cp;
mode_t perm;
- struct stat st;
+ struct stat st;
char *buf = NULL;
- unsigned char ourmd[MD4_DIGEST_LENGTH],
+ unsigned char ourmd[MD4_DIGEST_LENGTH],
md[MD4_DIGEST_LENGTH];
struct timespec tv[2];
@@ -332,7 +332,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
if (sess->opts->dry_run)
return 1;
- /*
+ /*
* Now get our block information.
* This is all we'll need to reconstruct the file from
* the map, as block sizes are regular.
@@ -344,7 +344,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
goto out;
}
- /*
+ /*
* Next, we want to open the existing file for using as
* block input.
* We do this in a non-blocking way, so if the open
@@ -355,7 +355,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
p->state = DOWNLOAD_READ_LOCAL;
f = &p->fl[idx];
- p->ofd = openat(p->rootfd, f->path,
+ p->ofd = openat(p->rootfd, f->path,
O_RDONLY | O_NONBLOCK, 0);
if (-1 == p->ofd && ENOENT != errno) {
@@ -388,7 +388,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
if (DOWNLOAD_READ_LOCAL == p->state) {
assert(NULL == p->fname);
- /*
+ /*
* Try to fstat() the file descriptor if valid and make
* sure that we're still a regular file.
* Then, if it has non-zero size, mmap() it for hashing.
@@ -405,7 +405,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
if (-1 != p->ofd && st.st_size > 0) {
p->mapsz = st.st_size;
- p->map = mmap(NULL, p->mapsz,
+ p->map = mmap(NULL, p->mapsz,
PROT_READ, MAP_SHARED, p->ofd, 0);
if (MAP_FAILED == p->map) {
ERR(sess, "%s: mmap", f->path);
@@ -417,7 +417,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
*ofd = -1;
- /*
+ /*
* Create the temporary file.
* Use a simple scheme of path/.FILE.RANDOM, where we
* fill in RANDOM with an arc4random number.
@@ -434,7 +434,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
f->path + dirlen + 1, hash) < 0)
p->fname = NULL;
} else {
- if (asprintf(&p->fname, ".%s.%" PRIu32,
+ if (asprintf(&p->fname, ".%s.%" PRIu32,
f->path, hash) < 0)
p->fname = NULL;
}
@@ -443,7 +443,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
goto out;
}
- /*
+ /*
* Inherit permissions from the source file if we're new
* or specifically told with -p.
*/
@@ -453,7 +453,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
else
perm = f->st.mode;
- p->fd = openat(p->rootfd, p->fname,
+ p->fd = openat(p->rootfd, p->fname,
O_APPEND|O_WRONLY|O_CREAT|O_EXCL, perm);
if (-1 == p->fd) {
@@ -461,7 +461,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
goto out;
}
- /*
+ /*
* FIXME: we can technically wait until the temporary
* file is writable, but since it's guaranteed to be
* empty, I don't think this is a terribly expensive
@@ -491,7 +491,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
if ( ! io_read_int(sess, p->fdin, &rawtok)) {
ERRX1(sess, "io_read_int");
goto out;
- }
+ }
if (rawtok > 0) {
sz = rawtok;
@@ -516,7 +516,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
tok = -rawtok - 1;
if (tok >= p->blk.blksz) {
ERRX(sess, "%s: token not in block "
- "set: %zu (have %zu blocks)",
+ "set: %zu (have %zu blocks)",
p->fname, tok, p->blk.blksz);
goto out;
}
@@ -552,7 +552,7 @@ rsync_downloader(struct download *p, struct sess *sess, int *ofd)
assert(0 == rawtok);
assert(0 == p->obufsz);
- /*
+ /*
* Make sure our resulting MD4 hashes match.
* FIXME: if the MD4 hashes don't match, then our file has
* changed out from under us.
diff --git a/usr.bin/rsync/extern.h b/usr.bin/rsync/extern.h
index 8d3d591eace..1a2f6609724 100644
--- a/usr.bin/rsync/extern.h
+++ b/usr.bin/rsync/extern.h
@@ -1,4 +1,4 @@
-/* $Id: extern.h,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: extern.h,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -201,7 +201,7 @@ void rsync_errx1(struct sess *, const char *,
size_t, const char *, ...)
__attribute__((format(printf, 4, 5)));
-int flist_del(struct sess *, int,
+int flist_del(struct sess *, int,
const struct flist *, size_t);
int flist_gen(struct sess *, size_t, char **,
struct flist **, size_t *);
@@ -212,7 +212,7 @@ int flist_recv(struct sess *, int,
struct flist **, size_t *);
int flist_send(struct sess *, int, int,
const struct flist *, size_t);
-int flist_gen_dels(struct sess *, const char *,
+int flist_gen_dels(struct sess *, const char *,
struct flist **, size_t *,
const struct flist *, size_t);
@@ -232,16 +232,16 @@ int io_write_int(struct sess *, int, int32_t);
int io_write_line(struct sess *, int, const char *);
int io_write_long(struct sess *, int, int64_t);
-void io_buffer_int(struct sess *, void *,
+void io_buffer_int(struct sess *, void *,
size_t *, size_t, int32_t);
-void io_buffer_buf(struct sess *, void *,
+void io_buffer_buf(struct sess *, void *,
size_t *, size_t, const void *, size_t);
-void io_unbuffer_int(struct sess *, const void *,
+void io_unbuffer_int(struct sess *, const void *,
size_t *, size_t, int32_t *);
-int io_unbuffer_size(struct sess *, const void *,
+int io_unbuffer_size(struct sess *, const void *,
size_t *, size_t, size_t *);
-void io_unbuffer_buf(struct sess *, const void *,
+void io_unbuffer_buf(struct sess *, const void *,
size_t *, size_t, void *, size_t);
void rsync_child(const struct opts *, int, const struct fargs *)
@@ -252,14 +252,14 @@ int rsync_client(const struct opts *, int, const struct fargs *);
int rsync_socket(const struct opts *, const struct fargs *);
int rsync_server(const struct opts *, size_t, char *[]);
int rsync_downloader(struct download *, struct sess *, int *);
-int rsync_uploader(struct upload *,
+int rsync_uploader(struct upload *,
int *, struct sess *, int *);
int rsync_uploader_tail(struct upload *, struct sess *);
struct download *download_alloc(struct sess *, int,
const struct flist *, size_t, int);
void download_free(struct download *);
-struct upload *upload_alloc(struct sess *, int, int, size_t,
+struct upload *upload_alloc(struct sess *, int, int, size_t,
const struct flist *, size_t, mode_t);
void upload_free(struct upload *);
diff --git a/usr.bin/rsync/fargs.c b/usr.bin/rsync/fargs.c
index 0120479bee1..9bd8cc4b94f 100644
--- a/usr.bin/rsync/fargs.c
+++ b/usr.bin/rsync/fargs.c
@@ -1,4 +1,4 @@
-/* $Id: fargs.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: fargs.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -22,7 +22,7 @@
#include "extern.h"
-#define RSYNC_PATH "rsync"
+#define RSYNC_PATH "rsync"
char **
fargs_cmdline(struct sess *sess, const struct fargs *f)
@@ -39,9 +39,9 @@ fargs_cmdline(struct sess *sess, const struct fargs *f)
/* Be explicit with array size. */
- argsz += 1; /* dot separator */
- argsz += 1; /* sink file */
- argsz += 5; /* per-mode maximum */
+ argsz += 1; /* dot separator */
+ argsz += 1; /* sink file */
+ argsz += 5; /* per-mode maximum */
argsz += 10; /* shared args */
argsz += 1; /* NULL pointer */
argsz += f->sourcesz;
@@ -101,4 +101,3 @@ fargs_cmdline(struct sess *sess, const struct fargs *f)
args[i] = NULL;
return args;
}
-
diff --git a/usr.bin/rsync/flist.c b/usr.bin/rsync/flist.c
index be091267f0d..844e3184423 100644
--- a/usr.bin/rsync/flist.c
+++ b/usr.bin/rsync/flist.c
@@ -1,4 +1,4 @@
-/* $Id: flist.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: flist.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -65,7 +65,7 @@ flist_cmp(const void *p1, const void *p2)
static int
flist_dedupe(struct sess *sess, struct flist **fl, size_t *sz)
{
- size_t i, j;
+ size_t i, j;
struct flist *new;
struct flist *f, *fnext;
@@ -144,7 +144,7 @@ flist_dedupe(struct sess *sess, struct flist **fl, size_t *sz)
static void
flist_topdirs(struct sess *sess, struct flist *fl, size_t flsz)
{
- size_t i;
+ size_t i;
const char *cp;
if ( ! sess->opts->recursive)
@@ -155,7 +155,7 @@ flist_topdirs(struct sess *sess, struct flist *fl, size_t flsz)
if ( ! S_ISDIR(fl[i].st.mode))
continue;
cp = strchr(fl[i].wpath, '/');
- if (NULL != cp && '\0' != cp[1])
+ if (NULL != cp && '\0' != cp[1])
continue;
fl[i].st.flags |= FLSTAT_TOP_DIR;
LOG4(sess, "%s: top-level", fl[i].wpath);
@@ -238,7 +238,7 @@ flist_free(struct flist *f, size_t sz)
* Return zero on failure, non-zero on success.
*/
int
-flist_send(struct sess *sess, int fdin,
+flist_send(struct sess *sess, int fdin,
int fdout, const struct flist *fl, size_t flsz)
{
size_t i, fnlen;
@@ -256,7 +256,7 @@ flist_send(struct sess *sess, int fdin,
fnlen = strlen(f->wpath);
assert(fnlen > 0);
- /*
+ /*
* If applicable, unclog the read buffer.
* This happens when the receiver has a lot of log
* messages and all we're doing is sending our file list
@@ -951,7 +951,7 @@ flist_gen(struct sess *sess, size_t argc,
* On success, "fl" will need to be freed with flist_free().
*/
int
-flist_gen_dels(struct sess *sess, const char *root,
+flist_gen_dels(struct sess *sess, const char *root,
struct flist **fl, size_t *sz,
const struct flist *wfl, size_t wflsz)
{
@@ -963,7 +963,7 @@ flist_gen_dels(struct sess *sess, const char *root,
size_t cargvs = 0, i, j, max = 0, stripdir;
ENTRY hent;
ENTRY *hentp;
-
+
*fl = NULL;
*sz = 0;
@@ -972,7 +972,7 @@ flist_gen_dels(struct sess *sess, const char *root,
if ( ! sess->opts->recursive)
return 1;
- /*
+ /*
* Gather up all top-level directories for scanning.
* This is stipulated by rsync's --delete behaviour, where we
* only delete things in the top-level directories given on the
@@ -1013,7 +1013,7 @@ flist_gen_dels(struct sess *sess, const char *root,
continue;
assert(S_ISDIR(wfl[i].st.mode));
assert(strcmp(wfl[i].wpath, "."));
- c = asprintf(&cargv[j],
+ c = asprintf(&cargv[j],
"%s/%s", root, wfl[i].wpath);
if (c < 0) {
ERR(sess, "asprintf");
@@ -1060,7 +1060,7 @@ flist_gen_dels(struct sess *sess, const char *root,
}
}
- /*
+ /*
* Now we're going to try to descend into all of the top-level
* directories stipulated by the file list.
* If the directories don't exist, it's ok.
diff --git a/usr.bin/rsync/hash.c b/usr.bin/rsync/hash.c
index 97c12db25b1..ebbcaefd4d9 100644
--- a/usr.bin/rsync/hash.c
+++ b/usr.bin/rsync/hash.c
@@ -1,4 +1,4 @@
-/* $Id: hash.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: hash.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -32,21 +32,21 @@
uint32_t
hash_fast(const void *buf, size_t len)
{
- size_t i = 0;
- uint32_t a = 0, /* part of a(k, l) */
- b = 0; /* b(k, l) */
- const signed char *dat = buf;
+ size_t i = 0;
+ uint32_t a = 0, /* part of a(k, l) */
+ b = 0; /* b(k, l) */
+ const signed char *dat = buf;
if (len > 4)
for ( ; i < len - 4; i += 4) {
b += 4 * (a + dat[i]) +
- 3 * dat[i + 1] +
- 2 * dat[i + 2] +
- dat[i + 3];
+ 3 * dat[i + 1] +
+ 2 * dat[i + 2] +
+ dat[i + 3];
a += dat[i + 0] +
- dat[i + 1] +
- dat[i + 2] +
- dat[i + 3];
+ dat[i + 1] +
+ dat[i + 2] +
+ dat[i + 3];
}
for ( ; i < len; i++) {
diff --git a/usr.bin/rsync/io.c b/usr.bin/rsync/io.c
index 630701dbb13..55f1b1c142c 100644
--- a/usr.bin/rsync/io.c
+++ b/usr.bin/rsync/io.c
@@ -1,4 +1,4 @@
-/* $Id: io.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: io.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -302,7 +302,7 @@ io_read_flush(struct sess *sess, int fd)
LOG0(sess, "%.*s", (int)sess->mplex_read_remain, mpbuf);
sess->mplex_read_remain = 0;
- /*
+ /*
* I only know that a tag of one means an error.
* This means that we should exit.
*/
@@ -413,7 +413,7 @@ io_write_int(struct sess *sess, int fd, int32_t val)
* is insufficient for the new data.
*/
void
-io_buffer_buf(struct sess *sess, void *buf,
+io_buffer_buf(struct sess *sess, void *buf,
size_t *bufpos, size_t buflen, const void *val, size_t valsz)
{
@@ -426,12 +426,12 @@ io_buffer_buf(struct sess *sess, void *buf,
* Converts "val" to LE prior to io_buffer_buf().
*/
void
-io_buffer_int(struct sess *sess, void *buf,
+io_buffer_int(struct sess *sess, void *buf,
size_t *bufpos, size_t buflen, int32_t val)
{
int32_t nv = htole32(val);
- io_buffer_buf(sess, buf, bufpos,
+ io_buffer_buf(sess, buf, bufpos,
buflen, &nv, sizeof(int32_t));
}
@@ -523,7 +523,7 @@ io_read_int(struct sess *sess, int fd, int32_t *val)
* Increases "bufpos" to the new position.
*/
void
-io_unbuffer_buf(struct sess *sess, const void *buf,
+io_unbuffer_buf(struct sess *sess, const void *buf,
size_t *bufpos, size_t bufsz, void *val, size_t valsz)
{
@@ -536,18 +536,18 @@ io_unbuffer_buf(struct sess *sess, const void *buf,
* Calls io_unbuffer_buf() and converts from LE.
*/
void
-io_unbuffer_int(struct sess *sess, const void *buf,
+io_unbuffer_int(struct sess *sess, const void *buf,
size_t *bufpos, size_t bufsz, int32_t *val)
{
int32_t oval;
- io_unbuffer_buf(sess, buf, bufpos,
+ io_unbuffer_buf(sess, buf, bufpos,
bufsz, &oval, sizeof(int32_t));
*val = le32toh(oval);
}
int
-io_unbuffer_size(struct sess *sess, const void *buf,
+io_unbuffer_size(struct sess *sess, const void *buf,
size_t *bufpos, size_t bufsz, size_t *val)
{
int32_t oval;
@@ -582,4 +582,3 @@ io_write_byte(struct sess *sess, int fd, uint8_t val)
}
return 1;
}
-
diff --git a/usr.bin/rsync/log.c b/usr.bin/rsync/log.c
index 093264e3bb4..08284fc83d2 100644
--- a/usr.bin/rsync/log.c
+++ b/usr.bin/rsync/log.c
@@ -1,4 +1,4 @@
-/* $Id: log.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: log.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
diff --git a/usr.bin/rsync/main.c b/usr.bin/rsync/main.c
index 871922f2c15..506c031ac01 100644
--- a/usr.bin/rsync/main.c
+++ b/usr.bin/rsync/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: main.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -284,8 +284,8 @@ int
main(int argc, char *argv[])
{
struct opts opts;
- pid_t child;
- int fds[2], flags, c, st;
+ pid_t child;
+ int fds[2], flags, c, st;
struct fargs *fargs;
struct option lopts[] = {
{ "delete", no_argument, &opts.del, 1 },
diff --git a/usr.bin/rsync/mkpath.c b/usr.bin/rsync/mkpath.c
index 8dc44e544b5..2555a81558b 100644
--- a/usr.bin/rsync/mkpath.c
+++ b/usr.bin/rsync/mkpath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkpath.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $OpenBSD: mkpath.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 1983, 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -74,4 +74,3 @@ mkpath(struct sess *sess, char *path)
return (0);
}
-
diff --git a/usr.bin/rsync/receiver.c b/usr.bin/rsync/receiver.c
index 8bc4779274e..594de55b641 100644
--- a/usr.bin/rsync/receiver.c
+++ b/usr.bin/rsync/receiver.c
@@ -1,4 +1,4 @@
-/* $Id: receiver.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: receiver.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -40,7 +40,7 @@ enum pfdt {
PFD__MAX
};
-/*
+/*
* Pledges: unveil, rpath, cpath, wpath, stdio, fattr.
* Pledges (dry-run): -cpath, -wpath, -fattr.
*/
@@ -52,10 +52,10 @@ rsync_receiver(struct sess *sess,
size_t i, flsz = 0, dflsz = 0, excl;
char *tofree;
int rc = 0, dfd = -1, phase = 0, c;
- int32_t ioerror;
+ int32_t ioerror;
struct pollfd pfd[PFD__MAX];
struct download *dl = NULL;
- struct upload *ul = NULL;
+ struct upload *ul = NULL;
mode_t oumask;
if (-1 == pledge("unveil rpath cpath wpath stdio fattr", NULL)) {
@@ -89,8 +89,8 @@ rsync_receiver(struct sess *sess,
if ( ! flist_recv(sess, fdin, &fl, &flsz)) {
ERRX1(sess, "flist_recv");
goto out;
- }
-
+ }
+
/* The IO error is sent after the file list. */
if ( ! io_read_int(sess, fdin, &ioerror)) {
@@ -152,7 +152,7 @@ rsync_receiver(struct sess *sess,
* unveil.
*/
- if (sess->opts->del &&
+ if (sess->opts->del &&
sess->opts->recursive &&
! flist_gen_dels(sess, root, &dfl, &dflsz, fl, flsz)) {
ERRX1(sess, "flist_gen_local");
@@ -193,7 +193,7 @@ rsync_receiver(struct sess *sess,
pfd[PFD_DOWNLOADER_IN].events = POLLIN;
pfd[PFD_SENDER_OUT].events = POLLOUT;
- ul = upload_alloc(sess, dfd, fdout,
+ ul = upload_alloc(sess, dfd, fdout,
CSUM_LENGTH_PHASE1, fl, flsz, oumask);
if (NULL == ul) {
ERRX1(sess, "upload_alloc");
@@ -212,9 +212,9 @@ rsync_receiver(struct sess *sess,
if (-1 == (c = poll(pfd, PFD__MAX, INFTIM))) {
ERR(sess, "poll");
goto out;
- }
+ }
- for (i = 0; i < PFD__MAX; i++)
+ for (i = 0; i < PFD__MAX; i++)
if (pfd[i].revents & (POLLERR|POLLNVAL)) {
ERRX(sess, "poll: bad fd");
goto out;
@@ -250,8 +250,8 @@ rsync_receiver(struct sess *sess,
if ((POLLIN & pfd[PFD_UPLOADER_IN].revents) ||
(POLLOUT & pfd[PFD_SENDER_OUT].revents)) {
- c = rsync_uploader(ul,
- &pfd[PFD_UPLOADER_IN].fd,
+ c = rsync_uploader(ul,
+ &pfd[PFD_UPLOADER_IN].fd,
sess, &pfd[PFD_SENDER_OUT].fd);
if (c < 0) {
ERRX1(sess, "rsync_uploader");
@@ -259,7 +259,7 @@ rsync_receiver(struct sess *sess,
}
}
- /*
+ /*
* We need to run the downloader when we either have
* read events from the sender or an asynchronous local
* open is ready.
@@ -268,9 +268,9 @@ rsync_receiver(struct sess *sess,
* messages, which will otherwise clog up the pipes.
*/
- if ((POLLIN & pfd[PFD_SENDER_IN].revents) ||
+ if ((POLLIN & pfd[PFD_SENDER_IN].revents) ||
(POLLIN & pfd[PFD_DOWNLOADER_IN].revents)) {
- c = rsync_downloader(dl, sess,
+ c = rsync_downloader(dl, sess,
&pfd[PFD_DOWNLOADER_IN].fd);
if (c < 0) {
ERRX1(sess, "rsync_downloader");
@@ -290,7 +290,7 @@ rsync_receiver(struct sess *sess,
* here we should bump our checksum length and
* go into the second phase.
*/
- }
+ }
}
/* Properly close us out by progressing through the phases. */
diff --git a/usr.bin/rsync/rsync.1 b/usr.bin/rsync/rsync.1
index 1a727ec776e..3a843467dce 100644
--- a/usr.bin/rsync/rsync.1
+++ b/usr.bin/rsync/rsync.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rsync.1,v 1.1 2019/02/10 23:18:28 benno Exp $
+.\" $OpenBSD: rsync.1,v 1.2 2019/02/10 23:24:14 benno Exp $
.\"
.\" Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
diff --git a/usr.bin/rsync/rsync.5 b/usr.bin/rsync/rsync.5
index 5c56bc25528..80bae255785 100644
--- a/usr.bin/rsync/rsync.5
+++ b/usr.bin/rsync/rsync.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rsync.5,v 1.1 2019/02/10 23:18:28 benno Exp $
+.\" $OpenBSD: rsync.5,v 1.2 2019/02/10 23:24:14 benno Exp $
.\"
.\" Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
diff --git a/usr.bin/rsync/rsyncd.5 b/usr.bin/rsync/rsyncd.5
index d2e18fbac2e..b5255948f38 100644
--- a/usr.bin/rsync/rsyncd.5
+++ b/usr.bin/rsync/rsyncd.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rsyncd.5,v 1.1 2019/02/10 23:18:28 benno Exp $
+.\" $OpenBSD: rsyncd.5,v 1.2 2019/02/10 23:24:14 benno Exp $
.\"
.\" Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
diff --git a/usr.bin/rsync/sender.c b/usr.bin/rsync/sender.c
index 362c6c93ecb..e8f2f8f5552 100644
--- a/usr.bin/rsync/sender.c
+++ b/usr.bin/rsync/sender.c
@@ -1,4 +1,4 @@
-/* $Id: sender.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: sender.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -65,20 +65,20 @@ rsync_sender(struct sess *sess, int fdin,
! io_write_int(sess, fdout, 0)) {
ERRX1(sess, "io_write_int");
goto out;
- }
+ }
- /*
+ /*
* Then the file list in any mode.
* Finally, the IO error (always zero for us).
*/
-
+
if ( ! flist_send(sess, fdin, fdout, fl, flsz)) {
ERRX1(sess, "flist_send");
goto out;
} else if ( ! io_write_int(sess, fdout, 0)) {
ERRX1(sess, "io_write_int");
goto out;
- }
+ }
/* Exit if we're the server with zero files. */
diff --git a/usr.bin/rsync/server.c b/usr.bin/rsync/server.c
index 8ce49f0867f..9a01d33e99e 100644
--- a/usr.bin/rsync/server.c
+++ b/usr.bin/rsync/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: server.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -54,7 +54,7 @@ int
rsync_server(const struct opts *opts, size_t argc, char *argv[])
{
struct sess sess;
- int fdin = STDIN_FILENO,
+ int fdin = STDIN_FILENO,
fdout = STDOUT_FILENO, c = 0;
memset(&sess, 0, sizeof(struct sess));
diff --git a/usr.bin/rsync/session.c b/usr.bin/rsync/session.c
index 8ba1ebb0d38..b8ac6e956f9 100644
--- a/usr.bin/rsync/session.c
+++ b/usr.bin/rsync/session.c
@@ -1,4 +1,4 @@
-/* $Id: session.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: session.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -29,7 +29,7 @@
* This only prints as the client.
*/
static void
-stats_log(struct sess *sess,
+stats_log(struct sess *sess,
uint64_t tread, uint64_t twrite, uint64_t tsize)
{
double tr, tw, ts;
@@ -89,8 +89,8 @@ stats_log(struct sess *sess,
"%.*lf %s sent, "
"%.*lf %s read, "
"%.*lf %s file size",
- trsz, tr, tru,
- twsz, tw, twu,
+ trsz, tr, tru,
+ twsz, tw, twu,
tssz, ts, tsu);
}
@@ -158,4 +158,3 @@ sess_stats_recv(struct sess *sess, int fd)
stats_log(sess, tr, tw, ts);
return 1;
}
-
diff --git a/usr.bin/rsync/socket.c b/usr.bin/rsync/socket.c
index ca28e172b17..c3fcd82db87 100644
--- a/usr.bin/rsync/socket.c
+++ b/usr.bin/rsync/socket.c
@@ -1,4 +1,4 @@
-/* $Id: socket.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: socket.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -38,8 +38,8 @@
* There can be many, IPV4 or IPV6.
*/
struct source {
- int family; /* PF_INET or PF_INET6 */
- char ip[INET6_ADDRSTRLEN]; /* formatted string */
+ int family; /* PF_INET or PF_INET6 */
+ char ip[INET6_ADDRSTRLEN]; /* formatted string */
struct sockaddr_storage sa; /* socket */
socklen_t salen; /* length of socket buffer */
};
@@ -179,7 +179,7 @@ inet_resolve(struct sess *sess, const char *host, size_t *sz)
&(((struct sockaddr_in6 *)sa)->sin6_addr),
src[i].ip, INET6_ADDRSTRLEN);
}
-
+
LOG2(sess, "DNS resolved: %s: %s", host, src[i].ip);
i++;
}
diff --git a/usr.bin/rsync/symlinks.c b/usr.bin/rsync/symlinks.c
index b85d3866fc9..18ef8cd2483 100644
--- a/usr.bin/rsync/symlinks.c
+++ b/usr.bin/rsync/symlinks.c
@@ -1,4 +1,4 @@
-/* $Id: symlinks.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: symlinks.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
diff --git a/usr.bin/rsync/uploader.c b/usr.bin/rsync/uploader.c
index 5017d6b2571..cee66f5d320 100644
--- a/usr.bin/rsync/uploader.c
+++ b/usr.bin/rsync/uploader.c
@@ -1,4 +1,4 @@
-/* $Id: uploader.c,v 1.1 2019/02/10 23:18:28 benno Exp $ */
+/* $Id: uploader.c,v 1.2 2019/02/10 23:24:14 benno Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -71,7 +71,7 @@ log_dir(struct sess *sess, const struct flist *f)
return;
sz = strlen(f->path);
assert(sz > 0);
- LOG1(sess, "%s%s", f->path,
+ LOG1(sess, "%s%s", f->path,
'/' == f->path[sz - 1] ? "" : "/");
}
@@ -119,7 +119,7 @@ init_blkset(struct blkset *p, off_t sz)
v = sqrt(sz);
p->len = ceil(v);
- /*
+ /*
* Always be a multiple of eight.
* There's no reason to do this, but rsync does.
*/
@@ -233,7 +233,7 @@ pre_link(struct upload *p, struct sess *sess)
return -1;
}
newlink = 1;
- }
+ }
free(b);
}
@@ -244,7 +244,7 @@ pre_link(struct upload *p, struct sess *sess)
tv[0].tv_nsec = 0;
tv[1].tv_sec = f->st.mtime;
tv[1].tv_nsec = 0;
- rc = utimensat(p->rootfd,
+ rc = utimensat(p->rootfd,
f->path, tv, AT_SYMLINK_NOFOLLOW);
if (-1 == rc) {
ERR(sess, "%s: utimensat", f->path);
@@ -252,8 +252,8 @@ pre_link(struct upload *p, struct sess *sess)
}
LOG4(sess, "%s: updated symlink date", f->path);
}
-
- /*
+
+ /*
* FIXME: if newlink is set because we updated the symlink, we
* want to carry over the permissions from the last.
*/
@@ -281,7 +281,7 @@ static int
pre_dir(const struct upload *p, struct sess *sess)
{
struct stat st;
- int rc;
+ int rc;
const struct flist *f;
f = &p->fl[p->idx];
@@ -304,7 +304,7 @@ pre_dir(const struct upload *p, struct sess *sess)
WARNX(sess, "%s: not a directory", f->path);
return -1;
} else if (-1 != rc) {
- /*
+ /*
* FIXME: we should fchmod the permissions here as well,
* as we may locally have shut down writing into the
* directory and that doesn't work.
@@ -361,13 +361,13 @@ post_dir(struct sess *sess, const struct upload *u, size_t idx)
return 0;
}
- /*
+ /*
* Update the modification time if we're a new directory *or* if
* we're preserving times and the time has changed.
*/
- if (u->newdir[idx] ||
- (sess->opts->preserve_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;
@@ -386,7 +386,7 @@ post_dir(struct sess *sess, const struct upload *u, size_t idx)
* preserving modes and it has changed.
*/
- if (u->newdir[idx] ||
+ if (u->newdir[idx] ||
(sess->opts->preserve_perms &&
st.st_mode != f->st.mode)) {
rc = fchmodat(u->rootfd, f->path, f->st.mode, 0);
@@ -446,7 +446,7 @@ pre_file(const struct upload *p, int *filefd, struct sess *sess)
* On success, upload_free() must be called with the allocated pointer.
*/
struct upload *
-upload_alloc(struct sess *sess, int rootfd, int fdout,
+upload_alloc(struct sess *sess, int rootfd, int fdout,
size_t clen, const struct flist *fl, size_t flsz, mode_t msk)
{
struct upload *p;
@@ -496,7 +496,7 @@ upload_free(struct upload *p)
* Otherwise returns <0, which is an error.
*/
int
-rsync_uploader(struct upload *u, int *fileinfd,
+rsync_uploader(struct upload *u, int *fileinfd,
struct sess *sess, int *fileoutfd)
{
struct blkset blk;
@@ -534,7 +534,7 @@ rsync_uploader(struct upload *u, int *fileinfd,
if (u->bufpos < u->bufsz) {
sz = MAX_CHUNK < (u->bufsz - u->bufpos) ?
MAX_CHUNK : (u->bufsz - u->bufpos);
- c = io_write_buf(sess, u->fdout,
+ c = io_write_buf(sess, u->fdout,
u->buf + u->bufpos, sz);
if (0 == c) {
ERRX1(sess, "io_write_nonblocking");
@@ -545,7 +545,7 @@ rsync_uploader(struct upload *u, int *fileinfd,
return 1;
}
- /*
+ /*
* Let the UPLOAD_FIND_NEXT state handle things if we
* finish, as we'll need to write a POLLOUT message and
* not have a writable descriptor yet.
@@ -583,7 +583,7 @@ rsync_uploader(struct upload *u, int *fileinfd,
break;
}
- /*
+ /*
* Whether we've finished writing files or not, we
* disable polling on the output channel.
*/
@@ -608,7 +608,7 @@ rsync_uploader(struct upload *u, int *fileinfd,
return 1;
}
- /*
+ /*
* If an input file is open, stat it and see if it's already up
* to date, in which case close it and go to the next one.
* Either way, we don't have a write channel open.
@@ -655,7 +655,7 @@ rsync_uploader(struct upload *u, int *fileinfd,
if (-1 != *fileinfd && st.st_size > 0) {
mapsz = st.st_size;
- map = mmap(NULL, mapsz,
+ map = mmap(NULL, mapsz,
PROT_READ, MAP_SHARED, *fileinfd, 0);
if (MAP_FAILED == map) {
WARN(sess, "%s: mmap", u->fl[u->idx].path);
@@ -678,7 +678,7 @@ rsync_uploader(struct upload *u, int *fileinfd,
offs = 0;
for (i = 0; i < blk.blksz; i++) {
- init_blk(&blk.blks[i],
+ init_blk(&blk.blks[i],
&blk, offs, i, map, sess);
offs += blk.len;
}
@@ -687,7 +687,7 @@ rsync_uploader(struct upload *u, int *fileinfd,
close(*fileinfd);
*fileinfd = -1;
LOG3(sess, "%s: mapped %jd B with %zu blocks",
- u->fl[u->idx].path, (intmax_t)blk.size,
+ u->fl[u->idx].path, (intmax_t)blk.size,
blk.blksz);
} else {
if (-1 != *fileinfd) {
@@ -702,13 +702,13 @@ rsync_uploader(struct upload *u, int *fileinfd,
/* Make sure the block metadata buffer is big enough. */
- u->bufsz =
+ u->bufsz =
sizeof(int32_t) + /* identifier */
sizeof(int32_t) + /* block count */
sizeof(int32_t) + /* block length */
sizeof(int32_t) + /* checksum length */
sizeof(int32_t) + /* block remainder */
- blk.blksz *
+ blk.blksz *
(sizeof(int32_t) + /* short checksum */
blk.csum); /* long checksum */
@@ -728,9 +728,9 @@ rsync_uploader(struct upload *u, int *fileinfd,
io_buffer_int(sess, u->buf, &pos, u->bufsz, blk.csum);
io_buffer_int(sess, u->buf, &pos, u->bufsz, blk.rem);
for (i = 0; i < blk.blksz; i++) {
- io_buffer_int(sess, u->buf, &pos, u->bufsz,
+ io_buffer_int(sess, u->buf, &pos, u->bufsz,
blk.blks[i].chksum_short);
- io_buffer_buf(sess, u->buf, &pos, u->bufsz,
+ io_buffer_buf(sess, u->buf, &pos, u->bufsz,
blk.blks[i].chksum_long, blk.csum);
}
assert(pos == u->bufsz);