Bug 1300 - rename doesn't work on Linux vfat
Summary: rename doesn't work on Linux vfat
Status: CLOSED INVALID
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp-server (show other bugs)
Version: 3.8p1
Hardware: All Linux
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-18 11:08 AEDT by Tilman Vogel
Modified: 2008-04-04 09:58 AEDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tilman Vogel 2007-03-18 11:08:05 AEDT
Looking for a solution to the above problem, I saw in CVSWeb that in current versions of OpenSSH, there is code in process_rename() in sftp-server.c which checks if links are available on the target filesystem. 

It does so by checking the errno given by link() against EOPNOTSUPP. 
The problem is: At least on Linux 2.6.x with glibc 2.3.5, link() returns EPERM in this case as is also documented in my copy of "man 2 link":
...
      EPERM  oldpath is a directory.

       EPERM  The filesystem containing oldpath and newpath does not support the creation of hard links.
...

Thus the lack of link support is not detected and rename will not fall back to the stat/rename code. process_rename() fails even though it doesn't have to.
Comment 1 Darren Tucker 2007-03-18 11:23:12 AEDT
The code tests for LINK_OPNOTSUPP_ERRNO which is defined to be EPERM on Linux (in the Linux-specific block of configure).

What happened when you actually tried it?
Comment 2 Darren Tucker 2007-03-18 11:27:37 AEDT
(In reply to comment #1)
> The code tests for LINK_OPNOTSUPP_ERRNO which is defined to be EPERM on
> Linux (in the Linux-specific block of configure).

BTW that code has been there since version 3.9.
Comment 3 Tilman Vogel 2007-03-18 11:42:43 AEDT
(In reply to comment #2)
> (In reply to comment #1)
> > The code tests for LINK_OPNOTSUPP_ERRNO which is defined to be EPERM on
> > Linux (in the Linux-specific block of configure).
> 
> BTW that code has been there since version 3.9.

Ok, then sorry for bothering! I was trying to patch that piece of code into a 3.8p1 package for a Nokia 770 where obviously LINK_OPNOTSUPP_ERRNO won't be defined by configure. I'll just add that to the configure script too. Thanks!

Comment 4 Damien Miller 2008-04-04 09:58:55 AEDT
Close resolved bugs after release.