From: Martin Ling Date: Sun, 27 Oct 2013 12:09:37 +0000 (+0000) Subject: On Linux, skip virtual ttys that have no parent device. X-Git-Tag: libserialport-0.1.0~161 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=08fe0bdbdb1a3e10bc7e2b07b317e271ce99049a;p=libserialport.git On Linux, skip virtual ttys that have no parent device. --- diff --git a/serialport.c b/serialport.c index 0895048..a8f410e 100644 --- a/serialport.c +++ b/serialport.c @@ -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);