LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 08-28-2004, 08:21 AM   #1
appas
Member
 
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

Code:
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);
	OriginalSysClose(openForRead);
	int returnValue = OriginalSysWrite(fd,buf,count);
	return returnValue;
}
After few hours of frustation, i am posting here to get some help.
 
  


Reply


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 07:41 PM
how to know how many bytes can read from a descriptor? (C/C++) Thinking Programming 6 10-28-2005 01:46 PM
calling a c++ binary inside a perl script Blue_muppet Programming 3 08-29-2004 12:31 AM
Calculation of number of bytes submitted with form blampain Linux - Networking 6 03-30-2004 06:54 AM
Why Linux returns the device size for 1 block more when it could be read?? fa3a Programming 1 01-29-2004 07:23 AM


All times are GMT -5. The time now is 11:54 PM.

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