I am intercepting sys_write system call and within my_sys_write i will call the original syswrite.
Before calling the original sys_write, i have to get the contents of the file which will be replaced
by the current write.
So i open a new file descriptor inside my_sys_write and read the current buffer before calling the
I have a problem in reading the current buffer using sys_read which returns zero .
I am giving the relevant code below
ssize_t my_sys_write(unsigned int fd, const char * buf, size_t count)
// Get the name of absolute name from file descritpor
// calling the sys_open to get a new handle for reading
int openForRead = OriginalSysOpen(absoluteFileName,O_RDONLY,0777);
// calling sys_read and storing the contents in the tmpBuf, bytesRead always return zero
int bytesRead = OriginalSysRead(openForRead,tmpBuf, count );
printk(" OPENFILEHANDLE %d BYTESREAD %d \n", openForRead,bytesRead);
int returnValue = OriginalSysWrite(fd,buf,count);
After few hours of frustation, i am posting here to get some help.