UC Davis Cyrus Incident September 2007

Robert Mueller robm at fastmail.fm
Thu Oct 18 19:34:19 EDT 2007


> Actually, I don't see a deadlock situation at all... I am guessing that
> theorettically, it is possible... but the "ln -sf" option makes the
> overwriting of the symlink an atomic action (as much as it can), which

Not a "deadlock" situation, but a possible "file doesn't exist" error.
In the Unix/POSIX world, symlink will not overwrite an existing file
(man 3 symlink), but rename will do so (man 3 rename), and it will do it
atomically.

So, as an strace shows, this isn't atomic.

$ touch b
$ strace ln -fs a b
...
symlink("a", "b")                       = -1 EEXIST (File exists)
unlink("b")                             = 0
symlink("a", "b")                       = 0
...

But this is:

$ ln -fs a b.tmp
$ strace mv b.tmp b
...
rename("b.tmp", "b")                    = 0
...

Rob

----------
robm at fastmail.fm
Sign up at http://fastmail.fm for fast, ad free, IMAP accessible email



More information about the Info-cyrus mailing list