Mandatory File Locking

test test fileuploadoct08 at gmail.com
Fri Nov 21 19:41:26 UTC 2008


Yeah it should work supposedly but its not working. For reference I'm
attaching a sample file may be I am doing something very wrong.
I make executable of attached code. Then run one instance on terminal & 2nd
on another terminal.
Executable on 2nd terminal is able to write in the file.


Regards,
~Nishant

On Sat, Nov 22, 2008 at 12:56 AM, Mark Haney <mhaney at ercbroadband.org>wrote:

> 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
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20081122/fa707db0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filelock.c
Type: application/octet-stream
Size: 1581 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20081122/fa707db0/attachment.obj>


More information about the ubuntu-users mailing list