[Samba] File locking with smbd

Ron Cococcia ron.cococcia at request.com
Fri Oct 22 19:48:42 GMT 2004


I have a problem and haven't been able to figure it out yet.  I was 
running a test of an upload mechanism the product my company makes uses. 
   The idea is that users can upload files to a share, and we 
process/archive those files when they have been added.  It would try to 
detect if a file is in use, and if that were so, it would skip that 
particular file and come back to it later.  The problem that I 
discovered is that I was unable to programmatically detect whether a 
file was currently in use by smbd (using typical system calls).

Searching through smb.conf's man page, I tried a few different options 
with no luck.  I would like to use something like fcntl(F_GETLK...) to 
determine if there are any locks on the file, but I haven't been able to 
detect any.  strace shows that smbd does lock files, but as far as I can 
tell, only the log files.

Does smbd have the capability to lock files that it has in use?  Is it 
possible that if it were to lock files, that I misconfigured/miscompiled 
smbd?  I'd prefer to not use a kludge like popen("smbstatus") or 
popen("lsof").  I might consider examining the last modification 
timestamp on the file too, but I don't know if there might be other 
cases where that wouldn't work.

Thanks in advance!


More information about the samba mailing list