[gvfs/f14/master] - Use correct "usb:" address for GPhoto mounts with gudev (#642836) - FUSE: Add O_TRUNC support for
Tomas Bzatek
tbzatek at fedoraproject.org
Mon Nov 1 15:29:37 UTC 2010
commit 3694c2a211237f470e2ca3bf73b4a31f99bcb8aa
Author: Tomas Bzatek <tbzatek at redhat.com>
Date: Mon Nov 1 16:28:31 2010 +0100
- Use correct "usb:" address for GPhoto mounts with gudev (#642836)
- FUSE: Add O_TRUNC support for open()
gvfs-1.6.5-fuse-open-trunc-support.patch | 77 ++++++++++++++++++
gvfs-1.6.5-gphoto-addresses.patch | 124 ++++++++++++++++++++++++++++++
gvfs.spec | 15 ++++-
3 files changed, 215 insertions(+), 1 deletions(-)
---
diff --git a/gvfs-1.6.5-fuse-open-trunc-support.patch b/gvfs-1.6.5-fuse-open-trunc-support.patch
new file mode 100644
index 0000000..b5d096d
--- /dev/null
+++ b/gvfs-1.6.5-fuse-open-trunc-support.patch
@@ -0,0 +1,77 @@
+From 0d1dc99a87d354e8af9cb0f98827bafb2cd7f577 Mon Sep 17 00:00:00 2001
+From: Tomas Bzatek <tbzatek at redhat.com>
+Date: Wed, 13 Oct 2010 16:25:51 +0200
+Subject: [PATCH] fuse: Add O_TRUNC support for open()
+
+This requires kernel version 2.6.24 or later.
+
+See bug 627567 for details.
+---
+ client/gvfsfusedaemon.c | 16 +++++++++++-----
+ 1 files changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
+index 13cb74d..bc3090d 100644
+--- a/client/gvfsfusedaemon.c
++++ b/client/gvfsfusedaemon.c
+@@ -948,7 +948,7 @@ setup_input_stream (GFile *file, FileHandle *fh)
+ }
+
+ static gint
+-setup_output_stream (GFile *file, FileHandle *fh)
++setup_output_stream (GFile *file, FileHandle *fh, int flags)
+ {
+ GError *error = NULL;
+ gint result = 0;
+@@ -968,7 +968,10 @@ setup_output_stream (GFile *file, FileHandle *fh)
+
+ if (!fh->stream)
+ {
+- fh->stream = g_file_append_to (file, 0, NULL, &error);
++ if (flags & O_TRUNC)
++ fh->stream = g_file_replace (file, NULL, FALSE, 0, NULL, &error);
++ else
++ fh->stream = g_file_append_to (file, 0, NULL, &error);
+ if (fh->stream)
+ fh->pos = g_seekable_tell (G_SEEKABLE (fh->stream));
+ }
+@@ -1024,7 +1027,7 @@ vfs_open (const gchar *path, struct fuse_file_info *fi)
+ set_pid_for_file (file);
+
+ if (fi->flags & O_WRONLY || fi->flags & O_RDWR)
+- result = setup_output_stream (file, fh);
++ result = setup_output_stream (file, fh, fi->flags);
+ else
+ result = setup_input_stream (file, fh);
+
+@@ -1406,7 +1409,7 @@ vfs_write (const gchar *path, const gchar *buf, size_t len, off_t offset,
+ {
+ g_mutex_lock (fh->mutex);
+
+- result = setup_output_stream (file, fh);
++ result = setup_output_stream (file, fh, 0);
+ if (result == 0)
+ {
+ result = write_stream (fh, buf, len, offset);
+@@ -1857,7 +1860,7 @@ vfs_ftruncate (const gchar *path, off_t size, struct fuse_file_info *fi)
+ {
+ g_mutex_lock (fh->mutex);
+
+- result = setup_output_stream (file, fh);
++ result = setup_output_stream (file, fh, 0);
+
+ if (result == 0)
+ {
+@@ -2336,6 +2339,9 @@ vfs_init (struct fuse_conn_info *conn)
+ subthread_main_loop = g_main_loop_new (NULL, FALSE);
+ subthread = g_thread_create ((GThreadFunc) subthread_main, NULL, FALSE, NULL);
+
++ /* Indicate O_TRUNC support for open() */
++ conn->want |= FUSE_CAP_ATOMIC_O_TRUNC;
++
+ return NULL;
+ }
+
+--
+1.7.3.1
+
diff --git a/gvfs-1.6.5-gphoto-addresses.patch b/gvfs-1.6.5-gphoto-addresses.patch
new file mode 100644
index 0000000..bd7fbb1
--- /dev/null
+++ b/gvfs-1.6.5-gphoto-addresses.patch
@@ -0,0 +1,124 @@
+From 089ba0b1af08f8b7506bd867a415e197f4017ec0 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess at hadess.net>
+Date: Thu, 28 Oct 2010 16:25:12 +0000
+Subject: Use correct "usb:" address for GPhoto mounts with gudev
+
+gphoto2 expects the usb:X,X addresses to use the dirname and device
+names from libusb, which are zero-padded. Given that it's what udev
+gives us, just don't transform it to an int before printing.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=631562
+---
+diff --git a/monitor/gphoto2/ggphoto2volumemonitor.c b/monitor/gphoto2/ggphoto2volumemonitor.c
+index 9fefc5d..25affe3 100644
+--- a/monitor/gphoto2/ggphoto2volumemonitor.c
++++ b/monitor/gphoto2/ggphoto2volumemonitor.c
+@@ -83,7 +83,7 @@ static void update_cameras (GGPhoto2VolumeMonitor *monitor,
+ GList **removed_volumes);
+ #endif
+
+-static GList* get_stores_for_camera (int bus_num, int device_num);
++static GList* get_stores_for_camera (const char *bus_num, const char *device_num);
+
+ G_DEFINE_TYPE (GGPhoto2VolumeMonitor, g_gphoto2_volume_monitor, G_TYPE_VOLUME_MONITOR)
+
+@@ -195,9 +195,7 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
+ GGPhoto2Volume *volume;
+ GList *store_heads, *l;
+ guint num_store_heads;
+- const char *property;
+- int usb_bus_num;
+- int usb_device_num;
++ const char *usb_bus_num, *usb_device_num;
+
+ /* For iPhones and iPod Touches, don't mount gphoto mounts,
+ * we already have access through AFC */
+@@ -209,19 +207,17 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
+ }
+ #endif /* HAVE_AFC */
+
+- property = g_udev_device_get_property (device, "BUSNUM");
+- if (property == NULL) {
++ usb_bus_num = g_udev_device_get_property (device, "BUSNUM");
++ if (usb_bus_num == NULL) {
+ g_warning("device %s has no BUSNUM property, ignoring", g_udev_device_get_device_file (device));
+ return;
+ }
+- usb_bus_num = atoi (property);
+
+- property = g_udev_device_get_property (device, "DEVNUM");
+- if (property == NULL) {
++ usb_device_num = g_udev_device_get_property (device, "DEVNUM");
++ if (usb_device_num == NULL) {
+ g_warning("device %s has no DEVNUM property, ignoring", g_udev_device_get_device_file (device));
+ return;
+ }
+- usb_device_num = atoi (property);
+
+ /* g_debug ("gudev_add_camera: camera device %s (bus: %i, device: %i)",
+ g_udev_device_get_device_file (device),
+@@ -241,11 +237,11 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
+ */
+ if (num_store_heads == 1)
+ {
+- uri = g_strdup_printf ("gphoto2://[usb:%03d,%03d]", usb_bus_num, usb_device_num);
++ uri = g_strdup_printf ("gphoto2://[usb:%s,%s]", usb_bus_num, usb_device_num);
+ }
+ else
+ {
+- uri = g_strdup_printf ("gphoto2://[usb:%03d,%03d]/%s", usb_bus_num, usb_device_num,
++ uri = g_strdup_printf ("gphoto2://[usb:%s,%s]/%s", usb_bus_num, usb_device_num,
+ store_path[0] == '/' ? store_path + 1 : store_path);
+ }
+ /* g_debug ("gudev_add_camera: ... adding URI for storage head: %s", uri); */
+@@ -608,7 +604,7 @@ update_all (GGPhoto2VolumeMonitor *monitor,
+ #endif
+
+ static GList *
+-get_stores_for_camera (int bus_num, int device_num)
++get_stores_for_camera (const char *bus_num, const char *device_num)
+ {
+ GList *l;
+ CameraStorageInformation *storage_info;
+@@ -624,7 +620,7 @@ get_stores_for_camera (int bus_num, int device_num)
+ camera = NULL;
+ context = NULL;
+ l = NULL;
+- port = g_strdup_printf ("usb:%d,%d", bus_num, device_num);
++ port = g_strdup_printf ("usb:%s,%s", bus_num, device_num);
+
+ /* Connect to the camera */
+ context = gp_context_new ();
+@@ -686,6 +682,21 @@ out:
+ }
+
+ #ifndef HAVE_GUDEV
++static GList *
++get_stores_for_camera_int (int bus_num, int device_num)
++{
++ GList *ret;
++ char *bus_num_str, *device_num_str;
++
++ bus_num_str = g_strdup_printf ("%d", bus_num);
++ device_num_str = g_strdup_printf ("%d", device_num);
++ ret = get_stores_for_camera (bus_num_str, device_num_str);
++ g_free (bus_num_str);
++ g_free (device_num_str);
++
++ return ret;
++}
++
+ static void
+ update_cameras (GGPhoto2VolumeMonitor *monitor,
+ GList **added_volumes,
+@@ -781,7 +792,7 @@ update_cameras (GGPhoto2VolumeMonitor *monitor,
+ # error "Need OS specific tweaks"
+ #endif
+
+- store_heads = get_stores_for_camera (usb_bus_num, usb_device_num);
++ store_heads = get_stores_for_camera_int (usb_bus_num, usb_device_num);
+ num_store_heads = g_list_length (store_heads);
+ for (l = store_heads ; l != NULL; l = l->next)
+ {
+--
+cgit v0.8.3.1
diff --git a/gvfs.spec b/gvfs.spec
index 067849c..fea764e 100644
--- a/gvfs.spec
+++ b/gvfs.spec
@@ -1,7 +1,7 @@
Summary: Backends for the gio framework in GLib
Name: gvfs
Version: 1.6.4
-Release: 2%{?dist}
+Release: 3%{?dist}
License: LGPLv2+
Group: System Environment/Libraries
URL: http://www.gtk.org
@@ -46,6 +46,13 @@ Patch16: gvfs-1.6.2-stringv-dbus.patch
# from upstream
Patch17: gvfs-1.6.5-sftp-poll-timeout.patch
+# https://bugzilla.gnome.org/show_bug.cgi?id=627567
+# Data loss when writing files
+Patch18: gvfs-1.6.5-fuse-open-trunc-support.patch
+
+# from upstream
+Patch19: gvfs-1.6.5-gphoto-addresses.patch
+
Obsoletes: gnome-mount <= 0.8
Obsoletes: gnome-mount-nautilus-properties <= 0.8
@@ -145,6 +152,8 @@ including phones and music players to applications using gvfs.
%patch15 -p1 -b .gphoto2-storageinfo
%patch16 -p1 -b .stringv-dbus
%patch17 -p1 -b .sftp-timeout
+%patch18 -p1 -b .fuse-trunc
+%patch19 -p1 -b .gphoto-addresses
%build
@@ -314,6 +323,10 @@ killall -USR1 gvfsd >&/dev/null || :
%endif
%changelog
+* Mon Nov 1 2010 Tomas Bzatek <tbzatek at redhat.com> - 1.6.4-3
+- Use correct "usb:" address for GPhoto mounts with gudev (#642836)
+- FUSE: Add O_TRUNC support for open()
+
* Mon Oct 4 2010 Tomas Bzatek <tbzatek at redhat.com> - 1.6.4-2
- Fix sftp poll timeout
More information about the scm-commits
mailing list