[Python-ideas] Implement POSIX ln via shutil.link and shutil.symlink
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat Jun 1 03:29:34 EDT 2019
> On Wed, May 29, 2019 at 10:07:38PM +0700, Tom Hale wrote:
>
> If
> somebody can create a file named link_name between unlink and
> symlink, he can also remove and create a file named link_name after
> symlink.
I tbink there are some corner cases that can give different results
if the symlink is not atomic.
For example:
Process A wants to symlink f1 --> f2, replacing any existing f1.
Process B wants to create f1 if it doesn't already exist, or update
it if it does. If f1 is a symlink, the file it's linked to should
be updated.
The end result should be that f1 exists and is a symlink to f2.
If the symlink is not atomic, this can happen:
1. Process A sees that f1 already exists and deletes it.
2. Process B sees that f1 does not exist and creates a new file
called f1.
3. Process A tries to symlink f1 to f2, which fails because there
is now an existing file called f1.
This violates the postcondition, because f1 is not a symlink
to f2.
--
Greg
More information about the Python-ideas
mailing list