Testing for fcntl locks before doing ftruncate()?
Jeremy Allison
jra at samba.org
Thu Jan 19 14:26:52 GMT 2006
On Thu, Jan 19, 2006 at 01:53:34PM +0100, Volker Lendecke wrote:
> Hi!
>
> 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)) {
> unlock_share_entry_fsp(fsp);
> fd_close(conn,fsp);
> file_free(fsp);
> 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()
> here?
No, we need a is_locked(), not a posix specific one I think. I'll take
a look.
Jeremy.
More information about the samba-technical
mailing list