← Back to context

Comment by jstimpfle

20 days ago

Assuming that the two `mv` commands are run in sequence, there shouldn't be any possibility for a and d to be observed "at once" (i.e. first d and then afterwards still a, by a single process).

You'd be wrong

  • How so?

    With regards to Linux kernel implementation, I could map you out a list of sequence points caused in the kernel by above sequential "shell script", proving that no other process could observe d and then a using two subsequent "stat" calls. I could imagine that a single directory listing (getdents) could happen to first visit a and then d, though -- I don't know the internals of that.

    With regards to POSIX specification, I don't know the details but anything less than that guarantee would be very a huge robustness problem.