sdm: Add sys wrappers for read, write, eventfd system calls

Add function pointers for read, write, and eventfd in Sys
wrapper and call these instead of directly calling system calls.

CRs-Fixed: 814136
Change-Id: I9964df85be2f6eaa83371b71971c642a768830f8
diff --git a/sdm/include/utils/sys.h b/sdm/include/utils/sys.h
index dc45696..ed9b75c 100644
--- a/sdm/include/utils/sys.h
+++ b/sdm/include/utils/sys.h
@@ -25,6 +25,8 @@
 #ifndef __SYS_H__
 #define __SYS_H__
 
+#include <sys/eventfd.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <poll.h>
@@ -46,6 +48,9 @@
   typedef ssize_t (*getline)(char **lineptr, size_t *linelen, FILE *stream);
   typedef int (*pthread_cancel)(pthread_t thread);
   typedef int (*dup)(int fd);
+  typedef ssize_t (*read)(int, void *, size_t);
+  typedef ssize_t (*write)(int, const void *, size_t);
+  typedef int (*eventfd)(unsigned int, int);
 
   static ioctl ioctl_;
   static open open_;
@@ -58,6 +63,9 @@
   static getline getline_;
   static pthread_cancel pthread_cancel_;
   static dup dup_;
+  static read read_;
+  static write write_;
+  static eventfd eventfd_;
 };
 
 }  // namespace sdm
diff --git a/sdm/libs/utils/sys.cpp b/sdm/libs/utils/sys.cpp
index ff66fcf..a622b9e 100644
--- a/sdm/libs/utils/sys.cpp
+++ b/sdm/libs/utils/sys.cpp
@@ -54,6 +54,9 @@
 Sys::getline Sys::getline_ = ::getline;
 Sys::pthread_cancel Sys::pthread_cancel_ = PthreadCancel;
 Sys::dup Sys::dup_ = ::dup;
+Sys::read Sys::read_ = ::read;
+Sys::write Sys::write_ = ::write;
+Sys::eventfd Sys::eventfd_ = ::eventfd;
 
 #else
 
@@ -68,6 +71,9 @@
 extern int virtual_fclose(FILE* fileptr);
 extern ssize_t virtual_getline(char **lineptr, size_t *linelen, FILE *stream);
 extern int virtual_dup(int fd);
+extern ssize_t virtual_read(int fd, void *data, size_t count);
+extern ssize_t virtual_write(int fd, const void *data, size_t count);
+extern int virtual_eventfd(unsigned int initval, int flags);
 
 Sys::ioctl Sys::ioctl_ = virtual_ioctl;
 Sys::open Sys::open_ = virtual_open;
@@ -80,6 +86,9 @@
 Sys::getline Sys::getline_ = virtual_getline;
 Sys::pthread_cancel Sys::pthread_cancel_ = ::pthread_cancel;
 Sys::dup Sys::dup_ = virtual_dup;
+Sys::read Sys::read_ = virtual_read;
+Sys::write Sys::write_ = virtual_write;
+Sys::eventfd Sys::eventfd_ = virtual_eventfd;
 
 #endif  // SDM_VIRTUAL_DRIVER