Mandatory File Locking

Mark Haney mhaney at ercbroadband.org
Fri Nov 21 19:26:28 UTC 2008


test test wrote:
> 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.
> 
> 
> 
> OS: Ubuntu Hardy Heron 8.04
> 
> 
> 
> Scenario:
> 
> 1. Process A is super process (controller).
> 
> 2. Process B is normal process.
> 
> 3. *Process A and B are non-cooperating process, they simple don't know
> about other process existence and they are not interested in knowing it
> either.(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.
> 
> 
> 
> I used:
> 
> chmod g-x test
> 
> chmod g+s test
> 
> 

http://www.hackinglinuxexposed.com/articles/20030623.html

That was a quick google on file locking in Linux.  Are you coding these 
processes yourself?  I mean there are documented ways of locking files 
programmatically in linux as well.

Based on what you posted the file locking should work.  Are you saying 
it doesn't?





-- 
Frustra laborant quotquot se calculationibus fatigant pro inventione 
quadraturae circuli

Mark Haney
Sr. Systems Administrator
ERC Broadband
(828) 350-2415

Call (866) ERC-7110 for after hours support




More information about the ubuntu-users mailing list