Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-28-2004, 07:21 AM   #1
Registered: Jul 2004
Posts: 72

Rep: Reputation: 15
calling sys_read inside sys_write returns number of bytes read as zero

Hi All,

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
original sys_write.
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);
	return returnValue;
After few hours of frustation, i am posting here to get some help.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom DSDT found, read 0 bytes! So what did I miss? Simon Bridge Ubuntu 0 11-29-2005 06:41 PM
how to know how many bytes can read from a descriptor? (C/C++) Thinking Programming 6 10-28-2005 12:46 PM
calling a c++ binary inside a perl script Blue_muppet Programming 3 08-28-2004 11:31 PM
Calculation of number of bytes submitted with form blampain Linux - Networking 6 03-30-2004 05:54 AM
Why Linux returns the device size for 1 block more when it could be read?? fa3a Programming 1 01-29-2004 06:23 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration