Re: About close() in commit_lock_file()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 8/5/2013 16:23, schrieb Duy Nguyen:
> close() is added in commit_lock_file(), before rename(), by 4723ee9
> (Close files opened by lock_file() before unlinking. - 2007-11-13),
> which is needed by Windows. But doesn't that create a gap between
> close() and rename() on other platforms where another process can
> replace .lock file with something else before rename() is executed?

First, files manipulated by commit_lock_file() are to be opened only using
lock_file() by definition. Opening such a file in with open() or fopen()
or renaming it via rename() without using the lockfile.[ch] API is
possible regardless of whether commit_lock_file() has closed the file or
not. Such manipulation is already undefined behavior (from Git's point of
view), and there is nothing we can do about "misbehaving" processes.

Second, lock_file() uses O_CREAT|O_EXCL, which fails when the file exists,
regardless of whether it is open or not.

Conclusion: There is no problem.

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]