Re: Mandatory File Locking



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@xxxxxxxxxxxxxxxx>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@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Attachment: filelock.c
Description: Binary data

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users


Relevant Pages

  • Re: Mandatory File Locking
    ... I need to put a mandatory lock on /dev/fb0 in Linux OS. ... Based on what you posted the file locking should work. ...
    (Ubuntu)
  • [NT] File Locking and Security (Group Policy DoS on Windows 2000 Domains)
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... EXCLUSIVE lock on a file. ... file locking is only checked ... Windows, things are different. ...
    (Securiteam)
  • Re: Windoze 7?
    ... most people with infected machines actually ... Linux to do the same on them), I can sense when something is ... infallible install free Linux and every MS home machine (assuming ... the one with a weaker lock next to it. ...
    (uk.comp.sys.mac)
  • Thread Tests Fail During Build
    ... I'm trying to get SpamAssassin and Razor setup on my Linux server but I'm running to problems building some of the Perl modules. ... Running install for module Test::Simple ... Failed 5/5 tests, 0.00% okay ... lock can only be used on shared values at / ...
    (perl.beginners)
  • Re: semaphores between processes
    ... We're designing some software which has to lock access to ... This works well on Linux and Solaris, ... We then moved on to posix semaphores. ...
    (freebsd-hackers)