diff options
author | Bastien Nocera <hadess@hadess.net> | 2018-03-01 11:08:54 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2018-03-01 17:33:22 +0100 |
commit | 7a6fd7b68bfbe913b56adc5b8d1d6ce4a0718824 (patch) | |
tree | ec0d1f0fe0636758d80550c7ac02d4e4375f5b9d | |
parent | 97629179dba1205b512d1e82b9b9fed68a7b30d4 (diff) | |
download | gvfs-7a6fd7b68bfbe913b56adc5b8d1d6ce4a0718824.tar.gz |
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
-rw-r--r-- | 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 75884aaf..894bcd58 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; } |