Stephen Gallimore
1998-Nov-17 10:17 UTC
Failure to rename files that have active file handles
We have just installed Samba 1.9.18p10 on an Ultra Sparc, Solaris 2.5.1 .
So far we have been very impressed with the resilience and performance
of Samba in contrast to Hummingbird and Solstice NFS products while
doing large product builds on our NT4.0 sp4 machines.
However we have come across one little problem, which may be down to
configuration, that has left us "worried" about ditching our NFS
solution
completely. That is we seem to be unable to rename a file that has an
open file handle (either owned by the same process doing the rename or
a different process), this is not a problem on a local NT drive or on
an NFS mounted drive. This showed up in "makedepend" which has code
like this:
fdin = fopen("Makefile",...)
rename("Makefile","Makefile.bak")
fdout = freopen("Makefile","w",stdout)
The rename fails with "Permission denied". I have tried this with
oplocks
on and off (I couldn't see any other obvious configuration option that
might effect this).
Now clearly the above code can trivially be rewritten to avoid the problem,
however this may not always be an option. I have not been able to find
any similar report in the FAQs or the samba list archives so would
appreciate any help.
Best regards,
Stephen Gallimore
*******************************************************************************
Lincoln Software Limited Stephen Gallimore
Marlborough Court
Pickford Street Tel: +44 (0)1625 616722
Macclesfield Fax: +44 (0)1625 616780
Cheshire. SK11 6JD E-mail: stephen.gallimore@lincolnsoftware.com
United Kingdom Web: www.lincolnsoftware.com
"Never trust a crown green bowler under 30"
*******************************************************************************
David Collier-Brown
1998-Nov-17 21:13 UTC
Failure to rename files that have active file handles
You wrote:
| However we have come across one little problem, which may be down to
| configuration, that has left us "worried" about ditching our NFS
| solution completely. That is we seem to be unable to rename a file
that
| has an open file handle (either owned by the same process doing the
| rename or a different process), this is not a problem on a local NT
| drive or on an NFS mounted drive. This showed up in "makedepend"
which
| has code like this:
| fdin = fopen("Makefile",...)
| rename("Makefile","Makefile.bak")
| fdout = freopen("Makefile","w",stdout)
Er: that's wrong.
The algorithm you're thinking of is
1) copy x x.bak
2) open x and rewind
4) while reading x.bak, rewrite x.
This preserves the permissions on the file, and
tends to leave it in a recoverable state for as
long as possible, while always leaving a .bak file
in a sane state.
The algorith's a variant on "how to update a master file"
from the ACM, back in the algol/fortran days. And it
is one that Windows locking allows...
--dave
--
David Collier-Brown, | Always do right. This will gratify some people
185 Ellerslie Ave., | and astonish the rest. -- Mark Twain
Willowdale, Ontario | http://java.science.yorku.ca/~davecb
Work: (905) 477-0437, Home: (416) 223-8968, Email: davecb@canada.sun.com