LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-22-2006, 05:18 AM   #1
barunparichha
Member
 
Registered: Jun 2006
Location: Bangalore,india
Distribution: Linux(Redhat,fedora,suse,ubantu), Solaris (s8/s9/s10/nevada/open-solaris)
Posts: 303

Rep: Reputation: 32
calling system calls READ WRITE without any OPEN


sir,
i am traping some of the system calls for my application by preoading concept.
Rightnow i am traping READ ,WRITE ,CLOSE ,OPEN .
What i found after my execution is somewhat interesting. It calls READ,WRITE,CLOSE system calls without any call to OPEN.
How is the file descriptor used in READ,WRITE,CLOSE created without calling to OPEN ?
I suspect it might be using socket() system call instead of OPEN.

With thanks in advance,
barun
 
Old 06-24-2006, 08:12 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,660
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Absent specific examples it's hard to say, but I daresay that the OPEN call is out there somewhere. Check the underlying source-code...
 
Old 06-28-2006, 01:11 PM   #3
barunparichha
Member
 
Registered: Jun 2006
Location: Bangalore,india
Distribution: Linux(Redhat,fedora,suse,ubantu), Solaris (s8/s9/s10/nevada/open-solaris)
Posts: 303

Original Poster
Rep: Reputation: 32
Here goes my code. Here i am preloading the open() system call and printing that Open() is called with the process-id.

int open(const char* path, int flags) {
char * error;
char str[81];
void * handle;
int ret=0;
pid_t pid;

int (*original) (const char *,int);

handle=dlopen("/lib/libc-2.3.3.so",RTLD_LAZY);
if(handle==NULL) {
error=dlerror();
printf("\n error in dlopen : %s",error);
exit(0);
}

original=dlsym(handle,"open");
if( (error=dlerror()) !=NULL) {
printf("error in dlsym : %s",error);
exit(0);
}

ret=original(path,flags);
if(strcmp(path,"/dev/usb/lp0")==0) {
printf("\nOPEN : %s\n", path);
printf("Fd is %d\n", ret);
}
return(ret);
}


Now figure out the problem .
 
  


Reply



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
Read Write for NTFS file system geeedeee Linux - Laptop and Netbook 8 06-05-2006 07:41 PM
creating a read/write file system with kickstart triley Linux - General 1 12-29-2005 02:36 AM
How to Write Own Shell in Unix using System Calls? indian Programming 2 08-05-2004 04:06 AM
Open office read only, K-write read/write mode lwtvh Linux - Newbie 1 07-19-2003 11:33 AM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 07:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:02 AM.

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
Open Source Consulting | Domain Registration