|
|
769c0b |
--- gvfs-1.16.4/daemon/gvfsbackendmtp.c.fix-mtp-crashes 2013-12-06 19:28:25.533794671 +0100
|
|
|
769c0b |
+++ gvfs-1.16.4/daemon/gvfsbackendmtp.c 2013-12-06 19:34:20.805997988 +0100
|
|
|
769c0b |
@@ -125,6 +125,18 @@ typedef struct {
|
|
|
769c0b |
} RWHandle;
|
|
|
769c0b |
|
|
|
769c0b |
|
|
|
769c0b |
+#define FAIL_DURING_UNMOUNT() \
|
|
|
769c0b |
+ if (g_atomic_int_get (&G_VFS_BACKEND_MTP(backend)->unmount_started)) { \
|
|
|
769c0b |
+ DEBUG ("(I) aborting due to unmount"); \
|
|
|
769c0b |
+ g_vfs_job_failed_literal (G_VFS_JOB (job), \
|
|
|
769c0b |
+ G_IO_ERROR, G_IO_ERROR_CLOSED, \
|
|
|
769c0b |
+ _("The connection is closed")); \
|
|
|
769c0b |
+ goto exit; \
|
|
|
769c0b |
+ }
|
|
|
769c0b |
+
|
|
|
769c0b |
+
|
|
|
769c0b |
+
|
|
|
769c0b |
+
|
|
|
769c0b |
/************************************************
|
|
|
769c0b |
* Initialization
|
|
|
769c0b |
************************************************/
|
|
|
769c0b |
@@ -863,6 +875,8 @@ do_enumerate (GVfsBackend *backend,
|
|
|
769c0b |
|
|
|
769c0b |
g_mutex_lock (&G_VFS_BACKEND_MTP (backend)->mutex);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
LIBMTP_mtpdevice_t *device;
|
|
|
769c0b |
device = op_backend->device;
|
|
|
769c0b |
|
|
|
769c0b |
@@ -1018,6 +1032,8 @@ do_query_info (GVfsBackend *backend,
|
|
|
769c0b |
DEBUG ("(I) do_query_info (filename = %s) ", filename);
|
|
|
769c0b |
g_mutex_lock (&G_VFS_BACKEND_MTP (backend)->mutex);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
gchar **elements = g_strsplit_set (filename, "/", -1);
|
|
|
769c0b |
unsigned int ne = g_strv_length (elements);
|
|
|
769c0b |
|
|
|
769c0b |
@@ -1094,6 +1110,8 @@ do_query_fs_info (GVfsBackend *backend,
|
|
|
769c0b |
gchar **elements = g_strsplit_set (filename, "/", -1);
|
|
|
769c0b |
unsigned int ne = g_strv_length (elements);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
LIBMTP_mtpdevice_t *device;
|
|
|
769c0b |
device = G_VFS_BACKEND_MTP (backend)->device;
|
|
|
769c0b |
|
|
|
769c0b |
@@ -1161,6 +1179,8 @@ do_make_directory (GVfsBackend *backend,
|
|
|
769c0b |
gchar **elements = g_strsplit_set (filename, "/", -1);
|
|
|
769c0b |
unsigned int ne = g_strv_length (elements);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
if (ne < 3) {
|
|
|
769c0b |
g_vfs_job_failed_literal (G_VFS_JOB (job),
|
|
|
769c0b |
G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
769c0b |
@@ -1217,6 +1237,8 @@ do_pull (GVfsBackend *backend,
|
|
|
769c0b |
gchar **elements = g_strsplit_set (source, "/", -1);
|
|
|
769c0b |
unsigned int ne = g_strv_length (elements);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
if (ne < 3) {
|
|
|
769c0b |
g_vfs_job_failed_literal (G_VFS_JOB (job),
|
|
|
769c0b |
G_IO_ERROR, G_IO_ERROR_NOT_REGULAR_FILE,
|
|
|
769c0b |
@@ -1292,6 +1314,8 @@ do_push (GVfsBackend *backend,
|
|
|
769c0b |
gchar **elements = g_strsplit_set (destination, "/", -1);
|
|
|
769c0b |
unsigned int ne = g_strv_length (elements);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
if (ne < 3) {
|
|
|
769c0b |
g_vfs_job_failed_literal (G_VFS_JOB (job),
|
|
|
769c0b |
G_IO_ERROR, G_IO_ERROR_NOT_REGULAR_FILE,
|
|
|
769c0b |
@@ -1390,6 +1414,8 @@ do_delete (GVfsBackend *backend,
|
|
|
769c0b |
gchar **elements = g_strsplit_set (filename, "/", -1);
|
|
|
769c0b |
unsigned int ne = g_strv_length (elements);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
if (ne < 3) {
|
|
|
769c0b |
g_vfs_job_failed_literal (G_VFS_JOB (job),
|
|
|
769c0b |
G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
769c0b |
@@ -1428,6 +1454,8 @@ do_set_display_name (GVfsBackend *backen
|
|
|
769c0b |
DEBUG ("(I) do_set_display_name '%s' --> '%s' ", filename, display_name);
|
|
|
769c0b |
g_mutex_lock (&G_VFS_BACKEND_MTP (backend)->mutex);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
gchar **elements = g_strsplit_set (filename, "/", -1);
|
|
|
769c0b |
unsigned int ne = g_strv_length (elements);
|
|
|
769c0b |
|
|
|
769c0b |
@@ -1531,6 +1559,8 @@ do_open_icon_for_read (GVfsBackend *back
|
|
|
769c0b |
DEBUG ("(I) do_open_icon_for_read (%s)", icon_id);
|
|
|
769c0b |
g_mutex_lock (&G_VFS_BACKEND_MTP (backend)->mutex);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
guint id = strtol (icon_id, NULL, 10);
|
|
|
769c0b |
|
|
|
769c0b |
if (id > 0) {
|
|
|
769c0b |
@@ -1606,6 +1636,8 @@ do_seek_on_read (GVfsBackend *backend,
|
|
|
769c0b |
DEBUG ("(I) do_seek_on_read (%u %lu %ld %u)", id, old_offset, offset, type);
|
|
|
769c0b |
g_mutex_lock (&G_VFS_BACKEND_MTP (backend)->mutex);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
if (type == G_SEEK_END) {
|
|
|
769c0b |
offset = size + offset;
|
|
|
769c0b |
} else if (type == G_SEEK_CUR) {
|
|
|
769c0b |
@@ -1644,6 +1676,8 @@ do_read (GVfsBackend *backend,
|
|
|
769c0b |
DEBUG ("(I) do_read (%u %lu %lu)", id, offset, bytes_requested);
|
|
|
769c0b |
g_mutex_lock (&G_VFS_BACKEND_MTP (backend)->mutex);
|
|
|
769c0b |
|
|
|
769c0b |
+ FAIL_DURING_UNMOUNT();
|
|
|
769c0b |
+
|
|
|
769c0b |
uint32_t actual;
|
|
|
769c0b |
if (handle->handle_type == HANDLE_FILE) {
|
|
|
769c0b |
unsigned char *temp;
|