static char * get_render_node_from_id_path_tag(struct udev *udev, char *id_path_tag, char another_tag) { struct udev_device *device; struct udev_enumerate *e; struct udev_list_entry *entry; const char *path, *id_path_tag_tmp; char *path_res; char found = 0; UDEV_SYMBOL(struct udev_enumerate *, udev_enumerate_new, (struct udev *)); UDEV_SYMBOL(int, udev_enumerate_add_match_subsystem, (struct udev_enumerate *, const char *)); UDEV_SYMBOL(int, udev_enumerate_add_match_sysname, (struct udev_enumerate *, const char *)); UDEV_SYMBOL(int, udev_enumerate_scan_devices, (struct udev_enumerate *)); UDEV_SYMBOL(struct udev_list_entry *, udev_enumerate_get_list_entry, (struct udev_enumerate *)); UDEV_SYMBOL(struct udev_list_entry *, udev_list_entry_get_next, (struct udev_list_entry *)); UDEV_SYMBOL(const char *, udev_list_entry_get_name, (struct udev_list_entry *)); UDEV_SYMBOL(struct udev_device *, udev_device_new_from_syspath, (struct udev *, const char *)); UDEV_SYMBOL(const char *, udev_device_get_property_value, (struct udev_device *, const char *)); UDEV_SYMBOL(const char *, udev_device_get_devnode, (struct udev_device *)); UDEV_SYMBOL(struct udev_device *, udev_device_unref, (struct udev_device *)); e = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(e, "drm"); udev_enumerate_add_match_sysname(e, "render*"); udev_enumerate_scan_devices(e); udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { path = udev_list_entry_get_name(entry); device = udev_device_new_from_syspath(udev, path); if (!device) continue; id_path_tag_tmp = udev_device_get_property_value(device, "ID_PATH_TAG"); if (id_path_tag_tmp) { if ((!another_tag && !strcmp(id_path_tag, id_path_tag_tmp)) || (another_tag && strcmp(id_path_tag, id_path_tag_tmp))) { found = 1; break; } } udev_device_unref(device); }
static gboolean handle_get_tree_from_device (GVfsMetadata *object, GDBusMethodInvocation *invocation, guint arg_major, guint arg_minor) { char *res = NULL; #ifdef HAVE_LIBUDEV dev_t devnum = makedev (arg_major, arg_minor); struct udev_device *dev; const char *uuid, *label; static struct udev *udev; if (udev == NULL) udev = udev_new (); dev = udev_device_new_from_devnum (udev, 'b', devnum); uuid = udev_device_get_property_value (dev, "ID_FS_UUID_ENC"); res = NULL; if (uuid) { res = g_strconcat ("uuid-", uuid, NULL); } else { label = udev_device_get_property_value (dev, "ID_FS_LABEL_ENC"); if (label) res = g_strconcat ("label-", label, NULL); } udev_device_unref (dev); #endif gvfs_metadata_complete_get_tree_from_device (object, invocation, res ? res : ""); g_free (res); return TRUE; }
static int device_update_description(Unit *u, struct udev_device *dev, const char *path) { const char *model; int r; assert(u); assert(dev); assert(path); model = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE"); if (!model) model = udev_device_get_property_value(dev, "ID_MODEL"); if (model) { const char *label; /* Try to concatenate the device model string with a label, if there is one */ label = udev_device_get_property_value(dev, "ID_FS_LABEL"); if (!label) label = udev_device_get_property_value(dev, "ID_PART_ENTRY_NAME"); if (!label) label = udev_device_get_property_value(dev, "ID_PART_ENTRY_NUMBER"); if (label) { _cleanup_free_ char *j; j = strjoin(model, " ", label); if (j) r = unit_set_description(u, j); else r = -ENOMEM; } else r = unit_set_description(u, model); } else r = unit_set_description(u, path); if (r < 0) log_unit_error_errno(u, r, "Failed to set device description: %m"); return r; }
char * device_create_mountpoint (struct device_t *device) { char tmp[256]; char *c; strcpy(tmp, "/media/"); if (udev_device_get_property_value(device->udev, "ID_FS_LABEL") != NULL) strcat(tmp, udev_device_get_property_value(device->udev, "ID_FS_LABEL")); else if (udev_device_get_property_value(device->udev, "ID_FS_UUID") != NULL) strcat(tmp, udev_device_get_property_value(device->udev, "ID_FS_UUID")); else if (udev_device_get_property_value(device->udev, "ID_SERIAL") != NULL) strcat(tmp, udev_device_get_property_value(device->udev, "ID_SERIAL")); /* Replace the whitespaces */ for (c = (char*)&tmp; *c; c++) { if (*c == ' ') *c = '_'; } /* It can't fail as every disc should have at least the serial */ return s_strdup(tmp); }
static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool test) { int r; const char *path = NULL, *seat; bool changed_acl = false; uid_t uid; umask(0022); /* don't muck around with ACLs when the system is not running systemd */ if (!logind_running()) return 0; path = udev_device_get_devnode(dev); seat = udev_device_get_property_value(dev, "ID_SEAT"); if (!seat) seat = "seat0"; r = sd_seat_get_active(seat, NULL, &uid); if (r == -ENOENT) { /* No active session on this seat */ r = 0; goto finish; } else if (r < 0) { log_error("Failed to determine active user on seat %s.", seat); goto finish; } r = devnode_acl(path, true, false, 0, true, uid); if (r < 0) { log_error("Failed to apply ACL on %s: %s", path, strerror(-r)); goto finish; } changed_acl = true; r = 0; finish: if (path && !changed_acl) { int k; /* Better be safe than sorry and reset ACL */ k = devnode_acl(path, true, false, 0, false, 0); if (k < 0) { log_error("Failed to apply ACL on %s: %s", path, strerror(-k)); if (r >= 0) r = k; } } return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }
char * dri2_get_driver_for_fd(int fd) { struct udev *udev; struct udev_device *device, *parent; const char *pci_id; char *driver = NULL; int vendor_id, chip_id, i, j; udev = udev_new(); device = dri2_udev_device_new_from_fd(udev, fd); if (device == NULL) return NULL; parent = udev_device_get_parent(device); if (parent == NULL) { _eglLog(_EGL_WARNING, "DRI2: could not get parent device"); goto out; } pci_id = udev_device_get_property_value(parent, "PCI_ID"); if (pci_id == NULL || sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) { _eglLog(_EGL_WARNING, "EGL-DRI2: malformed or no PCI ID"); goto out; } for (i = 0; driver_map[i].driver; i++) { if (vendor_id != driver_map[i].vendor_id) continue; if (driver_map[i].num_chips_ids == -1) { driver = strdup(driver_map[i].driver); _eglLog(_EGL_DEBUG, "pci id for %d: %04x:%04x, driver %s", fd, vendor_id, chip_id, driver); goto out; } for (j = 0; j < driver_map[i].num_chips_ids; j++) if (driver_map[i].chip_ids[j] == chip_id) { driver = strdup(driver_map[i].driver); _eglLog(_EGL_DEBUG, "pci id for %d: %04x:%04x, driver %s", fd, vendor_id, chip_id, driver); goto out; } } out: udev_device_unref(device); udev_unref(udev); return driver; }
static int libudev_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id) { struct udev *udev = NULL; struct udev_device *device = NULL, *parent; const char *pci_id; UDEV_SYMBOL(struct udev *, udev_new, (void)); UDEV_SYMBOL(struct udev_device *, udev_device_get_parent, (struct udev_device *)); UDEV_SYMBOL(const char *, udev_device_get_property_value, (struct udev_device *, const char *)); UDEV_SYMBOL(struct udev_device *, udev_device_unref, (struct udev_device *)); UDEV_SYMBOL(struct udev *, udev_unref, (struct udev *)); *chip_id = -1; if (dlsym_failed) return 0; udev = udev_new(); device = udev_device_new_from_fd(udev, fd); if (!device) goto out; parent = udev_device_get_parent(device); if (parent == NULL) { log_(_LOADER_WARNING, "MESA-LOADER: could not get parent device\n"); goto out; } pci_id = udev_device_get_property_value(parent, "PCI_ID"); if (pci_id == NULL) { log_(_LOADER_INFO, "MESA-LOADER: no PCI ID\n"); *chip_id = -1; goto out; } else if (sscanf(pci_id, "%x:%x", vendor_id, chip_id) != 2) { log_(_LOADER_WARNING, "MESA-LOADER: malformed PCI ID\n"); *chip_id = -1; goto out; } out: if (device) udev_device_unref(device); if (udev) udev_unref(udev); return (*chip_id >= 0); }
static bool is_hotplug(uint32_t drm_id, struct udev_device *device) { uint32_t id; const char *sysnum; if (!(sysnum = udev_device_get_sysnum(device)) || !chck_cstr_to_u32(sysnum, &id) || id != drm_id) return false; const char *val; if (!(val = udev_device_get_property_value(device, "HOTPLUG"))) return false; return chck_cstreq(val, "1"); }
/* * Here we try to find the "modem device". * * In this variant we identify the "modem device" as simply the device * that has the OFONO_DRIVER property. If the device node doesn't * have this property itself, then we do a brute force search for it * through the device hierarchy. * */ static struct udev_device* get_serial_modem_device(struct udev_device *dev) { const char* driver; while (dev) { driver = udev_device_get_property_value(dev, "OFONO_DRIVER"); if (driver) return dev; dev = udev_device_get_parent(dev); } return NULL; }
static gboolean setup_ifx(struct modem_info* modem) { struct serial_device_info* info; const char *value; info = modem->serial; value = udev_device_get_property_value(info->dev, "OFONO_IFX_LDISC"); if (value) ofono_modem_set_string(modem->modem, "LineDiscipline", value); value = udev_device_get_property_value(info->dev, "OFONO_IFX_AUDIO"); if (value) ofono_modem_set_string(modem->modem, "AudioSetting", value); value = udev_device_get_property_value(info->dev, "OFONO_IFX_LOOPBACK"); if (value) ofono_modem_set_string(modem->modem, "AudioLoopback", value); ofono_modem_set_string(modem->modem, "Device", info->devnode); return TRUE; }
static int manager_udev_fn(sd_event_source *source, int fd, uint32_t mask, void *data) { _cleanup_udev_device_ struct udev_device *d = NULL; struct manager *m = data; const char *action, *ifname; unsigned int ifindex; struct link *l; d = udev_monitor_receive_device(m->udev_mon); if (!d) return 0; ifindex = ifindex_from_udev_device(d); if (!ifindex) return 0; l = manager_find_link(m, ifindex); action = udev_device_get_action(d); if (action && !strcmp(action, "remove")) { if (l) link_free(l); } else if (l) { ifname = udev_device_get_property_value(d, "INTERFACE"); if (action && !strcmp(action, "move")) { if (ifname) link_renamed(l, ifname); } #ifdef RELY_UDEV if (udev_device_has_tag(d, "miracle") && !lazy_managed) link_set_managed(l, true); else link_set_managed(l, false); #else if ((!interface_name || !strcmp(interface_name, ifname)) && !lazy_managed) { link_set_managed(l, true); } else { log_debug("ignored device: %s", ifname); } #endif } else { manager_add_udev_link(m, d); } return 0; }
bool CUDevProvider::PumpDriveChangeEvents(IStorageEventsCallback *callback) { bool changed = false; fd_set readfds; FD_ZERO(&readfds); FD_SET(udev_monitor_get_fd(m_udevMon), &readfds); // non-blocking, check the file descriptor for received data struct timeval tv = {0}; int count = select(udev_monitor_get_fd(m_udevMon) + 1, &readfds, NULL, NULL, &tv); if (count < 0) return false; if (FD_ISSET(udev_monitor_get_fd(m_udevMon), &readfds)) { struct udev_device *dev = udev_monitor_receive_device(m_udevMon); if (!dev) return false; const char *action = udev_device_get_action(dev); const char *devtype = udev_device_get_devtype(dev); if (action) { const char *label = udev_device_get_property_value(dev, "ID_FS_LABEL"); const char *mountpoint = get_mountpoint(udev_device_get_devnode(dev)); if (!label) label = URIUtils::GetFileName(mountpoint); if (!strcmp(action, "add") && !strcmp(devtype, "partition")) { CLog::Log(LOGNOTICE, "UDev: Added %s", mountpoint); if (callback) callback->OnStorageAdded(label, mountpoint); changed = true; } if (!strcmp(action, "remove") && !strcmp(devtype, "partition")) { CLog::Log(LOGNOTICE, "UDev: Removed %s", mountpoint); if (callback) callback->OnStorageSafelyRemoved(label); changed = true; } } udev_device_unref(dev); } return changed; }
struct fstab_node_t * fstab_search (struct fstab_t *fstab, struct device_t *device) { struct fstab_node_t *node; const char *tmp; for (node = fstab->head; node; node = node->next) { if (!strncasecmp(node->node, "UUID=", 5)) { tmp = udev_device_get_property_value(device->udev, "ID_FS_UUID_ENC"); if (tmp && !strcmp(node->node + 5, tmp)) return node; } else if (!strncasecmp(node->node, "LABEL=", 6)) { tmp = udev_device_get_property_value(device->udev, "ID_FS_LABEL_ENC"); if (tmp && !strcmp(node->node + 6, tmp)) return node; } else if (!strcmp(node->node, device->devnode)) return node; } return NULL; }
const char * udev_prop_value(struct udev_device *device, const char *prop_name) { struct udev_device *parent; const char *prop_value = NULL; parent = device; while (parent && !prop_value) { prop_value = udev_device_get_property_value(parent, prop_name); parent = udev_device_get_parent(parent); } return prop_value; }
EAPI const char * eeze_udev_syspath_get_subsystem(const char *syspath) { _udev_device *device; const char *subsystem; if (!syspath) return NULL; if (!(device = _new_device(syspath))) return NULL; subsystem = eina_stringshare_add(udev_device_get_property_value(device, "SUBSYSTEM")); udev_device_unref(device); return subsystem; }
bool match(udev_device* device) const { const char* str = udev_device_get_property_value(device, m_name.c_str()); log_debug("matching property '" << m_name << "' with value '" << (str?str:"(null)") << "' against '" << m_value); if (!str) { return false; } else { return (m_value == str); } }
static gboolean setup_wavecom(struct modem_info* modem) { struct serial_device_info* info; const char *value; info = modem->serial; value = udev_device_get_property_value(info->dev, "OFONO_WAVECOM_MODEL"); if (value) ofono_modem_set_string(modem->modem, "Model", value); ofono_modem_set_string(modem->modem, "Device", info->devnode); return TRUE; }
static void manager_add_udev_link(struct manager *m, struct udev_device *d) { struct link *l; unsigned int ifindex; const char *ifname; int r; ifindex = ifindex_from_udev_device(d); if (!ifindex) return; ifname = udev_device_get_property_value(d, "INTERFACE"); if (!ifname) return; if (interface_name && strcmp(interface_name, ifname)) { return; } /* ignore dynamic p2p interfaces */ if (shl_startswith(ifname, "p2p-")) return; r = link_new(m, ifindex, ifname, &l); if (r < 0) return; if (m->friendly_name && l->managed) link_set_friendly_name(l, m->friendly_name); if (m->config_methods) link_set_config_methods(l, m->config_methods); if(use_dev) link_use_dev(l); #ifdef RELY_UDEV bool managed = udev_device_has_tag(d, "miracle") && !lazy_managed; #else bool managed = (!interface_name || !strcmp(interface_name, ifname)) && !lazy_managed; #endif if (managed) { link_set_managed(l, true); } else { log_debug("ignored device: %s", ifname); } }
static int linux_get_pciid_from_fd(int fd, unsigned *vendor_id, unsigned *chip_id) { struct udev *udev; struct udev_device *device; struct udev_device *parent; const char *pci_id; struct stat buffer; int ret; ret = fstat(fd, &buffer); if (ret) return -EINVAL; if (!S_ISCHR(buffer.st_mode)) return -EINVAL; udev = udev_new(); if (!udev) return -ENOMEM; device = udev_device_new_from_devnum(udev, 'c', buffer.st_rdev); if (!device) goto err_free_udev; parent = udev_device_get_parent(device); if (!parent) goto err_free_device; pci_id = udev_device_get_property_value(parent, "PCI_ID"); if (!pci_id) goto err_free_device; if (sscanf(pci_id, "%x:%x", vendor_id, chip_id) != 2) goto err_free_device; udev_device_unref(device); udev_unref(udev); return 0; err_free_device: udev_device_unref(device); err_free_udev: udev_unref(udev); return -EINVAL; }
static Bool check_seat(struct udev_device *udev_device) { const char *dev_seat; dev_seat = udev_device_get_property_value(udev_device, "ID_SEAT"); if (!dev_seat) dev_seat = "seat0"; if (SeatId && strcmp(dev_seat, SeatId)) return FALSE; if (!SeatId && strcmp(dev_seat, "seat0")) return FALSE; return TRUE; }
static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device *srcdev, const char *subsystem, const char *prefix, const char *filter, bool test) { struct udev_device *d; char s[16]; bool last = false; int r = 0; assert(dev); if (!srcdev) srcdev = dev; for (d = srcdev; d && !last; d = udev_device_get_parent(d)) { const char *dsubsys; const char *modalias = NULL; dsubsys = udev_device_get_subsystem(d); if (!dsubsys) continue; /* look only at devices of a specific subsystem */ if (subsystem && !streq(dsubsys, subsystem)) continue; modalias = udev_device_get_property_value(d, "MODALIAS"); if (streq(dsubsys, "usb") && streq_ptr(udev_device_get_devtype(d), "usb_device")) { /* if the usb_device does not have a modalias, compose one */ if (!modalias) modalias = modalias_usb(d, s, sizeof(s)); /* avoid looking at any parent device, they are usually just a USB hub */ last = true; } if (!modalias) continue; r = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test); if (r > 0) break; } return r; }
char * dri2_get_driver_for_fd(int fd) { struct udev *udev; struct udev_device *device, *parent; const char *pci_id; char *driver = NULL; int vendor_id, chip_id, i, j; udev = udev_new(); device = dri2_udev_device_new_from_fd(udev, fd); if (device == NULL) return NULL; parent = udev_device_get_parent(device); if (parent == NULL) { goto out; } pci_id = udev_device_get_property_value(parent, "PCI_ID"); if (pci_id == NULL || sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) { goto out; } for (i = 0; driver_map[i].driver; i++) { if (vendor_id != driver_map[i].vendor_id) continue; if (driver_map[i].num_chips_ids == -1) { driver = strdup(driver_map[i].driver); goto out; } for (j = 0; j < driver_map[i].num_chips_ids; j++) if (driver_map[i].chip_ids[j] == chip_id) { driver = strdup(driver_map[i].driver); goto out; } } out: udev_device_unref(device); udev_unref(udev); return driver; }
static enum icd_drm_minor_type get_minor_type(struct udev_device *minor_dev) { const char *minor; minor = udev_device_get_property_value(minor_dev, "MINOR"); if (!minor) return ICD_DRM_MINOR_INVALID; switch (atoi(minor) >> 6) { case 0: return ICD_DRM_MINOR_LEGACY; case 2: return ICD_DRM_MINOR_RENDER; default: return ICD_DRM_MINOR_INVALID; } }
/** Open the first DRM device matching the criteria */ int drm_open_matching(const char *pci_glob, int flags, int *vendor_id, int *device_id) { struct udev *udev; struct udev_enumerate *e; struct udev_device *device, *parent; struct udev_list_entry *entry; const char *pci_id, *path; char *tmp; int fd; *vendor_id = 0; *device_id = 0; udev = udev_new(); if (udev == NULL) { fprintf(stderr, "failed to initialize udev context\n"); return -1; //abort(); } fd = -1; e = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(e, "drm"); udev_enumerate_scan_devices(e); udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { path = udev_list_entry_get_name(entry); device = udev_device_new_from_syspath(udev, path); parent = udev_device_get_parent(device); /* Filter out KMS output devices. */ if (strcmp(udev_device_get_subsystem(parent), "pci") != 0) continue; pci_id = udev_device_get_property_value(parent, "PCI_ID"); if (fnmatch(pci_glob, pci_id, 0) != 0) continue; fd = open(udev_device_get_devnode(device), O_RDWR); if (fd < 0) continue; if ((flags & DRM_TEST_MASTER) && !is_master(fd)) { close(fd); fd = -1; continue; } break; }
/** * Get the property value of a device from the /sys/ path. * * @param syspath The /sys/ path with or without the /sys/ * @param property The property to get; full list of these is a FIXME * @return A stringshared char* with the property or NULL on failure */ EAPI const char * eeze_udev_syspath_get_property(const char *syspath, const char *property) { _udev_device *device; const char *value = NULL, *test; if (!syspath || !property) return NULL; if (!(device = _new_device(syspath))) return NULL; if ((test = udev_device_get_property_value(device, property))) value = eina_stringshare_add(test); udev_device_unref(device); return value; }
static char *disk_udev_attr_name (struct udev *udev, char *disk_name, const char *attr) { struct udev_device *dev; const char *prop; char *output = NULL; dev = udev_device_new_from_subsystem_sysname (udev, "block", disk_name); if (dev != NULL) { prop = udev_device_get_property_value (dev, attr); if (prop) { output = strdup (prop); DEBUG ("disk plugin: renaming %s => %s", disk_name, output); } udev_device_unref (dev); } return output; }
EAPI Eina_Bool eeze_udev_syspath_check_property(const char *syspath, const char *property, const char *value) { _udev_device *device; const char *test; Eina_Bool ret = EINA_FALSE; if (!syspath || !property || !value) return EINA_FALSE; if (!(device = _new_device(syspath))) return EINA_FALSE; if ((test = udev_device_get_property_value(device, property))) ret = !strcmp(test, value); udev_device_unref(device); return ret; }
/* * Try to parse /sys/block/sda/device/vpd_pg83 for VPD83 NAA ID first. * This sysfs file is missing in some older kernel(like RHEL6), we use udev * ID_WWN_WITH_EXTENSION property instead, even through ID_WWN_WITH_EXTENSION * does not mean VPD83 NAA ID, this is the only workaround I could found for * old system without root privilege. * Input *vpd83 should be char[_MAX_VPD83_NAA_ID_LEN], assuming caller did * the check. * The maximum *sd_name strlen is (_MAX_SD_NAME_STR_LEN - 1), assuming caller * did the check. */ static int _udev_vpd83_of_sd_name(char *err_msg, const char *sd_name, char *vpd83) { struct udev *udev = NULL; struct udev_device *sd_udev = NULL; int rc = LSM_ERR_OK; const char *wwn = NULL; char sys_path[_MAX_SYSFS_BLK_PATH_STR_LEN]; memset(vpd83, 0, _MAX_VPD83_NAA_ID_LEN); snprintf(sys_path, _MAX_SYSFS_BLK_PATH_STR_LEN, _SYSFS_BLK_PATH_FORMAT, sd_name); udev = udev_new(); if (udev == NULL) { rc = LSM_ERR_NO_MEMORY; goto out; } sd_udev = udev_device_new_from_syspath(udev, sys_path); if (sd_udev == NULL) { _lsm_err_msg_set(err_msg, "Provided disk not found"); rc = LSM_ERR_NOT_FOUND_DISK; goto out; } wwn = udev_device_get_property_value(sd_udev, "ID_WWN_WITH_EXTENSION"); if (wwn == NULL) goto out; if (strncmp(wwn, "0x", strlen("0x")) == 0) wwn += strlen("0x"); snprintf(vpd83, _MAX_VPD83_NAA_ID_LEN, wwn); out: if (udev != NULL) udev_unref(udev); if (sd_udev != NULL) udev_device_unref(sd_udev); return rc; }
bool QDeviceDiscovery::checkDeviceType(udev_device *dev) { if (!dev) return false; if ((m_types & Device_Keyboard) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 )) { const char *capabilities_key = udev_device_get_sysattr_value(dev, "capabilities/key"); QStringList val = QString::fromUtf8(capabilities_key).split(QString::fromUtf8(" "), QString::SkipEmptyParts); if (!val.isEmpty()) { bool ok; unsigned long long keys = val.last().toULongLong(&ok, 16); if (ok) { // Tests if the letter Q is valid for the device. We may want to alter this test, but it seems mostly reliable. bool test = (keys >> KEY_Q) & 1; if (test) return true; } } }
QVariant Device::deviceProperty(const QString &name) const { if (!d) return QVariant(); QByteArray propName = name.toLatin1(); QString propValue = QString::fromLatin1(udev_device_get_property_value(d->udev, propName.constData())); if (!propValue.isEmpty()) { return QVariant::fromValue(propValue); } return QVariant(); }