internal: add read() method
Add the read() method to the internal syscall interface.
Change-Id: Iea2a137df5b6ba2085c7363ca150d4e4b8864048
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/internal/sys.cpp b/internal/sys.cpp
index b99a2f2..46c6642 100644
--- a/internal/sys.cpp
+++ b/internal/sys.cpp
@@ -29,6 +29,11 @@
return ::open(pathname, flags);
}
+int SysImpl::read(int fd, void* buf, std::size_t count) const
+{
+ return static_cast<int>(::read(fd, buf, count));
+}
+
int SysImpl::close(int fd) const
{
return ::close(fd);
diff --git a/internal/sys.hpp b/internal/sys.hpp
index 98b6e5c..2975b8c 100644
--- a/internal/sys.hpp
+++ b/internal/sys.hpp
@@ -26,6 +26,7 @@
virtual ~Sys() = default;
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 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;
@@ -44,6 +45,7 @@
{
public:
int open(const char* pathname, int flags) const override;
+ int read(int fd, void* buf, std::size_t count) 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;
diff --git a/test/internal_sys_mock.hpp b/test/internal_sys_mock.hpp
index 63c0b0c..fc98561 100644
--- a/test/internal_sys_mock.hpp
+++ b/test/internal_sys_mock.hpp
@@ -15,6 +15,7 @@
virtual ~InternalSysMock() = default;
MOCK_CONST_METHOD2(open, int(const char*, int));
+ MOCK_CONST_METHOD3(read, int(int, void*, std::size_t));
MOCK_CONST_METHOD1(close, int(int));
MOCK_CONST_METHOD6(mmap, void*(void*, std::size_t, int, int, int, off_t));
MOCK_CONST_METHOD2(munmap, int(void*, std::size_t));