Currently renaming of a file is implemented via a link() and unlink() syscall with the possibility to fall back to the rename() syscall in certain conditions (ENOTSUPP etc). In case the errorcode returned by link() is ENOSYS this is not the case. The attached patch implements a fallback to rename in case of ENOSYS.
Created attachment 1578 [details] Patch fall back to rename() upon ENOSYS errorcode.
Sounds reasonable, but under what conditions does link return ENOSYS? It's not documented in link(2) as a possible errno.
We'd like this for openssh-5.2, but Darren's question needs an answer before we can commit it.
(In reply to comment #3) > We'd like this for openssh-5.2, but Darren's question needs an answer > before we can commit it. Actually that was covered over on openssh-unix-dev: it's sshfs that returns ENOSYS. http://marc.info/?l=openssh-unix-dev&m=122602218711487
(In reply to comment #4) It was also brought to my attention on the mailinglist that the syscall link() shouldn't return ENOSYS. According to the link(2) the implementation of link in sshfs should return EPERM to indicate that creation of links is not supported. However the error check in sftp-server doesn't check EPERM either. So actually the proper solution would be to fix this in sshfs and to add a fix in sftp-server to also check for EPERM.
(In reply to comment #5) > (In reply to comment #4) > It was also brought to my attention on the mailinglist that the syscall > link() shouldn't return ENOSYS. According to the link(2) the > implementation of link in sshfs should return EPERM to indicate that > creation of links is not supported. However the error check in > sftp-server doesn't check EPERM either. Actually it does (on Linux, anyway): if (link(oldpath, newpath) == -1) { if (errno == EOPNOTSUPP #ifdef EXDEV || errno == EXDEV #endif #ifdef LINK_OPNOTSUPP_ERRNO || errno == LINK_OPNOTSUPP_ERRNO #endif ) { where on Linux, LINK_OPNOTSUPP_ERRNO is defined thusly: AC_DEFINE(LINK_OPNOTSUPP_ERRNO, EPERM, [Define to whatever link() returns for "not supported" if it doesn't return EOPNOTSUPP.])
patch applied - this will be in openssh-5.3
Mass move of RESOLVED bugs to CLOSED now that 5.3 is out.