[Python-ideas] Implementation of shutil.move
Masklinn
masklinn at masklinn.net
Fri Aug 12 18:37:40 CEST 2011
On 2011-08-12, at 17:03 , Christian Heimes wrote:
> Am 12.08.2011 16:55, schrieb Masklinn:
>> On 2011-08-12, at 16:48 , David Townshend wrote:
>>> My understanding of os.O_EXCL is that it locks the file from changes by any
>>> other process.
>> That, *could* be O_EXLOCK, but I'm not too sure.
>>
>> O_EXCL does not do anything in and of itself, it fails the file opening if combined with O_CREAT. That's it (from man 2 open):
>>
>> O_EXCL error if O_CREAT and the file exists
>
> The man page open(2) doesn't mention O_EXLOCK. It must belong to another
> low level function.
Nope, got it from open(2), but it's apparently a bsd extension: http://lkml.indiana.edu/hypermail/linux/kernel/0005.1/1288.html
This information (that it's an extension) is present in the OpenBSD open(2) page, but I checked it on an OSX machine where it's not specified. Sorry.
It's an atomic `flock(fd, LOCK_EX)` (or LOCK_SH) built into open(2) to avoid the unlocked open hole between the open(2) and flock(2) calls.
http://www.openbsd.org/cgi-bin/man.cgi?query=open&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html
http://www.freebsd.org/cgi/man.cgi?query=open&apropos=0&sektion=2&manpath=FreeBSD+8.2-RELEASE&format=html
http://netbsd.gw.com/cgi-bin/man-cgi?open+2+NetBSD-current
http://leaf.dragonflybsd.org/cgi/web-man?command=open§ion=2
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/open.2.html
More information about the Python-ideas
mailing list