|Main Archive Page > Month Archives > samba-users archives|
On Fri, Aug 20, 2010 at 04:49:11PM -0400, Whit Blauvelt wrote:
> We've got a system where staff use Samba mounts on their Windows desktops to
> drop files into a Linux directory for further processing. Some of those
> files are large, and take time for the file copy across Samba to complete.
> The problem is that looking at the directory from the Linux side, to see if
> there are new files to process, the directory listing for the
> files-copied-across-by-Samba looks the same for complete files as for
> partial ones - same file name, same perms. We have been handling this by a
> script which checks for files whose size hasn't increased in the last X
> seconds. That's not only an ugly kludge, but fails if system load or network
> congestion stalls the file transfer for too long - the partial file then
> gets "recognized" as complete when its not, and taken for further processing
> when it shouldn't be yet.
> There's got to be a better way. Looking at the docs I see options for
> different ways to lock files against being written to by two users at once.
> But I don't see anything to prevent a file from being read by one user as
> it's being written to by another - or in the initial process of being
> written to the directory location through copying, as in our case.
> I've tried, of course, googling the list archives. Maybe my search terms are
> poorly chosen. This has to be a problem that's been solved before, right?
Outside of Samba, there's no way to know when Samba is finished
with a file. You could write a Windows app to do the copies, which
does a share mode DENY_ALL over the file, but there's no guarantee
that local POSIX apps on the Linux side will see it.
One way of testing that Samba is finished with writing a file
from a POSIX shell script is to write a custom program using
the libsmbclient library to open the required file, and set
the share mode using smbc_setOptionOpenShareMode() to be
DENY_ALL. Such a program will only allow an open to succeed
if there are no other openers in Samba.
Otherwise you can write a VFS module in Samba that notifies
an external program when a file in a particular share is
closed, with no other openers. That might fit your specific
-- To unsubscribe from this list go to the following URL and read the instructions: https://lists.samba.org/mailman/options/samba