version 1.29.2.1, 2021/11/09 13:40:41 |
version 1.30, 2021/10/22 11:10:34 |
|
|
*/ |
*/ |
static int |
static int |
check_file(int rootfd, const struct flist *f, struct stat *st) |
check_file(int rootfd, const struct flist *f, struct stat *st) |
{ |
{ |
if (fstatat(rootfd, f->path, st, AT_SYMLINK_NOFOLLOW) == -1) { |
if (fstatat(rootfd, f->path, st, AT_SYMLINK_NOFOLLOW) == -1) { |
if (errno == ENOENT) |
if (errno == ENOENT) |
return 3; |
return 3; |
|
|
return 0; |
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 |
* For non dry-run cases, we'll write the acknowledgement later |
* in the rsync_uploader() function. |
* in the rsync_uploader() function. |
|
|
const char *root = sess->opts->basedir[i]; |
const char *root = sess->opts->basedir[i]; |
int dfd, x; |
int dfd, x; |
|
|
dfd = openat(p->rootfd, root, O_RDONLY | O_DIRECTORY); |
dfd = openat(p->rootfd, root, O_RDONLY | O_DIRECTORY, 0); |
if (dfd == -1) |
if (dfd == -1) |
err(ERR_FILE_IO, "%s: openat", root); |
err(ERR_FILE_IO, "%s: openat", root); |
x = check_file(dfd, f, &st); |
x = check_file(dfd, f, &st); |
|
|
} |
} |
|
|
*size = st.st_size; |
*size = st.st_size; |
*filefd = openat(p->rootfd, f->path, O_RDONLY | O_NOFOLLOW); |
*filefd = openat(p->rootfd, f->path, O_RDONLY | O_NOFOLLOW, 0); |
if (*filefd == -1 && errno != ENOENT) { |
if (*filefd == -1 && errno != ENOENT) { |
ERR("%s: openat", f->path); |
ERR("%s: openat", f->path); |
return -1; |
return -1; |
|
|
/* Make sure the block metadata buffer is big enough. */ |
/* Make sure the block metadata buffer is big enough. */ |
|
|
u->bufsz = |
u->bufsz = |
sizeof(int32_t) + /* identifier */ |
sizeof(int32_t) + /* identifier */ |
sizeof(int32_t) + /* block count */ |
sizeof(int32_t) + /* block count */ |
sizeof(int32_t) + /* block length */ |
sizeof(int32_t) + /* block length */ |
sizeof(int32_t) + /* checksum length */ |
sizeof(int32_t) + /* checksum length */ |
sizeof(int32_t) + /* block remainder */ |
sizeof(int32_t) + /* block remainder */ |
blk.blksz * |
blk.blksz * |
(sizeof(int32_t) + /* short checksum */ |
(sizeof(int32_t) + /* short checksum */ |
blk.csum); /* long checksum */ |
blk.csum); /* long checksum */ |
|
|
if (u->bufsz > u->bufmax) { |
if (u->bufsz > u->bufmax) { |
if ((bufp = realloc(u->buf, u->bufsz)) == NULL) { |
if ((bufp = realloc(u->buf, u->bufsz)) == NULL) { |