Loading ifs/include/preload/passthrough.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -48,9 +48,12 @@ extern void* libc_puts; extern void* libc_write; extern void* libc_pwrite; extern void* libc_pwrite64; extern void* libc_writev; extern void* libc_read; extern void* libc_pread; extern void* libc_pread64; extern void* libc_readv; extern void* libc_lseek; extern void* libc_lseek64; Loading ifs/src/preload/intcp_functions.cpp +47 −0 Original line number Diff line number Diff line Loading @@ -520,6 +520,53 @@ ssize_t pwrite64(int fd, const void* buf, size_t count, __off64_t offset) { return (reinterpret_cast<decltype(&pwrite64)>(libc_pwrite64))(fd, buf, count, offset); } ssize_t writev(int fd, const struct iovec *iov, int iovcnt) { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { auto adafs_fd = CTX->file_map()->get(fd); auto pos = adafs_fd->pos(); // retrieve the current offset ssize_t written = 0; ssize_t ret; for (int i = 0; i < iovcnt; ++i){ auto buf = (iov+i)->iov_base; auto count = (iov+i)->iov_len; ret = adafs_pwrite_ws(fd, buf, count, pos); if(ret == -1) { break; } written += ret; pos += ret; if(static_cast<size_t>(ret) < count){ break; } } if(written == 0){ return -1; } adafs_fd->pos(pos); return written; } } return (reinterpret_cast<decltype(&writev)>(libc_writev))(fd, iov, iovcnt); } ssize_t readv(int fd, const struct iovec *iov, int iovcnt) { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { CTX->log()->error("{}() NOT SUPPORTED", __func__); errno = ENOTSUP; return -1; } } return (reinterpret_cast<decltype(&readv)>(libc_readv))(fd, iov, iovcnt); } ssize_t read(int fd, void* buf, size_t count) { init_passthrough_if_needed(); if(CTX->initialized()) { Loading ifs/src/preload/passthrough.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -52,9 +52,12 @@ void* libc_puts; void* libc_write; void* libc_pwrite; void* libc_pwrite64; void* libc_writev; void* libc_read; void* libc_pread; void* libc_pread64; void* libc_readv; void* libc_lseek; void* libc_lseek64; Loading Loading @@ -126,9 +129,12 @@ void init_passthrough_() { libc_write = dlsym(libc, "write"); libc_pwrite = dlsym(libc, "pwrite"); libc_pwrite64 = dlsym(libc, "pwrite64"); libc_writev = dlsym(libc, "writev"); libc_read = dlsym(libc, "read"); libc_pread = dlsym(libc, "pread"); libc_pread64 = dlsym(libc, "pread64"); libc_readv = dlsym(libc, "readv"); libc_lseek = dlsym(libc, "lseek"); libc_lseek64 = dlsym(libc, "lseek64"); Loading Loading
ifs/include/preload/passthrough.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -48,9 +48,12 @@ extern void* libc_puts; extern void* libc_write; extern void* libc_pwrite; extern void* libc_pwrite64; extern void* libc_writev; extern void* libc_read; extern void* libc_pread; extern void* libc_pread64; extern void* libc_readv; extern void* libc_lseek; extern void* libc_lseek64; Loading
ifs/src/preload/intcp_functions.cpp +47 −0 Original line number Diff line number Diff line Loading @@ -520,6 +520,53 @@ ssize_t pwrite64(int fd, const void* buf, size_t count, __off64_t offset) { return (reinterpret_cast<decltype(&pwrite64)>(libc_pwrite64))(fd, buf, count, offset); } ssize_t writev(int fd, const struct iovec *iov, int iovcnt) { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { auto adafs_fd = CTX->file_map()->get(fd); auto pos = adafs_fd->pos(); // retrieve the current offset ssize_t written = 0; ssize_t ret; for (int i = 0; i < iovcnt; ++i){ auto buf = (iov+i)->iov_base; auto count = (iov+i)->iov_len; ret = adafs_pwrite_ws(fd, buf, count, pos); if(ret == -1) { break; } written += ret; pos += ret; if(static_cast<size_t>(ret) < count){ break; } } if(written == 0){ return -1; } adafs_fd->pos(pos); return written; } } return (reinterpret_cast<decltype(&writev)>(libc_writev))(fd, iov, iovcnt); } ssize_t readv(int fd, const struct iovec *iov, int iovcnt) { init_passthrough_if_needed(); if(CTX->initialized()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { CTX->log()->error("{}() NOT SUPPORTED", __func__); errno = ENOTSUP; return -1; } } return (reinterpret_cast<decltype(&readv)>(libc_readv))(fd, iov, iovcnt); } ssize_t read(int fd, void* buf, size_t count) { init_passthrough_if_needed(); if(CTX->initialized()) { Loading
ifs/src/preload/passthrough.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -52,9 +52,12 @@ void* libc_puts; void* libc_write; void* libc_pwrite; void* libc_pwrite64; void* libc_writev; void* libc_read; void* libc_pread; void* libc_pread64; void* libc_readv; void* libc_lseek; void* libc_lseek64; Loading Loading @@ -126,9 +129,12 @@ void init_passthrough_() { libc_write = dlsym(libc, "write"); libc_pwrite = dlsym(libc, "pwrite"); libc_pwrite64 = dlsym(libc, "pwrite64"); libc_writev = dlsym(libc, "writev"); libc_read = dlsym(libc, "read"); libc_pread = dlsym(libc, "pread"); libc_pread64 = dlsym(libc, "pread64"); libc_readv = dlsym(libc, "readv"); libc_lseek = dlsym(libc, "lseek"); libc_lseek64 = dlsym(libc, "lseek64"); Loading