link(2) to rename files in sftp
Darren Tucker
dtucker at zip.com.au
Wed Apr 7 10:34:06 EST 2004
Carson Gaspar wrote:
> --On Tuesday, April 06, 2004 12:00:57 +1000 Darren Tucker wrote:
[about non-racy renames without clobbering existing files]
>> I have no idea how to implement that portably for filesystems without
>> Unix semantics without the race.
>
> Well, if they are reasonably sane, you can do:
>
> if (fd = open(newpath, O_CREAT|O_EXCL, 0)) {
> ret = rename(oldpath, newpath);
> close(fd);
> Unless I'm missing something...
For one thing, the Linux (RH9) open(2) man page says that
O_CREATE|O_EXCL is racy on NFS filesystems. Probably other platforms too.
--
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
More information about the openssh-unix-dev
mailing list