Bug 1295007 - Non-GIO (POSIX) API call to save data truncates file to 0 bytes.
Non-GIO (POSIX) API call to save data truncates file to 0 bytes.
Status: CLOSED EOL
Product: Fedora
Classification: Fedora
Component: gvfs (Show other bugs)
23
x86_64 Linux
unspecified Severity high
: ---
: ---
Assigned To: Ondrej Holy
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-31 13:22 EST by Benjamin Ariel Nava Martinez
Modified: 2016-12-20 12:31 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-12-20 12:31:19 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Benjamin Ariel Nava Martinez 2015-12-31 13:22:04 EST
Description of problem:
Whenever I save any file using an app that doesn't use GIO but rather POSIX to perform IO, the file ends up being truncated.

Version-Release number of selected component (if applicable):
Nombre      : gvfs
Arquitectur : x86_64
Epoch       : 0
Versión     : 1.26.2
Lanzamiento : 1.fc23
Tamaño      : 1.1 M
Repo        : @System
Desde repo  : updates
Resumen     : Backends for the gio framework in GLib
URL         : https://wiki.gnome.org/Projects/gvfs
Licencia    : GPLv3 and LGPLv2+ and BSD and MPLv2.0
Descripción : The gvfs package provides backend implementations for the gio
            : framework in GLib. It includes ftp, sftp, cifs.

Other relevant components:
Nombre      : fuse
Arquitectur : x86_64
Epoch       : 0
Versión     : 2.9.4
Lanzamiento : 3.fc23
Tamaño      : 220 k
Repo        : @System
Desde repo  : fedora
Resumen     : File System in Userspace (FUSE) utilities
URL         : http://fuse.sf.net
Licencia    : GPL+
Descripción : With FUSE it is possible to implement a fully functional filesystem in a
            : userspace program. This package contains the FUSE userspace tools to
            : mount a FUSE filesystem.

Nombre      : gvfs-fuse
Arquitectur : x86_64
Epoch       : 0
Versión     : 1.26.2
Lanzamiento : 1.fc23
Tamaño      : 37 k
Repo        : @System
Desde repo  : updates
Resumen     : FUSE support for gvfs
URL         : https://wiki.gnome.org/Projects/gvfs
Licencia    : GPLv3 and LGPLv2+ and BSD and MPLv2.0
Descripción : This package provides support for applications not using gio
            : to access the gvfs filesystems.

How reproducible:
Always

Steps to Reproduce:
1. Open a file with an app that uses POSIX instead of GIO e.g. leafpad.
2. Attempt to write to the remote location.
3. File ends up being truncated to 0 bytes.

Actual results:
File is being truncated.

Expected results:
File is saved correctly.

Additional info:
Other relevant (external) bug reports:

https://bugs.launchpad.net/ubuntu/+source/leafpad/+bug/708829
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680418
https://bugzilla.redhat.com/show_bug.cgi?id=479199 (too old)
Comment 1 Ondrej Holy 2016-01-05 07:24:46 EST
Thanks for your bug report.

GIO API isn't fully compatible with POSIX and thus some operations might not be supported. However it is not definitely true that all "POSIX editors" doesn't work, I would say that most of the editors should work, e.g. nano works (first one I tried)...

It seems leafpad is doing something bit nonstandard, because it is using two file descriptors for writing:

open("/run/user/1000/gvfs/ftp:host=foo/bar", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 10
...
open("/run/user/1000/gvfs/ftp:host=foo/bar", O_WRONLY|O_CREAT|O_APPEND, 0666) = 11
lseek(11, 0, SEEK_END)                  = -1 ESPIPE (Illegal seek)
close(11)                               = 0
...
write(10, "foobar", 6)                  = -1 EOPNOTSUPP (Operation not supported)
close(10)  

As a result fuse calls vfs_write without O_APPEND, nor O_TRUNC:

vfs_open: /ftp:host=foo/bar
open_common: flags=101001
vfs_open: -> Success
...
vfs_open: /ftp:host=foo/bar
open_common: flags=102001
vfs_open: -> Success
vfs_release: /ftp:host=foo/bar
file_handle_close_stream
...
vfs_write: /ftp:host=foo/bar
vfs_write: flags=100001
vfs_write: -> Operation not supported
vfs_release: /ftp:host=foo/bar
file_handle_close_stream
file_handle_close_stream

This is not supported by the fuse daemon, because it might cause data corruptions due to the divergence of POSIX and GIO API, see:
https://bugzilla.gnome.org/show_bug.cgi?id=632296

I'm not sure if we can improve it somehow in GVfs, but I suppose it can be easily fixed in leafpad (e.g. adding O_APPEND for the first open)...
Comment 2 Ondrej Holy 2016-01-05 07:50:29 EST
There is also problem with invalidation ftp cache after writing, which might cause POSIX editors fails to read file content over fuse daemon after successful write:
https://bugzilla.gnome.org/show_bug.cgi?id=760159
Comment 3 Benjamin Ariel Nava Martinez 2016-01-05 17:11:59 EST
Thank you for your response, this is a leafpad-related bug then, if I understand correctly.
Comment 4 Fedora End Of Life 2016-11-24 09:37:57 EST
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 5 Fedora End Of Life 2016-12-20 12:31:19 EST
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.