Re: WARNING: smbfs and locking -- POSIX v. CIFS locking, and how DOS doesn't do CIFS locking (bad things man)

Bart Oldeman
2003-02-11T00:31:25Z

On Mon, 10 Feb 2003, Bryan J. Smith wrote:

> > NFS *does* support locking though.
>
> Yes, and it does it in a way that is far more "DOS-like" -- one write lock per file.

there are still some differences between POSIX and DOS locks though:
DOS has 6 kinds of locks:

* COMPATIBILITY
* DENY_NONE
* DENY_READ
* DENY_WRITE
* DENY_ALL
* exclusive region locking

where POSIX only has two:
* shared region locking (read locks)
* exclusive region locking (write locks)

DOSEMU emulates DENY_WRITE using a shared lock and DENY_ALL/DENY_READ
using an exclusive lock if the file is opened r/w or w/o or a shared lock
if the file is opened r/o. The other modes don't cause a lock; the code
only checks if locks already exist.

File locking is emulated by either locking the whole file region or one
byte at 0x7fffffff (without large file system support) or at 0x100000000
(with large file system support).

Also, without LFS the DOS unsigned 32bit locks need to be mapped into
positive 31bit signed numbers, which is what the magic borrowed from the
Samba project does. But it's much better not having to do that if we can
and that's why I added the LFS support (63 bits to be able to access 32!).

Bart