GNOME Bugzilla – Bug 608910
gvfsd-sftp: unable to append to file via fuse-daemon
Last modified: 2013-10-25 04:20:16 UTC
Hello, I have faced some strange behaviour when mounting a GVFS-SFTP share. This bug is similar to https://bugzilla.gnome.org/show_bug.cgi?id=608908, though the backend is different. The configuration is the same (Ubuntu 9.10 Karmic with Gnome 2.28.1 and GVFS 1.4.2) Steps to reproduce behaviour: 1. Mount a GVFS-SFTP share (via sftp://someserver/someshare) 2. Open terminal and cd to this share 3. Run commands: user@host:~/.gvfs/sftp on someserver$ echo 100 > ./test user@host:~/.gvfs/sftp on someserver$ echo 200 >> ./test 4. Expected result: "200" appended to file contents 5. Real result - an error: bash: echo: write error: Operation not supported When using a text editor writing with fopen (e.g. Geany: http://www.geany.org), this behaviour leads to loss of all file contents (e.g. after I save a file, it has a 0-byte size and is empty). When using gedit (which seems to write via g_file_set_contents), all is OK. Again, this was not present in Ubuntu Jaunty (Gnome 2.26, GVFS 1.2.2). Please let me know if that is a bug or a normal behaviour.
The issue is still present in GVFS 1.8.2 (Arch Linux 32bit, Kernel 3.0.3, Gnome 3.0.2).
(In reply to comment #1) > The issue is still present in GVFS 1.8.2 (Arch Linux 32bit, Kernel 3.0.3, Gnome > 3.0.2). You mean the 0-byte sized file or the append error?
I mean the append error. I was under the impression that the 0-byte error is a consequence of the append error under some circumstances. Sorry for not being more specific.
Append error still exists here in gvfs 1.10.0 (Ubuntu Oneiric). Also I got "Operation not supported" by moving a file from local fs to remote.
Could someone from BugSquad please mark this as confirmed and update version to 1.10.x? This should be a high priority bug as it prevents normal usage of sftp backend and may cause data loss.
Created attachment 256550 [details] [review] sftp: Allow seeking when opening for append Although it has no effect, allow seeking when opening a file for append to allow programs to write to files opened for append through the fuse backend without failing with ENOTSUPP. This is similar to POSIX behavior which allows seeking on a file opened with O_APPEND.
The problem is two-fold: Firstly, OpenSSH does not honor the append flag for sftp. I have sent a patch upstream for this: http://marc.info/?l=openssh-unix-dev&m=138053388830753&w=2 This makes appending work with GIO. Secondly, the patch marks the file as seekable which allows appending to work with the fuse daemon instead of failing with "operation not supported".
The patch has been applied to OpenSSH upstream [1]. This means that g_file_append_to() now works correctly. With the minor patch in #6, append also works for the fuse daemon. [1] http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/sftp-server.c.diff?r1=1.100;r2=1.101
Review of attachment 256550 [details] [review]: It looks good.
Pushed to master as 629c5cc.