LinuxQuestions.org
Review your favorite Linux distribution.
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 12-05-2011, 03:29 AM   #16
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 234Reputation: 234Reputation: 234

Quote:
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, 04:20 AM   #17
Meson
Member
 
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 04:35 AM.
 
Old 12-05-2011, 05:56 AM   #18
Reuti
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).
 
  


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

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

All times are GMT -5. The time now is 01:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration