From 4fe3b0f8d24851145b5ceae10eb3181b2340466b Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Wed, 25 Oct 2017 20:28:22 +0200 Subject: mtp: Fix volume removal with current udev behavior UDev events for devices without ID_MTP_DEVICE property are ignored. Although ID_MTP_DEVICE seems don't have to be set for device when removing and thus the volume is not removed. Let's ignore ID_MTP_DEVICE when removing. https://bugzilla.gnome.org/show_bug.cgi?id=789491 --- monitor/mtp/gmtpvolumemonitor.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/monitor/mtp/gmtpvolumemonitor.c b/monitor/mtp/gmtpvolumemonitor.c index 50e37cf..bfd9e29 100644 --- a/monitor/mtp/gmtpvolumemonitor.c +++ b/monitor/mtp/gmtpvolumemonitor.c @@ -208,17 +208,12 @@ on_uevent (GUdevClient *client, gchar *action, GUdevDevice *device, gpointer use g_debug ("on_uevent: action=%s, device=%s", action, g_udev_device_get_device_file(device)); - /* filter out uninteresting events */ - if (!g_udev_device_has_property (device, "ID_MTP_DEVICE")) - { - g_debug ("on_uevent: discarding, not ID_MTP"); - return; - } - - if (strcmp (action, "add") == 0) - gudev_add_device (monitor, device, TRUE); - else if (strcmp (action, "remove") == 0) - gudev_remove_device (monitor, device); + if (g_strcmp0 (action, "add") == 0 && g_udev_device_has_property (device, "ID_MTP_DEVICE")) + gudev_add_device (monitor, device, TRUE); + else if (g_strcmp0 (action, "remove") == 0 && g_udev_device_get_device_file (device) != NULL) + gudev_remove_device (monitor, device); + else + g_debug ("on_uevent: discarding"); } static void -- cgit v0.12 From bcd2a7ac00b5d6cd82e8ddfe9481da8edfe59e6a Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 27 Oct 2017 10:11:20 +0200 Subject: gphoto2: Fix volume removal with current udev behavior UDev events for devices without ID_GPHOTO2 property are ignored. Although ID_GPHOTO2 seems don't have to be set for device when removing and thus the volume is not removed. Let's ignore ID_GPHOTO2 when removing. https://bugzilla.gnome.org/show_bug.cgi?id=789491 --- monitor/gphoto2/ggphoto2volumemonitor.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/monitor/gphoto2/ggphoto2volumemonitor.c b/monitor/gphoto2/ggphoto2volumemonitor.c index f4fae8b..06e07ab 100644 --- a/monitor/gphoto2/ggphoto2volumemonitor.c +++ b/monitor/gphoto2/ggphoto2volumemonitor.c @@ -246,17 +246,12 @@ on_uevent (GUdevClient *client, /* g_debug ("on_uevent: action=%s, device=%s", action, g_udev_device_get_device_file(device)); */ - /* filter out uninteresting events */ - if (!g_udev_device_has_property (device, "ID_GPHOTO2")) - { - /* g_debug ("on_uevent: discarding, not ID_GPHOTO2"); */ - return; - } - - if (strcmp (action, "add") == 0) - gudev_add_camera (monitor, device, TRUE); - else if (strcmp (action, "remove") == 0) - gudev_remove_camera (monitor, device); + if (g_strcmp0 (action, "add") == 0 && g_udev_device_has_property (device, "ID_GPHOTO2")) + gudev_add_camera (monitor, device, TRUE); + else if (g_strcmp0 (action, "remove") == 0 && g_udev_device_get_device_file (device) != NULL) + gudev_remove_camera (monitor, device); + else + g_debug ("on_uevent: discarding"); } /* Find all attached gphoto supported cameras; this is called on startup -- cgit v0.12 From 9bf86aaf229ecbf82777958d55e29ec0d3a2f273 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Tue, 31 Oct 2017 17:31:05 +0100 Subject: monitor: Remove device file checks The device file checks were added by mistake and it is not clear whether it can't have some side-effect. Let's remove them and use g_strcmp0 for sysfs path comparison for sure... https://bugzilla.gnome.org/show_bug.cgi?id=789491 --- monitor/gphoto2/ggphoto2volume.c | 2 +- monitor/gphoto2/ggphoto2volumemonitor.c | 2 +- monitor/mtp/gmtpvolume.c | 2 +- monitor/mtp/gmtpvolumemonitor.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/monitor/gphoto2/ggphoto2volume.c b/monitor/gphoto2/ggphoto2volume.c index c1be77e..21e318b 100644 --- a/monitor/gphoto2/ggphoto2volume.c +++ b/monitor/gphoto2/ggphoto2volume.c @@ -218,7 +218,7 @@ g_gphoto2_volume_has_path (GGPhoto2Volume *volume, G_LOCK (gphoto2_volume); res = FALSE; if (gphoto2_volume->device != NULL) - res = strcmp (g_udev_device_get_sysfs_path (gphoto2_volume->device), sysfs_path) == 0; + res = g_strcmp0 (g_udev_device_get_sysfs_path (gphoto2_volume->device), sysfs_path) == 0; G_UNLOCK (gphoto2_volume); return res; } diff --git a/monitor/gphoto2/ggphoto2volumemonitor.c b/monitor/gphoto2/ggphoto2volumemonitor.c index 06e07ab..83340a2 100644 --- a/monitor/gphoto2/ggphoto2volumemonitor.c +++ b/monitor/gphoto2/ggphoto2volumemonitor.c @@ -248,7 +248,7 @@ on_uevent (GUdevClient *client, if (g_strcmp0 (action, "add") == 0 && g_udev_device_has_property (device, "ID_GPHOTO2")) gudev_add_camera (monitor, device, TRUE); - else if (g_strcmp0 (action, "remove") == 0 && g_udev_device_get_device_file (device) != NULL) + else if (g_strcmp0 (action, "remove") == 0) gudev_remove_camera (monitor, device); else g_debug ("on_uevent: discarding"); diff --git a/monitor/mtp/gmtpvolume.c b/monitor/mtp/gmtpvolume.c index cfd7759..681029f 100644 --- a/monitor/mtp/gmtpvolume.c +++ b/monitor/mtp/gmtpvolume.c @@ -209,7 +209,7 @@ g_mtp_volume_has_path (GMtpVolume *volume, G_LOCK (mtp_volume); res = FALSE; if (mtp_volume->device != NULL) - res = strcmp (g_udev_device_get_sysfs_path (mtp_volume->device), sysfs_path) == 0; + res = g_strcmp0 (g_udev_device_get_sysfs_path (mtp_volume->device), sysfs_path) == 0; G_UNLOCK (mtp_volume); return res; } diff --git a/monitor/mtp/gmtpvolumemonitor.c b/monitor/mtp/gmtpvolumemonitor.c index bfd9e29..1e73db7 100644 --- a/monitor/mtp/gmtpvolumemonitor.c +++ b/monitor/mtp/gmtpvolumemonitor.c @@ -210,7 +210,7 @@ on_uevent (GUdevClient *client, gchar *action, GUdevDevice *device, gpointer use if (g_strcmp0 (action, "add") == 0 && g_udev_device_has_property (device, "ID_MTP_DEVICE")) gudev_add_device (monitor, device, TRUE); - else if (g_strcmp0 (action, "remove") == 0 && g_udev_device_get_device_file (device) != NULL) + else if (g_strcmp0 (action, "remove") == 0) gudev_remove_device (monitor, device); else g_debug ("on_uevent: discarding"); -- cgit v0.12