Testing for fcntl locks before doing ftruncate()?

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Jan 19 12:53:34 GMT 2006


A customer of mine is testing cross-platform access to files from Samba and
Unix, in particular fcntl locking. One thing that happened that an 

echo hello > test.txt

done from a windows command window wiped out the file contents that had been
locked by fcntl locks on the unix side. This happened because in open.c:

        if (flags2&O_TRUNC) {
                 * We are modifing the file after open - update the stat
                 * struct..
                if ((SMB_VFS_FTRUNCATE(fsp,fsp->fh->fd,0) == -1) ||
                    (SMB_VFS_FSTAT(fsp,fsp->fh->fd,psbuf)==-1)) {
                        return NULL;

we don't check for byte range locks. Similarly for the ftruncate in smbwrite.

This is probably not what is expected. Shall we add some is_posix_locked()

-------------- 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-technical/attachments/20060119/1d006973/attachment.bin

More information about the samba-technical mailing list