ln -f
Lars Henrik Mathiesen
thorinn at skinfaxe.diku.dk
Fri Aug 17 21:11:57 AEST 1990
guy at auspex.auspex.com (Guy Harris) writes:
>[I write:]
>>Why don't the versions of ln that you know of on 4.3 BSD and SunOS 4
>>use the rename system call?
I tried to cancel this as soon as I realized my error, but it didn't
work, evidently.
>["rename" is]
> an atomic operation that *renames* the source to the target, and if
>it succeeds does *not* leave the source behind.
I [usually] know that. But now that I think about it: Why doesn't ln:
1) Create a new, randomly named, link in the target directory.
2) Use "rename" to atomically replace the target with that link?
There will be no time when the target name doesn't exist. If the
machine crashes (or ln is killed), a funny link may be left behind,
but I think that is a smaller problem than the timing race.
I don't know if it would be wise to make this the default behaviour of
ln, but it might be useful to provide it as an option. (Of course, the
method would only be used if the target already existed.)
--
Lars Mathiesen, DIKU, U of Copenhagen, Denmark [uunet!]mcsun!diku!thorinn
Institute of Datalogy -- we're scientists, not engineers. thorinn at diku.dk
More information about the Comp.unix.wizards
mailing list