internal: Add pread pwrite support in sys
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: I84c5e7f493afbb0894528f5d0986180b7109e170
diff --git a/internal/sys.cpp b/internal/sys.cpp
index 2e040ae..db843ac 100644
--- a/internal/sys.cpp
+++ b/internal/sys.cpp
@@ -50,6 +50,17 @@
return static_cast<int>(::read(fd, buf, count));
}
+int SysImpl::pread(int fd, void* buf, std::size_t count, off_t offset) const
+{
+ return static_cast<int>(::pread(fd, buf, count, offset));
+}
+
+int SysImpl::pwrite(int fd, const void* buf, std::size_t count,
+ off_t offset) const
+{
+ return static_cast<int>(::pwrite(fd, buf, count, offset));
+}
+
int SysImpl::close(int fd) const
{
return ::close(fd);
diff --git a/internal/sys.hpp b/internal/sys.hpp
index 265d251..41fb46b 100644
--- a/internal/sys.hpp
+++ b/internal/sys.hpp
@@ -28,6 +28,10 @@
virtual int open(const char* pathname, int flags) const = 0;
virtual int read(int fd, void* buf, std::size_t count) const = 0;
+ virtual int pread(int fd, void* buf, std::size_t count,
+ off_t offset) const = 0;
+ virtual int pwrite(int fd, const void* buf, std::size_t count,
+ off_t offset) const = 0;
virtual int close(int fd) const = 0;
virtual void* mmap(void* addr, std::size_t length, int prot, int flags,
int fd, off_t offset) const = 0;
@@ -48,6 +52,10 @@
public:
int open(const char* pathname, int flags) const override;
int read(int fd, void* buf, std::size_t count) const override;
+ int pread(int fd, void* buf, std::size_t count,
+ off_t offset) const override;
+ int pwrite(int fd, const void* buf, std::size_t count,
+ off_t offset) const override;
int close(int fd) const override;
void* mmap(void* addr, std::size_t length, int prot, int flags, int fd,
off_t offset) const override;