From: Waldemar Kozaczuk <[email protected]> Committer: WALDEMAR KOZACZUK <[email protected]> Branch: master
vfs: implement subset of copy_file_range() This patch implements subset of copy_file_range() needed by the GNU cp utility to function. The implementation delagates to sendfile() and accepts calls with off_out equal to 0 only. Signed-off-by: Waldemar Kozaczuk <[email protected]> --- diff --git a/fs/vfs/main.cc b/fs/vfs/main.cc --- a/fs/vfs/main.cc +++ b/fs/vfs/main.cc @@ -2345,6 +2345,27 @@ ssize_t sendfile(int out_fd, int in_fd, off_t *_offset, size_t count) #undef sendfile64 LFS64(sendfile); +extern "C" OSV_LIBC_API +ssize_t copy_file_range(int fd_in, off_t *off_in, + int fd_out, off_t *off_out, + size_t len, unsigned int flags) +{ + //Non-zero flags are rejected according to the manual + if (flags != 0) { + errno = EINVAL; + return -1; + } + //We do not support writing to a file at specified offset because + //we delegate to sendfile() which assumes current position of the output + //file + if (off_out) { + WARN("copy_file_range() does not support non-zero off_out\n"); + errno = EINVAL; + return -1; + } + return sendfile(fd_out, fd_in, off_in, len); +} + NO_SYS(OSV_LIBC_API int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)); OSV_LIBC_API -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000874b2a0613f1f44b%40google.com.
