[Samba] File deleted while locked

Nico Kadel-Garcia nkadel at gmail.com
Sun May 26 07:08:32 MDT 2013

On Thu, May 23, 2013 at 11:56 AM,
<nipponunited.keithrob91 at spamgourmet.com> wrote:
> Hi,
> I'm running Samba 4.0.0 on a RHEL 6.4 machine and have created a simple share with all the default configuration options. I've also created an application (running on the RHEL box) that does the following:

Update, definitely. My published toolchain for building Samba 4.0.5 as
SRPM's, and with the option of acting as a domain controller, is at

> - detects a file appearing in the share (using Inotify looking for the IN_CLOSE_WRITE event)
> - open and fcntl lock the file
> - do some processing
> - move the file to somewhere else in the filesystem
> When I use a Windows 7 machine to copy a file to the share (using explorer) my app works fine. However if I copy a file as before, but then while my app is processing the file if I copy the file to the share again, I get a dialog in Windows stating the file is locked, 'Try Again' or 'Cancel'. If I press Cancel, the dialog goes away but so does the file within the share. When my app tries to move the file it fails because it no longer exists.
> Looking at the wireshark output on the Windows machine I see that a SetInfo request is made with a SMB2_FILE_DISPOSITION_INFO and 'Delete on close set', followed by a success response. I assume this is the cause of the file deletion? I have to admit to being a novice at both SMB and Samba so apologies in advance if I'm a little vague.
> Is the above expected even though I have locked the file?
> For further info, I disabled oplocks for my share with no change in behaviour.

Update first, then be ready to publish your smb.conf.

More information about the samba mailing list