IETF-SSH archive

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

Re: sftp rename not good.



* Nicolas Williams <Nicolas.Williams%sun.com@localhost> [030513 16:23] wrote:
> 
> If the semantics of file renaming vary so much from platform to
> platform, without even the ability to reliably emulate one behaviour on
> all those platforms, then either that variance will have to carry
> through to SFTP or the SFTP server will have to have a way to tell the
> SFTP client what file rename semantics it supports so the client can
> choose which to use.

Which is why I was hoping for "rename -f" to at least attempt the unix
rename(2).  If rename(2) is not available it should do something like 
this:

if (rename(old, new) == -1)
	if (errno != ENOSYS || errno != ENOTSUP)
		return (-1);
	/* emulate rename, XXX: output a warning to client? */
	(void) unlink(new);
	if (link(old, new) != 0)
		return (-1);
	if (fsync(new) != 0) {
		(void) unlink(new);
		return (-1);
	}
	(void) unlink(old);
}

-- 
-Alfred Perlstein [alfred%freebsd.org@localhost]
'Instead of asking why a piece of software is using "1970s technology,"
 start asking why software is ignoring 30 years of accumulated wisdom.'



Home | Main Index | Thread Index | Old Index