[gvfs] mtp: Ignore devices without a device file



commit 7a6fd7b68bfbe913b56adc5b8d1d6ce4a0718824
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 1 11:08:54 2018 +0100

    mtp: Ignore devices without a device file
    
    If there's no device file, which means libusb won't be able to open the
    device, no need to print a warning, simply ignore the device.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793925

 monitor/mtp/gmtpvolumemonitor.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/monitor/mtp/gmtpvolumemonitor.c b/monitor/mtp/gmtpvolumemonitor.c
index 75884aa..894bcd5 100644
--- a/monitor/mtp/gmtpvolumemonitor.c
+++ b/monitor/mtp/gmtpvolumemonitor.c
@@ -137,19 +137,26 @@ static void
 gudev_add_device (GMtpVolumeMonitor *monitor, GUdevDevice *device, gboolean do_emit)
 {
   GMtpVolume *volume;
-  const char *usb_bus_num, *usb_device_num;
+  const char *usb_bus_num, *usb_device_num, *device_path;
   char *uri;
   GFile *activation_mount_root;
 
+  device_path = g_udev_device_get_device_file (device);
+  if (!device_path) {
+    g_debug ("Ignoring device '%s' without a device file",
+             g_udev_device_get_sysfs_path (device));
+    return;
+  }
+
   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));
+    g_warning ("device %s has no BUSNUM property, ignoring", device_path);
     return;
   }
 
   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));
+    g_warning ("device %s has no DEVNUM property, ignoring", device_path);
     return;
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]