]> sigrok.org Git - libserialport.git/commitdiff
On Linux, skip virtual ttys that have no parent device.
authorMartin Ling <redacted>
Sun, 27 Oct 2013 12:09:37 +0000 (12:09 +0000)
committerUwe Hermann <redacted>
Thu, 14 Nov 2013 23:42:37 +0000 (00:42 +0100)
serialport.c

index 0895048cf2f1ab7cbb3f0e0e132c0da80c9d98b0..a8f410eea624b1879bfe01173738aba46430fe6e 100644 (file)
@@ -176,7 +176,7 @@ out_release:
        struct udev_list_entry *ud_list;
        struct udev_list_entry *ud_entry;
        const char *path;
-       struct udev_device *ud_dev;
+       struct udev_device *ud_dev, *ud_parent;
        const char *name;
 
        ud = udev_new();
@@ -190,6 +190,13 @@ out_release:
        {
                path = udev_list_entry_get_name(ud_entry);
                ud_dev = udev_device_new_from_syspath(ud, path);
+               /* If there is no parent device, this is a virtual tty. */
+               ud_parent = udev_device_get_parent(ud_dev);
+               if (ud_parent == NULL)
+               {
+                       udev_device_unref(ud_dev);
+                       continue;
+               }
                name = udev_device_get_devnode(ud_dev);
                list = sp_list_append(list, (void *)name, strlen(name) + 1);
                udev_device_unref(ud_dev);