diff --git a/src/posix/handlers.hpp b/src/posix/handlers.hpp index 6f994c28f..fd1aeed3e 100644 --- a/src/posix/handlers.hpp +++ b/src/posix/handlers.hpp @@ -8,6 +8,7 @@ #include "handlers/access.hpp" #include "handlers/chdir.hpp" #include "handlers/close.hpp" +#include "handlers/copy_file_range.hpp" #include "handlers/dup.hpp" #include "handlers/execve.hpp" #include "handlers/exit.hpp" diff --git a/src/posix/handlers/copy_file_range.hpp b/src/posix/handlers/copy_file_range.hpp new file mode 100644 index 000000000..a309cd36c --- /dev/null +++ b/src/posix/handlers/copy_file_range.hpp @@ -0,0 +1,21 @@ +#ifndef CAPIO_COPY_FILE_RANGE_HPP +#define CAPIO_COPY_FILE_RANGE_HPP +int copy_file_range_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, + long *result) { + auto tid = static_cast(syscall_no_intercept(SYS_gettid)); + auto fd_in = static_cast(arg0); + auto fd_out = static_cast(arg2); + auto off_in = static_cast(arg1); + auto off_out = static_cast(arg3); + START_LOG(tid, "call()"); + + // TODO: support in memory read / write + if (exists_capio_fd(fd_in)) { + auto path = get_capio_fd_path(fd_in); + LOG("Handling copy for source file: %s", path.c_str()); + read_request_cache_fs->read_request(path, off_in, tid, fd_in); + } + + return CAPIO_POSIX_SYSCALL_SKIP; +} +#endif // CAPIO_COPY_FILE_RANGE_HPP diff --git a/src/posix/libcapio_posix.cpp b/src/posix/libcapio_posix.cpp index 0e055fad2..131cb631b 100644 --- a/src/posix/libcapio_posix.cpp +++ b/src/posix/libcapio_posix.cpp @@ -187,6 +187,9 @@ static constexpr long CAPIO_NR_SYSCALLS = 1 + std::max({ #endif #ifdef SYS_writev SYS_writev, +#endif +#ifdef SYS_copy_file_range + SYS_copy_file_range, #endif }); @@ -356,6 +359,9 @@ static constexpr std::array build_syscall_table( #ifdef SYS_writev _syscallTable[SYS_writev] = writev_handler; #endif +#ifdef SYS_copy_file_range + _syscallTable[SYS_copy_file_range] = copy_file_range_handler; +#endif return _syscallTable; }