LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-16-2008, 03:21 AM   #1
linuxdoniv
Member
 
Registered: Mar 2008
Posts: 63

Rep: Reputation: 15
how can a daemon get notified when a system call is made


Hi ,

I want to write a daemon which would do some action whenever a open/ create system call is made.

could anybody help me about this.

Thanks in advance..
 
Old 07-16-2008, 03:21 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
You mean open/creat from your own programs, or any process on the system ?
 
Old 07-16-2008, 03:28 AM   #3
linuxdoniv
Member
 
Registered: Mar 2008
Posts: 63

Original Poster
Rep: Reputation: 15
Daemon should get a signal when any process on the system makes the open/ create system call.

BR,
 
Old 07-16-2008, 04:27 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
The strace utility can attach to any running process and log the syscalls the process calls. By reading its sources you can probably find out how this is done.

Logging any (instead of selected processes) syscall that happens on an entire system may not be possible (or very difficult/intrusive) the strace-way (i.e. without an special kernel module). It seems that is exactly what this software did to be able to track any syscall. I suggest trying to read its sources, or just use it.

Hope this helps
 
Old 07-16-2008, 05:48 AM   #5
linuxdoniv
Member
 
Registered: Mar 2008
Posts: 63

Original Poster
Rep: Reputation: 15
Thanks for the input..
 
Old 07-16-2008, 06:20 AM   #6
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
selinux, auditd, lsm?
 
Old 07-16-2008, 08:12 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by jcookeman View Post
selinux, auditd, lsm?
LSM stands for "Linux Security Modules" framework and is equal to say the "Netfilter" framework or "DBUS" in the way that other applications may use it. In the case of the LSM two well-known "users" are SE-Linux and GRSecurity. Auditd, the audit daemon, allows you to maintain a (plaintext) database of rules with which to track for instance system call usage. However just like the previous Dnotify and current Inotify implementation it has a usability issue. You can not set a watch ("-w") on a directory and expect system calls to be monitored recursively, you'll have to set a watch for each file. You could combine things and set watches for static files in system directories where changes are not expected (OK, that depends...) and use Inotify for directories with volatile contents.



Quote:
Originally Posted by Hko View Post
Logging any (instead of selected processes) syscall that happens on an entire system may not be possible (or very difficult/intrusive) the strace-way (i.e. without an special kernel module). It seems that is exactly what this software did to be able to track any syscall.
SysCallTrack was developed for the 2.4 kernel and never ported to 2.6. Unfortunate because it was very easy to work with. Current 2.6 kernels do have Kprobes builtin meaning you can use SystemTap or else try LTTng, LTTV, LKST. Other options to intercept syscalls could use something LD_PRELOADed or a kernel module, but since the OP doesn't provide any details it'll be hard to guesstimate what will be the "way bestest" option...
 
  


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
How can i make centos 4.5's system call using vDSO(call *%gs:0x10) instead of int80 tclwp Red Hat 3 08-06-2007 12:07 AM
How do I include my own system call in file system driver kgp Linux - Kernel 3 06-06-2007 10:41 AM
Adding more swap made system hangs ivanatora Linux - General 6 11-22-2006 03:50 PM
Calling a system call from a system call? Loc_8 Programming 0 09-16-2006 04:21 PM
how to call xdialog from a daemon dscherry Linux - Software 0 09-20-2003 12:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:19 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