Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-05-2011, 04:29 AM   #16
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 234Reputation: 234Reputation: 234

Originally Posted by mopinion View Post
So.. maybe i should clearly state what my intent is. I am trying to block the open system call whenever it is invoked in order to stop files within a directory from being altered (written to, deleted, moved etc.) before a backup is made.
Therefore for example:
Forget about it - the idea is bad. Many things on Linux are represented as "files" (remember /proc?), so if you block "open", you'll break the entire system.

Use access rights to restrict file modification access.
Old 12-05-2011, 05:20 AM   #17
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
I think the easiest thing you can do is use lvm or a filesystem that has snapshots.

If this doesn't work for you, you can use fanotify to register for and listen to the filesystem events of your choosing on the files of your choosing. You can then block these events until you're done with them.

For those talking about system calls: I don't think you can write a module which will mess with an existing syscall. Instead you would need to patch the module/code which already handles it. For open(), this would probably be somewhere in vfs.

Last edited by Meson; 12-05-2011 at 05:35 AM.
Old 12-05-2011, 06:56 AM   #18
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,330

Rep: Reputation: 254Reputation: 254Reputation: 254
If itís just for your own applications: you can also use custom version of kernel calls, when you define them in a shared library which you load beforehand by setting LD_PRELOAD. Inside the replacement call to open(), you can check a variable (create a backup of the file if you want), and in either case forward the real call by calling the kernel function by number (not by name).

This is the way the queuing system Condor catches open() calls and route it to read a file on a different machine instead of open it locally.

You can check this page and this document (chapter 3.4).


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
how does java calls the system calls which are written in c babu198649 Linux - General 3 12-05-2011 04:40 AM
linux system calls rblampain Programming 3 02-25-2010 12:06 AM
Linux System Calls or Interupts Moaxam Linux - Software 1 05-03-2007 11:56 AM
LINUX System calls Jitin Programming 1 08-02-2006 09:47 PM
linux system calls blanny Programming 4 03-04-2006 01:15 AM > Forums > Non-*NIX Forums > Programming

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

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