您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ udev_device_get_property_value函数代码示例

51自学网 2021-06-03 09:05:53
  C++
这篇教程C++ udev_device_get_property_value函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中udev_device_get_property_value函数的典型用法代码示例。如果您正苦于以下问题:C++ udev_device_get_property_value函数的具体用法?C++ udev_device_get_property_value怎么用?C++ udev_device_get_property_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了udev_device_get_property_value函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: get_render_node_from_id_path_tag

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);   }
开发者ID:TechnoMancer,项目名称:mesa,代码行数:54,


示例2: handle_get_tree_from_device

static gbooleanhandle_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;}
开发者ID:gicmo,项目名称:gvfs,代码行数:41,


示例3: QVariant

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();}
开发者ID:gustavosbarreto,项目名称:libqsolid,代码行数:12,


示例4: device_create_mountpoint

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);}
开发者ID:vodik,项目名称:ldm,代码行数:25,


示例5: device_update_description

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;}
开发者ID:aulanov,项目名称:systemd,代码行数:40,


示例6: dri2_get_driver_for_fd

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;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:52,


示例7: builtin_uaccess

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;}
开发者ID:MOBO-OSS,项目名称:systemd-relative,代码行数:52,


示例8: libudev_get_pci_id_for_fd

static intlibudev_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);}
开发者ID:ashmew2,项目名称:kolibriosSVN,代码行数:50,


示例9: is_hotplug

static boolis_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");}
开发者ID:Azarn,项目名称:wlc,代码行数:14,


示例10: manager_udev_fn

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;}
开发者ID:albfan,项目名称:miraclecast,代码行数:50,


示例11: get_serial_modem_device

/* * 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;}
开发者ID:endocode,项目名称:ofono,代码行数:23,


示例12: setup_ifx

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;}
开发者ID:endocode,项目名称:ofono,代码行数:23,


示例13: FD_ZERO

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;}
开发者ID:Anankin,项目名称:xbmc,代码行数:49,


示例14: fstab_search

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;}
开发者ID:vodik,项目名称:ldm,代码行数:24,


示例15: udev_prop_value

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;}
开发者ID:libratbag,项目名称:libratbag,代码行数:15,


示例16: match

  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);    }  }
开发者ID:Ape,项目名称:xboxdrv,代码行数:16,


示例17: setup_wavecom

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;}
开发者ID:endocode,项目名称:ofono,代码行数:16,


示例18: linux_get_pciid_from_fd

static intlinux_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;}
开发者ID:alexzeitgeist,项目名称:YT2,代码行数:47,


示例19: manager_add_udev_link

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);	}}
开发者ID:albfan,项目名称:miraclecast,代码行数:47,


示例20: check_seat

static Boolcheck_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;}
开发者ID:cmei,项目名称:xserver,代码行数:17,


示例21: udev_builtin_hwdb_search

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;}
开发者ID:jamespharvey20,项目名称:systemd,代码行数:46,


示例22: dri2_get_driver_for_fd

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;}
开发者ID:axeldavy,项目名称:xf86-video-wlglamor,代码行数:46,


示例23: get_minor_type

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;    }}
开发者ID:DavidYen,项目名称:VulkanTools,代码行数:17,


示例24: drm_open_matching

/** 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;	}
开发者ID:bjsnider,项目名称:vaapi,代码行数:46,


示例25: udev_device_new_from_subsystem_sysname

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;}
开发者ID:zach14c,项目名称:collectd,代码行数:18,


示例26: _udev_vpd83_of_sd_name

/* * 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;}
开发者ID:HP-Scale-out-Storage,项目名称:libstoragemgmt,代码行数:54,


示例27: checkDeviceType

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;            }        }    }
开发者ID:ghjinlei,项目名称:qt5,代码行数:19,



注:本文中的udev_device_get_property_value函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ udev_device_get_sysattr_value函数代码示例
C++ udev_device_get_parent_with_subsystem_devtype函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。