On 16 May 2002, Nigel Metheringham wrote:
> That won't work either. You can't rename a directory in place of
> another directory in one operation - you need to move the target out of
> the way first.
Oh dear. And I thought I was being so clever. Sigh. Looking at the man
page on Solaris, it seems that the strict statement is that you can only
do it if the target directory is empty, which defeats the object:
--------------------------------------------------------------------
If old points to the pathname of a directory, new must not
point to the pathname of a file that is not a directory. If
the directory named by new exists, it will be removed and
old will be renamed to new. In this case, a link named new
will exist throughout the renaming operation and will refer
to either the file referred to by new or the file referred
to as old before the operation began. Thus, if new names an
existing directory, it must be an empty directory.
--------------------------------------------------------------------
> Also consider this:-
> process X opens dir/dbfile.1
> process Y renames newdir into the place of dir
> process X opens dir/dbfile.2
>
> dbfile.1 and dbfile.2 do not come from the same original directory.
Indeed. I think I have been round this loop before, and forgotten about
it. A creature of (bad) habits!
Moral: don't use NDBM for this kind of thing.
--
Philip Hazel University of Cambridge Computing Service,
ph10@??? Cambridge, England. Phone: +44 1223 334714.