Re: Careful object writing..
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- May 3, 2005, 22:13 UTC
- Message-ID
- <Pine.LNX.4.58.0505031507460.26698@ppc970.osdl.org>
- In-Reply-To
- <20050503205957.GA25253@delft.aura.cs.cmu.edu>
On Tue, 3 May 2005, Jan Harkes wrote:
Show 6 quoted lines
> > Short summary: > > rc = link(old, new); > if (rc == -1 && errno == EXDEV) > rc = rename(old, new);
Ok, that is safe enough. Will do.
> On Coda, the cross-directory link fails, the following cross-directory > rename will work fine. On a normal filesystem, if the link fails with > EXDEV, the rename will fail with the same.
Yup. I do suspect that since you handle the rename anyway, you probably could handle the git link/unlink patterns too, but it's easy enough to just do the rename fallback in git itself.
The only reason not to use rename in the first place is literally just to be able to check for collisions. Which we don't actually _do_ right now, but I like to be able to do so in theory.
Linus