Skip to contentSkip to conversation

mandatory locks and LOCK_MAND

DISCUSSION Michael Ganss 1 participant 1 message Apr 24, 2002 VFS

lore
Share & tools
lore
#0 lore raw

Hi,

I'm trying to get mandatory file locking to work. I don't want to use the mount option plus permission bits hack.
The only helpful document I could find (besides mandatory.txt in the kernel sources) was http://infradead.org/~willy/locking_manifesto.html
which describes "share modes":

"* Share modes. These are whole-file mandatory locks. No other process may open a file which would conflict with the Share Mode on the file. Use flock() with the %LOCK_MAND flag to set a Share Mode."

However, this doesn't work for me (kernel 2.4.17). /proc/locks shows the lock:

1: FLOCK MSNFS NONE 17653 03:05:44 0 EOF dfb6b458 c02eb928
dfb6bb30 000000
00 dfb6b464

but it doesn't seem to be enforced anywhere. other processes can still open(2), read(2), write(2). I've skimmed fs/locks.c and for locks_may_read() it says:

"*
N.B. this function is only ever called
* from knfsd and ownership of locks is never checked."

It seems to me, LOCK_MAND is not intended to be used outside the kernel. is this correct, or am I doing something wrong?

on the other hand, leases work as described.

regards

Signature · 13 lines
O&O Services GmbH - Delivering Value!

Michael Ganß

Am Borsigturm 48, 13507 Berlin, Germany
Tel: +49 30 43 03 43-50 Fax: -99
E-Mail: [email protected]
Web: http://www.oo-services.com/

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html