samba-users August 2010 archive
Main Archive Page > Month Archives  > samba-users archives
samba-users: Re: [Samba] Can Samba lock files until copy is comp

Re: [Samba] Can Samba lock files until copy is complete?

From: Whit Blauvelt <whit+samba_at_nospam>
Date: Sat Aug 21 2010 - 13:13:41 GMT

Thanks much for the suggestions. This may be a dead end then, but trying to
get just a bit clearer on the implications....

On Fri, Aug 20, 2010 at 04:46:20PM -0700, Jeremy Allison wrote:

> 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.

So inside Samba there's a way to know? Would it be possible, with the right
hooks into Samba, to query: "I see a file. Are you done with 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.

Do I take it that this would only apply if the "open" were made through
Samba? I ask since the file is being placed there through Samba, but taken
for other uses by local *nix methods.

> 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
> case best.

Probably true, aside from the "you can write" part - that's beyond my C
skills. At

there's mention of a "audit" and "extd_audit" modules that can log among
other things "file close." If we can have a log of when files are closed, we
can have our Linux-side scripting only grab those files which are logged as
closed. For that matter, we can have a primary and secondary directory, with
logic like "if file in primary directory, if logged as closed, move to
secondary directory; if file in secondary directory, process."

There'd need to be some comparison of file time and log time, so that if a
file by the same name comes in twice the check to the log doesn't
misidentify it as closed, but on first glance this looks workable. Thanks.


-- To unsubscribe from this list go to the following URL and read the instructions: