X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=io_uring_engine.cpp;h=63a3af78a86256ad4469443e6f872b4f890a43bc;hb=fd6198891d6fd9642effc0843fef6f23b991af3e;hp=70497a44cb122acf501d52c7062db124e6551e9d;hpb=3c481c94adcbd3d0aa3a9767129664d7253cf189;p=plocate diff --git a/io_uring_engine.cpp b/io_uring_engine.cpp index 70497a4..63a3af7 100644 --- a/io_uring_engine.cpp +++ b/io_uring_engine.cpp @@ -7,6 +7,7 @@ #ifndef WITHOUT_URING #include #endif +#include "complete_pread.h" #include "dprintf.h" #include "io_uring_engine.h" @@ -45,7 +46,7 @@ IOUringEngine::IOUringEngine(size_t slop_bytes) #endif } -void IOUringEngine::submit_stat(const char *path, std::function cb) +void IOUringEngine::submit_stat(const char *path [[maybe_unused]], std::function cb [[maybe_unused]]) { assert(supports_stat); @@ -114,7 +115,7 @@ void IOUringEngine::submit_read_internal(io_uring_sqe *sqe, int fd, size_t len, ++pending_reads; } -void IOUringEngine::submit_stat_internal(io_uring_sqe *sqe, char *path, std::function cb) +void IOUringEngine::submit_stat_internal(io_uring_sqe *sqe, char *path, std::function cb) { PendingRead *pending = new PendingRead; pending->op = OP_STAT; @@ -122,7 +123,7 @@ void IOUringEngine::submit_stat_internal(io_uring_sqe *sqe, char *path, std::fun pending->stat.pathname = path; pending->stat.buf = new struct statx; - io_uring_prep_statx(sqe, /*fd=*/-1, pending->stat.pathname, AT_STATX_SYNC_AS_STAT, STATX_MODE, pending->stat.buf); + io_uring_prep_statx(sqe, /*fd=*/-1, pending->stat.pathname, AT_STATX_SYNC_AS_STAT | AT_SYMLINK_NOFOLLOW, STATX_MODE, pending->stat.buf); io_uring_sqe_set_data(sqe, pending); ++pending_reads; } @@ -165,7 +166,7 @@ void IOUringEngine::finish() --pending_reads; size_t old_pending_reads = pending_reads; - pending->stat_cb(); + pending->stat_cb(cqe->res == 0); free(pending->stat.pathname); delete pending->stat.buf; delete pending; @@ -247,20 +248,3 @@ void IOUringEngine::finish() } #endif } - -void complete_pread(int fd, void *ptr, size_t len, off_t offset) -{ - while (len > 0) { - ssize_t ret = pread(fd, ptr, len, offset); - if (ret == -1 && errno == EINTR) { - continue; - } - if (ret <= 0) { - perror("pread"); - exit(1); - } - ptr = reinterpret_cast(ptr) + ret; - len -= ret; - offset -= ret; - } -}