David Malone writes:
> > I'm writing a program under FreeBSD 3.X that has been forced into having to
> > make a number of rename() calls that must be completed atomically (i.e. all
> > together) without the process being interrupted, or any other process being
> > allowed to run...
>
> If all the files exist below one directory you could swap the
> directories with two renames, but that won't be atomic either. I
> think your best bet would be rethink what you want to do.
It could still work as long as at startup you check for any
half-completed operation and finish it, e.g.:
mkdir mydir.new
copy/modify files in mydir.new
mv mydir mydir.old
mv mydir.new mydir
Then on startup (e.g., after a crash), if "mydir" doesn't exist,
simply "mv mydir.new mydir; rm -rf mydir.old" before proceeding.
-Archie
___________________________________________________________________________
Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message