After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 748106 - Add operations to support O_WRONLY and O_RDWR in fuse daemon
Add operations to support O_WRONLY and O_RDWR in fuse daemon
Status: RESOLVED OBSOLETE
Product: gvfs
Classification: Core
Component: fuse
1.24.x
Other Linux
: Normal enhancement
: ---
Assigned To: gvfs-maint
gvfs-maint
: 748675 749687 753065 777152 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-04-18 13:47 UTC by Simonas Kazlauskas
Modified: 2018-09-21 17:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fuse: Add fallback for unsupported write operations (5.26 KB, patch)
2018-05-14 12:01 UTC, Ondrej Holy
none Details | Review

Description Simonas Kazlauskas 2015-04-18 13:47:28 UTC
After upgrade from 1.22 to 1.24 on Arch Linux smb:// and sftp:// both return EOPNOTSUPP if a file is attempted to be opened as writable (O_WRONLY or O_RDWR).

I believe this problem is not backend-specific.
Comment 1 Ross Lagerwall 2015-04-18 17:50:04 UTC
That is indeed true. GIO does not provide the correct high level operations to provide those operations. They should work if O_TRUNC is also used. This was changed in bug 632296 because the existing implementation caused data loss in several cases.

I will change this into a enhancement request to provide these operations.

Note that using gvfs through the fuse mechanism is a fallback implementation.
Comment 2 Ross Lagerwall 2015-04-30 04:51:48 UTC
*** Bug 748675 has been marked as a duplicate of this bug. ***
Comment 3 Ross Lagerwall 2015-05-23 19:43:32 UTC
*** Bug 749687 has been marked as a duplicate of this bug. ***
Comment 4 Ross Lagerwall 2015-08-01 08:43:44 UTC
*** Bug 753065 has been marked as a duplicate of this bug. ***
Comment 5 Ondrej Holy 2018-05-14 11:01:29 UTC
*** Bug 777152 has been marked as a duplicate of this bug. ***
Comment 6 Ondrej Holy 2018-05-14 12:01:59 UTC
Created attachment 372004 [details] [review]
fuse: Add fallback for unsupported write operations

Currently, open() fails with ENOTSUP if O_WRONLY/O_RDWR is used without
O_TRUNC, or O_APPEND, because GFileIOStream is not supported by GVfs
and GIO API doesn't provide any other suitable function. Let's introduce
fallback solution using a temporary file as follows:

1) Make a temporary copy of the original file with .fuse suffix (so the
   new file can be used as a backup if something goes wrong).
2) Replace original file using g_file_replace (i.e. using O_TRUNC) and
   copy back the data from the temporary file over the GFileOutputStream.
3) Finally, remove the temporary file and return the stream which was
   used to copy the data back.

This approach copies the file twice, once into the temporary location and
once back instead of just simple write, which is extremely inefficient
(and fragile), but there are not many possibilities using the current API.
It would be possible to make just one copy in theory, but I choose this
solution to make it more bulletproof.

Given the fact that is extremely inefficient, let's limit this only to small
files (i.e. return ENOTSUP for big files). I initialy choose the limit to
128 MB, but it can be changed in the future if needed.
Comment 7 GNOME Infrastructure Team 2018-09-21 17:47:49 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gvfs/issues/249.