LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-21-2008, 11:09 AM   #1
nightwatchman
LQ Newbie
 
Registered: Nov 2008
Posts: 3

Rep: Reputation: 0
Mandatory file locking


Hello,

I need to put a mandatory lock on /dev/fb0 (presently any file) in Linux OS. But in actual scenario it will be a device file.

Scenario:
1. Process A is super process
2. Process B is normal process.
3. Process A and B are non-cooperating process (So, advisory locking is out of scope).
4. At particular instance Process B is accessing /dev/fb0.
5. Now, Process A wants access to it.
6. Process A locks /dev/fb0
7. It can hold the lock as long it wants & in any case process B cannot write anything to it. (It’s better if B cannot read the contents also).

I also changed permissions of directory and lock file.

directory:
drwxr-Sr-x 2 ists ists 4096 2008-11-21 11:20 test

file to be locked:
-rw-r-Sr-- 1 ists ists 15 2008-11-21 09:32 lock.txt

uname -a:
Linux ists-desktop 2.6.24-21-generic #1 SMP Tue Oct 21 23:43:45 UTC 2008 i686 GNU/Linux

Please help me how to achieve above or what all I need to do it.
I am really stuck.

Regards,
~Nick
 
Old 11-21-2008, 11:41 AM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Take a look at the kernel documentation. Documentation/filesystems/mandatory-locking.txt. Once you set the proper file permissions you can use flock or lockf to apply the mandatory lock.
 
  


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
Vsftpd and File Locking amanset Linux - Server 3 10-01-2008 10:32 AM
Mandatory Locking Kernel programmer Linux - Software 3 07-28-2006 05:21 AM
Mandatory Locking Kernel programmer Linux - Kernel 1 07-28-2006 05:10 AM
locking a usage policy file/ftp file permissions gbow Linux - Newbie 0 02-16-2004 05:35 AM
python; file locking TheLinuxDuck Programming 22 08-05-2003 05:47 PM

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

All times are GMT -5. The time now is 06:43 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
Open Source Consulting | Domain Registration