mirror of
https://github.com/systemd/systemd.git
synced 2025-02-21 05:57:34 +03:00
copy: make copy_bytes() support O_PATH fds
This commit is contained in:
parent
1dec1c6163
commit
e63d070373
@ -157,6 +157,7 @@ int copy_bytes_full(
|
||||
copy_progress_bytes_t progress,
|
||||
void *userdata) {
|
||||
|
||||
_cleanup_close_ int fdf_opened = -EBADF, fdt_opened = -EBADF;
|
||||
bool try_cfr = true, try_sendfile = true, try_splice = true, copied_something = false;
|
||||
int r, nonblock_pipe = -1;
|
||||
size_t m = SSIZE_MAX; /* that is the maximum that sendfile and c_f_r accept */
|
||||
@ -177,6 +178,13 @@ int copy_bytes_full(
|
||||
if (ret_remains_size)
|
||||
*ret_remains_size = 0;
|
||||
|
||||
fdf = fd_reopen_condition(fdf, O_CLOEXEC | O_NOCTTY | O_RDONLY, O_PATH, &fdf_opened);
|
||||
if (fdf < 0)
|
||||
return fdf;
|
||||
fdt = fd_reopen_condition(fdt, O_CLOEXEC | O_NOCTTY | O_RDWR, O_PATH, &fdt_opened);
|
||||
if (fdt < 0)
|
||||
return fdt;
|
||||
|
||||
/* Try btrfs reflinks first. This only works on regular, seekable files, hence let's check the file offsets of
|
||||
* source and destination first. */
|
||||
if ((copy_flags & COPY_REFLINK)) {
|
||||
|
@ -301,7 +301,7 @@ static void test_copy_bytes_regular_file_one(const char *src, bool try_reflink,
|
||||
|
||||
log_info("%s try_reflink=%s max_bytes=%" PRIu64, __func__, yes_no(try_reflink), max_bytes);
|
||||
|
||||
fd = open(src, O_RDONLY | O_CLOEXEC | O_NOCTTY);
|
||||
fd = open(src, O_CLOEXEC | O_PATH);
|
||||
assert_se(fd >= 0);
|
||||
|
||||
fd2 = mkostemp_safe(fn2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user