[Samba] Locking between GNU/Linux and Microsoft Windows

Freddy Spierenburg freddy at dusktilldawn.nl
Mon Feb 17 16:45:37 GMT 2003


Hi Jeremy,

On Wed, Feb 12, 2003 at 06:31:06PM +0000, jra at dp.samba.org wrote:
> How does Clipper on Linux do locking ?
access("/home/freddy/tmp/clipper.locking/freddy.dbf", F_OK) = 0
open("/home/freddy/tmp/clipper.locking/freddy.dbf", O_RDWR) = 3
fcntl64(0x3, 0x6, 0xbfffeab0, 0x3)      = 0
ioctl(3, 0xc0286e04, 0xbfffea40)        = -1 ENOTTY (Inappropriate ioctl for device)
fstat64(3, {st_mode=S_IFREG|0644, st_size=1639, ...}) = 0
mmap2(NULL, 1639, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x40018000
ioctl(3, 0xc0286e04, 0xbfffea00)        = -1 ENOTTY (Inappropriate ioctl for device)
fcntl64(0x3, 0x6, 0xbfffeac0, 0x3)      = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 9), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40019000

It seems to me it's 

> Remember, doing EXCLUSIVE in Windows Clipper code may use share
> modes to "lock" a file, not byte ranges. The Linux kernel has
> no such concept as share modes, and so will probably use byte
> ranges instead.
Hmmmm, I can see. Well, the EXCLUSIVE lock is not that necessary.
It was just a test of mine.
I'll try the SHARED way of locking in Clipper. Dunno what
will happen, but I'll just try.

open("/home/freddy/tmp/clipper.locking/mnt/freddy/be000001.dat", O_RDWR) = 3
fcntl64(0x3, 0x6, 0xbfffea90, 0x3)      = 0
ioctl(3, 0xc0286e04, 0xbfffea20)        = -1 EINVAL (Invalid argument)
fstat64(3, {st_mode=S_IFREG|0755, st_size=1922, ...}) = 0
mmap2(NULL, 1922, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x40018000
ioctl(3, 0xc0286e04, 0xbfffe9e0)        = -1 EINVAL (Invalid argument)
fcntl64(0x3, 0x6, 0xbfffeaa0, 0x3)      = 0
fstat64(3, {st_mode=S_IFREG|0755, st_size=1922, ...}) = 0

At http://www.dusktilldawn.nl/~freddy/misc/samba/ you can find
the complete output of the strace in sl.strace and
exclusiv.strace . As well as the files sl.prg and exclusiv.prg .
They are the Clipper sources.

Here is some more information out of the var/locks/locking.tdb:

/* Before anything */
$ sudo ~/src/samba/upstream/samba-2.2.7a/source/tdb/tdbdump locking.tdb 
/* Starting sl on GNU/Linux */
$ sudo ~/src/samba/upstream/samba-2.2.7a/source/tdb/tdbdump locking.tdb 
{
key = "\07\03\00\00\00\00\00\00\14\00\00\00\00\00\00\00"
data = "\01\00\00\00\FC\98\16@\15\00\00\00\AC\A8\ED6\04\96J\AB\94l\E5\B6\B8\0B\0
0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\BD\05\00\00\00\00\00\00B\00
\00\00\03\00\00\00\F1\0DQ>\BF\00\06\00\07\03\00\00\00\00\00\00\14\00\00\00\00\00
\00\00\02\00\00\00/opt/db/administratie/freddy/be000001.i01\00"
}
{
key = "\07\03\00\00\00\00\00\00\13\00\00\00\00\00\00\00"
data = "\01\00\00\00\14\9B\16@\15\00\00\00\AC\A8\ED6\04\96J\AB\94l\E5\B6\B8\0B\0
0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\BD\05\00\00\00\00\00\00B\00
\00\00\03\00\00\00\F1\0DQ>]\E7\05\00\07\03\00\00\00\00\00\00\13\00\00\00\00\00\0
0\00\01\00\00\00/opt/db/administratie/freddy/be000001.dat\00"
}
/* Starting sl.exe on Microsoft Windows 2000 */
$ sudo ~/src/samba/upstream/samba-2.2.7a/source/tdb/tdbdump locking.tdb 
{
key = "\07\03\00\00\00\00\00\00\14\00\00\00\00\00\00\00"
data = "\02\00\00\00\FC\98\16@\15\00\00\00\AC\A8\ED6\04\96J\AB\94l\E5\B6\B8\0B\0
0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\E6\04\00\00\00\00\00\00B\80
\00\00\9F\01\02\00\18\0EQ>\DDX\02\00\07\03\00\00\00\00\00\00\14\00\00\00\00\00\0
0\00\1D\00\00\00\BD\05\00\00\00\00\00\00B\00\00\00\03\00\00\00\F1\0DQ>\BF\00\06\
00\07\03\00\00\00\00\00\00\14\00\00\00\00\00\00\00\02\00\00\00/opt/db/administra
tie/freddy/be000001.i01\00"
}
{
key = "\07\03\00\00\00\00\00\00\13\00\00\00\00\00\00\00"
data = "\02\00\00\00\14\9B\16@\15\00\00\00\AC\A8\ED6\04\96J\AB\94l\E5\B6\B8\0B\0
0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\E6\04\00\00\00\00\00\00B\80
\00\00\9F\01\02\00\18\0EQ>\F01\02\00\07\03\00\00\00\00\00\00\13\00\00\00\00\00\0
0\00\1C\00\00\00\BD\05\00\00\00\00\00\00B\00\00\00\03\00\00\00\F1\0DQ>]\E7\05\00
\07\03\00\00\00\00\00\00\13\00\00\00\00\00\00\00\01\00\00\00/opt/db/administrati
e/freddy/be000001.dat\00"
}
{
key = "\07\03\00\00\00\00\00\00\12\00\00\00\00\00\00\00"
data = "\01\00\00\00t\99\16 at n\00\00\00\01\00\00\00,\00\00\00\00\00\00\00p\BB\83\
04\0C\00\00\00\00\00\00\00\0C\00\00\00\5C\00\5C\00\E6\04\00\00\00\00\00\00 \80\0
0\00\89\01\02\00\18\0EQ>\D3\BD\01\00\07\03\00\00\00\00\00\00\12\00\00\00\00\00\0
0\00\1B\00\00\00/opt/db/administratie/freddy/sl.exe\00"
}
/* Stopping sl on GNU/Linux */
$ sudo ~/src/samba/upstream/samba-2.2.7a/source/tdb/tdbdump locking.tdb 
{
key = "\07\03\00\00\00\00\00\00\14\00\00\00\00\00\00\00"
data = "\01\00\00\00\FC\98\16@\15\00\00\00\AC\A8\ED6\04\96J\AB\94l\E5\B6\B8\0B\0
0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\E6\04\00\00\00\00\00\00B\80
\00\00\9F\01\02\00\18\0EQ>\DDX\02\00\07\03\00\00\00\00\00\00\14\00\00\00\00\00\0
0\00\1D\00\00\00/opt/db/administratie/freddy/be000001.i01\00"
}
{
key = "\07\03\00\00\00\00\00\00\13\00\00\00\00\00\00\00"
data = "\01\00\00\00\14\9B\16@\15\00\00\00\AC\A8\ED6\04\96J\AB\94l\E5\B6\B8\0B\0
0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\E6\04\00\00\00\00\00\00B\80
\00\00\9F\01\02\00\18\0EQ>\F01\02\00\07\03\00\00\00\00\00\00\13\00\00\00\00\00\0
0\00\1C\00\00\00/opt/db/administratie/freddy/be000001.dat\00"
}
{
key = "\07\03\00\00\00\00\00\00\12\00\00\00\00\00\00\00"
data = "\01\00\00\00t\99\16 at n\00\00\00\01\00\00\00,\00\00\00\00\00\00\00p\BB\83\
04\0C\00\00\00\00\00\00\00\0C\00\00\00\5C\00\5C\00\E6\04\00\00\00\00\00\00 \80\0
0\00\89\01\02\00\18\0EQ>\D3\BD\01\00\07\03\00\00\00\00\00\00\12\00\00\00\00\00\0
0\00\1B\00\00\00/opt/db/administratie/freddy/sl.exe\00"
}
/* Stopping sl on Microsoft Windows 2000 */
$ sudo ~/src/samba/upstream/samba-2.2.7a/source/tdb/tdbdump locking.tdb 
$ 

I just see them both using the same entries in locking.tdb, but
still they do not lock correctly. I'm confused. Any hint?

-- 
$ cat ~/.signature
Freddy Spierenburg <freddy at dusktilldawn.nl> http://snarl.nl/~freddy/
GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1  E588 6F17 FD5D 7941 D1E1
$ 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba/attachments/20030217/606f5d7c/attachment.bin


More information about the samba mailing list