From 7a23c7fdfe82754bebecf82cdb7e1ecb44d6f23f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Mar 2018 16:41:42 +0100 Subject: copy: extend copy_bytes() a bit Optionally, when we copy between fds with simple read/write, let's return any remaining data we already read into the buffer if write fails. This is useful to allow callers to use the read data otherwise, perhaps implementing a different fallback for copying. --- src/basic/copy.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/basic/copy.h') diff --git a/src/basic/copy.h b/src/basic/copy.h index 880bd321cf..9ea1049f83 100644 --- a/src/basic/copy.h +++ b/src/basic/copy.h @@ -25,6 +25,9 @@ int copy_tree(const char *from, const char *to, uid_t override_uid, gid_t overri int copy_tree_at(int fdf, const char *from, int fdt, const char *to, uid_t override_uid, gid_t override_gid, CopyFlags copy_flags); int copy_directory_fd(int dirfd, const char *to, CopyFlags copy_flags); int copy_directory(const char *from, const char *to, CopyFlags copy_flags); -int copy_bytes(int fdf, int fdt, uint64_t max_bytes, CopyFlags copy_flags); +int copy_bytes_full(int fdf, int fdt, uint64_t max_bytes, CopyFlags copy_flags, void **ret_remains, size_t *ret_remains_size); +static inline int copy_bytes(int fdf, int fdt, uint64_t max_bytes, CopyFlags copy_flags) { + return copy_bytes_full(fdf, fdt, max_bytes, copy_flags, NULL, NULL); +} int copy_times(int fdf, int fdt); int copy_xattr(int fdf, int fdt); -- cgit v1.2.1