这篇教程C++ udev_device_get_sysname函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中udev_device_get_sysname函数的典型用法代码示例。如果您正苦于以下问题:C++ udev_device_get_sysname函数的具体用法?C++ udev_device_get_sysname怎么用?C++ udev_device_get_sysname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了udev_device_get_sysname函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: udevGetDeviceProperty/* This function allocates memory from the heap for the property * value. That memory must be later freed by some other code. */static int udevGetDeviceProperty(struct udev_device *udev_device, const char *property_key, char **property_value){ const char *udev_value = NULL; int ret = PROPERTY_FOUND; udev_value = udev_device_get_property_value(udev_device, property_key); if (udev_value == NULL) { VIR_DEBUG("udev reports device '%s' does not have property '%s'", udev_device_get_sysname(udev_device), property_key); ret = PROPERTY_MISSING; goto out; } /* If this allocation is changed, the comment at the beginning * of the function must also be changed. */ *property_value = strdup(udev_value); if (*property_value == NULL) { VIR_ERROR(_("Failed to allocate memory for property value for " "property key '%s' on device with sysname '%s'"), property_key, udev_device_get_sysname(udev_device)); virReportOOMError(); ret = PROPERTY_ERROR; goto out; } VIR_DEBUG("Found property key '%s' value '%s' " "for device with sysname '%s'", property_key, *property_value, udev_device_get_sysname(udev_device));out: return ret;}
开发者ID:hw-claudio,项目名称:libvirt,代码行数:37,
示例2: manager_process_linkstatic int manager_process_link(Manager *m, struct udev_device *device) { Link *link; int r; if (streq_ptr(udev_device_get_action(device), "remove")) { uint64_t ifindex; log_debug("Link removed: %s", udev_device_get_sysname(device)); ifindex = udev_device_get_ifindex(device); link = hashmap_get(m->links, &ifindex); if (!link) return 0; link_free(link); } else { log_debug("New link: %s", udev_device_get_sysname(device)); r = link_add(m, device); if (r < 0) { log_error("Could not handle link %s: %s", udev_device_get_sysname(device), strerror(-r)); } } return 0;}
开发者ID:coldeasy,项目名称:systemd,代码行数:28,
示例3: manager_process_linkstatic int manager_process_link(Manager *m, struct udev_device *device) { Link *link; int r; if (streq_ptr(udev_device_get_action(device), "remove")) { uint64_t ifindex; log_debug("%s: link removed", udev_device_get_sysname(device)); ifindex = udev_device_get_ifindex(device); link = hashmap_get(m->links, &ifindex); if (!link) return 0; link_free(link); } else { r = link_add(m, device, &link); if (r < 0) { if (r == -EEXIST) log_debug("%s: link already exists, ignoring", link->ifname); else log_error("%s: could not handle link: %s", udev_device_get_sysname(device), strerror(-r)); } else log_debug("%s: link (with ifindex %" PRIu64") added", link->ifname, link->ifindex); } return 0;}
开发者ID:jaanek,项目名称:systemd,代码行数:32,
示例4: manager_process_linkstatic int manager_process_link(Manager *m, struct udev_device *device) { Link *link = NULL; int r; assert(m); assert(device); link_get(m, udev_device_get_ifindex(device), &link); if (streq_ptr(udev_device_get_action(device), "remove")) { log_debug("%s: link removed", udev_device_get_sysname(device)); if (link) link_free(link); } else { if (link) { log_debug("%s: link already exists, ignoring", link->ifname); return 0; } r = link_add(m, device, &link); if (r < 0) { log_error("%s: could not handle link: %s", udev_device_get_sysname(device), strerror(-r)); } else log_debug("%s: link (with ifindex %" PRIu64") added", link->ifname, link->ifindex); } return 0;}
开发者ID:wkennington,项目名称:systemd,代码行数:33,
示例5: pup_cdrom_udev_event//Here we can only handle udev events related to plugging and removing entire //drivesvoid pup_cdrom_udev_event(PupVMMonitor *monitor, struct udev_device *dev){ //An optical drive is a block device if (g_strcmp0(udev_device_get_subsystem(dev), "block") != 0) return; g_debug("processing event for %s.../n", udev_device_get_sysname(dev)); if (pup_drive_test_optical(dev)) { //We are handling it... pup_vm_monitor_stop_processing_uevent(monitor); const gchar *action = udev_device_get_action(dev); g_return_if_fail(action); if (strcmp(action, "remove") == 0) { g_debug("Removing %s", udev_device_get_sysname(dev)); PupDrive *drv = pup_vm_monitor_lookup_drive (monitor, udev_device_get_sysname(dev), FALSE); if (drv) pup_vm_monitor_remove_device(monitor, PUP_DEVICE(drv)); PupVolume *vol = pup_vm_monitor_lookup_volume (monitor, udev_device_get_sysname(dev), FALSE); if (vol) pup_vm_monitor_remove_device(monitor, PUP_DEVICE(vol)); } else { g_debug("Optical drive, now probing.../n"); pup_cd_drive_new_from_udev_device(monitor, dev); } } else g_debug("Not an optical drive/n");}
开发者ID:Jubei-Mitsuyoshi,项目名称:aaa-pup-volume-monitor,代码行数:35,
示例6: udevGenerateDeviceNamestatic int udevGenerateDeviceName(struct udev_device *device, virNodeDeviceDefPtr def, const char *s){ int ret = 0, i = 0; virBuffer buf = VIR_BUFFER_INITIALIZER; virBufferAsprintf(&buf, "%s_%s", udev_device_get_subsystem(device), udev_device_get_sysname(device)); if (s != NULL) { virBufferAsprintf(&buf, "_%s", s); } if (virBufferError(&buf)) { virBufferFreeAndReset(&buf); VIR_ERROR(_("Buffer error when generating device name for device " "with sysname '%s'"), udev_device_get_sysname(device)); ret = -1; } def->name = virBufferContentAndReset(&buf); for (i = 0; i < strlen(def->name) ; i++) { if (!(c_isalnum(*(def->name + i)))) { *(def->name + i) = '_'; } } return ret;}
开发者ID:hw-claudio,项目名称:libvirt,代码行数:32,
示例7: udevGetDeviceSysfsAttr/* This function allocates memory from the heap for the property * value. That memory must be later freed by some other code. */static int udevGetDeviceSysfsAttr(struct udev_device *udev_device, const char *attr_name, char **attr_value){ const char *udev_value = NULL; int ret = PROPERTY_FOUND; udev_value = udev_device_get_sysattr_value(udev_device, attr_name); if (udev_value == NULL) { VIR_DEBUG("udev reports device '%s' does not have sysfs attr '%s'", udev_device_get_sysname(udev_device), attr_name); ret = PROPERTY_MISSING; goto out; } /* If this allocation is changed, the comment at the beginning * of the function must also be changed. */ *attr_value = strdup(udev_value); if (*attr_value == NULL) { VIR_ERROR(_("Failed to allocate memory for sysfs attribute value for " "sysfs attribute '%s' on device with sysname '%s'"), attr_name, udev_device_get_sysname(udev_device)); virReportOOMError(); ret = PROPERTY_ERROR; goto out; } VIR_DEBUG("Found sysfs attribute '%s' value '%s' " "for device with sysname '%s'", attr_name, *attr_value, udev_device_get_sysname(udev_device));out: return ret;}
开发者ID:hw-claudio,项目名称:libvirt,代码行数:37,
示例8: udev_device_get_udevstatic struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **path){ struct udev *udev = udev_device_get_udev(parent); struct udev_device *transportdev; struct udev_device *sessiondev = NULL; const char *target; char *connname; struct udev_device *conndev = NULL; const char *addr; const char *port; /* find iscsi session */ transportdev = parent; while (1) { transportdev = udev_device_get_parent(transportdev); if (transportdev == NULL) return NULL; if (strncmp(udev_device_get_sysname(transportdev), "session", 7) == 0) break; } if (transportdev == NULL) return NULL; /* find iscsi session device */ sessiondev = udev_device_new_from_subsystem_sysname(udev, "iscsi_session", udev_device_get_sysname(transportdev)); if (sessiondev == NULL) return NULL; target = udev_device_get_sysattr_value(sessiondev, "targetname"); if (target == NULL) { parent = NULL; goto out; } if (asprintf(&connname, "connection%s:0", udev_device_get_sysnum(transportdev)) < 0) { parent = NULL; goto out; } conndev = udev_device_new_from_subsystem_sysname(udev, "iscsi_connection", connname); free(connname); if (conndev == NULL) { parent = NULL; goto out; } addr = udev_device_get_sysattr_value(conndev, "persistent_address"); port = udev_device_get_sysattr_value(conndev, "persistent_port"); if (addr == NULL || port == NULL) { parent = NULL; goto out; } path_prepend(path, "ip-%s:%s-iscsi-%s-lun-%s", addr, port, target, udev_device_get_sysnum(parent));out: udev_device_unref(sessiondev); udev_device_unref(conndev); return parent;}
开发者ID:Lingvorn,项目名称:udev,代码行数:56,
示例9: setup_isi_serialstatic gboolean setup_isi_serial(struct modem_info* modem){ struct serial_device_info* info; const char *value; info = modem->serial; if (g_strcmp0(udev_device_get_subsystem(info->dev), "net") != 0) return FALSE; value = udev_device_get_sysattr_value(info->dev, "type"); if (g_strcmp0(value, "820") != 0) return FALSE; /* OK, we want this device to be a modem */ value = udev_device_get_sysname(info->dev); if (value) ofono_modem_set_string(modem->modem, "Interface", value); value = udev_device_get_property_value(info->dev, "OFONO_ISI_ADDRESS"); if (value) ofono_modem_set_integer(modem->modem, "Address", atoi(value)); ofono_modem_set_string(modem->modem, "Device", info->devnode); return TRUE;}
开发者ID:endocode,项目名称:ofono,代码行数:27,
示例10: udev_input_add_devicesstatic intudev_input_add_devices(struct udev_input *input, struct udev *udev){ struct udev_enumerate *e; struct udev_list_entry *entry; struct udev_device *device; const char *path, *sysname; struct udev_seat *seat; int devices_found = 0; e = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(e, "input"); 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); sysname = udev_device_get_sysname(device); if (strncmp("event", sysname, 5) != 0) { udev_device_unref(device); continue; } if (device_added(device, input) < 0) { udev_device_unref(device); udev_enumerate_unref(e); return -1; } udev_device_unref(device); }
开发者ID:bpeel,项目名称:weston,代码行数:31,
示例11: qDebugvoid Storage::checkDevice(int fd) { PowerManagerLock* powerLock = PowerManager::getNewLock(this); powerLock->activate(); qDebug() << Q_FUNC_INFO << "FD: "<< fd; struct udev_device *dev; dev = udev_monitor_receive_device(udev_monitor); if (dev) { QString device = udev_device_get_devnode(dev); QString path = udev_device_get_devpath(dev); QString action = udev_device_get_action(dev); QString devtype = udev_device_get_devtype(dev); QString sysname("/dev/"); sysname += QString(udev_device_get_sysname(dev)); QString parent = udev_device_get_devpath( udev_device_get_parent (dev)); if (sysname.contains(QRegExp("mmcblk[0-9]//d*")) || sysname.contains(QRegExp("mmcblk[0-9]"))) { qDebug() << "Got " << path << ":" << action; qDebug() << " Got Device"; qDebug() << " Node: " << udev_device_get_devnode(dev); qDebug() << " Subsystem: "<< udev_device_get_subsystem(dev); qDebug() << " Devtype: " << devtype; qDebug() << " Action: " << action; qDebug() << " Sysname: " << sysname; qDebug() << " sysnum: " << udev_device_get_sysnum (dev); qDebug() << " parent: " << parent; processRemovableUdevEvents(devtype, path, sysname, action); } udev_device_unref(dev); } delete powerLock;}
开发者ID:bq,项目名称:cervantes,代码行数:34,
示例12: read_usb_deviceint read_usb_device(struct udev_device *sdev, struct usbip_usb_device *udev){ uint32_t busnum, devnum; const char *path, *name; READ_ATTR(udev, uint8_t, sdev, bDeviceClass, "%02x/n"); READ_ATTR(udev, uint8_t, sdev, bDeviceSubClass, "%02x/n"); READ_ATTR(udev, uint8_t, sdev, bDeviceProtocol, "%02x/n"); READ_ATTR(udev, uint16_t, sdev, idVendor, "%04x/n"); READ_ATTR(udev, uint16_t, sdev, idProduct, "%04x/n"); READ_ATTR(udev, uint16_t, sdev, bcdDevice, "%04x/n"); READ_ATTR(udev, uint8_t, sdev, bConfigurationValue, "%02x/n"); READ_ATTR(udev, uint8_t, sdev, bNumConfigurations, "%02x/n"); READ_ATTR(udev, uint8_t, sdev, bNumInterfaces, "%02x/n"); READ_ATTR(udev, uint8_t, sdev, devnum, "%d/n"); udev->speed = read_attr_speed(sdev); path = udev_device_get_syspath(sdev); name = udev_device_get_sysname(sdev); strncpy(udev->path, path, SYSFS_PATH_MAX); strncpy(udev->busid, name, SYSFS_BUS_ID_SIZE); sscanf(name, "%u-%u", &busnum, &devnum); udev->busnum = busnum; return 0;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:31,
示例13: udev_handle_devicestatic intudev_handle_device(void *ctx){ struct udev_device *device; const char *subsystem, *ifname, *action; device = udev_monitor_receive_device(monitor); if (device == NULL) { syslog(LOG_ERR, "libudev: received NULL device"); return -1; } subsystem = udev_device_get_subsystem(device); ifname = udev_device_get_sysname(device); action = udev_device_get_action(device); /* udev filter documentation says "usually" so double check */ if (strcmp(subsystem, "net") == 0) { syslog(LOG_DEBUG, "%s: libudev: %s", ifname, action); if (strcmp(action, "add") == 0 || strcmp(action, "move") == 0) dhcpcd.handle_interface(ctx, 1, ifname); else if (strcmp(action, "remove") == 0) dhcpcd.handle_interface(ctx, -1, ifname); } udev_device_unref(device); return 1;}
开发者ID:bluemutedwisdom,项目名称:dhcpcd-6.7.1,代码行数:28,
示例14: QStringQString Device::name() const{ if (!d) return QString(); return QString::fromLatin1(udev_device_get_sysname(d->udev));}
开发者ID:gustavosbarreto,项目名称:libqsolid,代码行数:7,
示例15: print_device_chainstatic int print_device_chain(struct udev_device *device){ struct udev_device *device_parent; const char *str; printf("/n" "Udevadm info starts with the device specified by the devpath and then/n" "walks up the chain of parent devices. It prints for every device/n" "found, all possible attributes in the udev rules key format./n" "A rule to match, can be composed by the attributes of the device/n" "and the attributes from one single parent device./n" "/n"); printf(" looking at device '%s':/n", udev_device_get_devpath(device)); printf(" KERNEL==/"%s/"/n", udev_device_get_sysname(device)); str = udev_device_get_subsystem(device); if (str == NULL) str = ""; printf(" SUBSYSTEM==/"%s/"/n", str); str = udev_device_get_driver(device); if (str == NULL) str = ""; printf(" DRIVER==/"%s/"/n", str); print_all_attributes(device, "ATTR"); device_parent = device; do { device_parent = udev_device_get_parent(device_parent); if (device_parent == NULL) break; printf(" looking at parent device '%s':/n", udev_device_get_devpath(device_parent)); printf(" KERNELS==/"%s/"/n", udev_device_get_sysname(device_parent)); str = udev_device_get_subsystem(device_parent); if (str == NULL) str = ""; printf(" SUBSYSTEMS==/"%s/"/n", str); str = udev_device_get_driver(device_parent); if (str == NULL) str = ""; printf(" DRIVERS==/"%s/"/n", str); print_all_attributes(device_parent, "ATTRS"); } while (device_parent != NULL); return 0;}
开发者ID:kwirk,项目名称:systemd,代码行数:45,
示例16: dce_dpm_onvoid dce_dpm_on(struct output *o){ void *sysname=(void*)udev_device_get_sysname(o->d); ul req=IOR('d',SI_DCE_DP_DPM,o->blk_idx); l r=ioctl(o->fd,req,&o->blk_idx); if(ISERR(r)) PERR("output:%s:dce:unable to swich dpm to on/n",sysname); else LOG("output:%s:dce:dpm on successfully/n",sysname);}
开发者ID:sylware,项目名称:lwl,代码行数:9,
示例17: udevInterfaceLookupByMACStringstatic virInterfacePtrudevInterfaceLookupByMACString(virConnectPtr conn, const char *macstr){ struct udev_iface_driver *driverState = conn->interfacePrivateData; struct udev *udev = udev_ref(driverState->udev); struct udev_enumerate *enumerate = NULL; struct udev_list_entry *dev_entry; struct udev_device *dev; const char *name; virInterfacePtr ret = NULL; enumerate = udevGetDevices(udev, VIR_UDEV_IFACE_ALL); if (!enumerate) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to lookup interface with MAC address '%s'"), macstr); goto err; } /* Match on MAC */ udev_enumerate_add_match_sysattr(enumerate, "address", macstr); /* Do the scan to load up the enumeration */ udev_enumerate_scan_devices(enumerate); /* Get a list we can walk */ dev_entry = udev_enumerate_get_list_entry(enumerate); /* Check that we got something back */ if (!dev_entry) { virReportError(VIR_ERR_NO_INTERFACE, _("couldn't find interface with MAC address '%s'"), macstr); goto err; } /* Check that we didn't get multiple items back */ if (udev_list_entry_get_next(dev_entry)) { virReportError(VIR_ERR_MULTIPLE_INTERFACES, _("the MAC address '%s' matches multiple interfaces"), macstr); goto err; } dev = udev_device_new_from_syspath(udev, udev_list_entry_get_name(dev_entry)); name = udev_device_get_sysname(dev); ret = virGetInterface(conn, name, macstr); udev_device_unref(dev);err: if (enumerate) udev_enumerate_unref(enumerate); udev_unref(udev); return ret;}
开发者ID:avdv,项目名称:libvirt,代码行数:57,
示例18: udev_device_get_sysattr_value LinuxDevice::LinuxDevice(struct udev_device* dev) { log->debug("Creating a new LinuxDevice instance"); const char *name = udev_device_get_sysattr_value(dev, "product"); if (name) { log->debug("DeviceName={}", name); setDeviceName(name); } const char *id_vendor = udev_device_get_sysattr_value(dev, "idVendor"); if (id_vendor) { log->debug("VendorID={}", id_vendor); setVendorID(id_vendor); } const char *id_product = udev_device_get_sysattr_value(dev, "idProduct"); if (id_product) { log->debug("ProductID={}", id_product); setProductID(id_product); } const char *serial = udev_device_get_sysattr_value(dev, "serial"); if (serial) { log->debug("Serial={}", serial); setSerialNumber(serial); } const char *syspath = udev_device_get_syspath(dev); if (syspath) { log->debug("Syspath={}", syspath); _syspath = syspath; } else { throw std::runtime_error("device wihtout syspath"); } const char *sysname = udev_device_get_sysname(dev); if (sysname) { log->debug("Sysname={}", sysname); setDevicePort(sysname); } else { throw std::runtime_error("device wihtout sysname"); } log->debug("DeviceHash={}", getDeviceHash()); setTarget(Rule::Target::Unknown); std::ifstream descriptor_stream(_syspath + "/descriptors", std::ifstream::binary); if (!descriptor_stream.good()) { throw std::runtime_error("cannot load USB descriptors"); } else { readDescriptors(descriptor_stream); } return; }
开发者ID:cmotc,项目名称:usbguard,代码行数:57,
示例19: PUP_DRIVEPupDrive *pup_cd_drive_new_from_udev_device(PupVMMonitor *monitor, struct udev_device *device){ PupDrive *drv = PUP_DRIVE(pup_device_new(PUP_TYPE_CD_DRIVE, udev_device_get_sysname(device))); PUP_DEVICE(drv)->icon_name = g_strdup(PUP_ICON_OPTICAL_DRIVE); drv->unix_dev = pup_guess_devnode(device); if (! drv->unix_dev) { g_critical("Device node not found for %s", udev_device_get_sysname(device)); g_object_unref(drv); return NULL; } //Find model and vendor strings gchar *tmpstr = g_strdup(udev_device_get_sysattr_value(device, "device/model")); PUP_DRIVE(drv)->model = g_strdup(g_strstrip(tmpstr)); g_free(tmpstr); tmpstr = g_strdup(udev_device_get_sysattr_value(device, "device/vendor")); PUP_DRIVE(drv)->vendor = g_strdup(g_strstrip(tmpstr)); g_free(tmpstr); PUP_DEVICE(drv)->display_name = pup_drive_gen_display_name(PUP_DRIVE(drv)); //We will check for the disk later... pup_vm_monitor_lock(monitor); PupDrive *old_drv = pup_vm_monitor_lookup_drive_unlocked (monitor, udev_device_get_sysname(device), FALSE); if (old_drv) PUP_CD_DRIVE(drv)->status = PUP_CD_DRIVE(old_drv)->status; else PUP_CD_DRIVE(drv)->status = PUP_CD_DRIVE_NOT_READY; pup_vm_monitor_unlock(monitor); g_signal_connect_object(monitor, "mounts-check", G_CALLBACK(pup_cd_drive_probe_disk_cb), drv, 0); pup_overwrite_dev(monitor, PUP_DEVICE(drv)); g_debug("%s added", udev_device_get_sysname(device)); return drv;}
开发者ID:Jubei-Mitsuyoshi,项目名称:aaa-pup-volume-monitor,代码行数:43,
示例20: handle_scsi_tapestatic void handle_scsi_tape(struct udev_device *dev, char **suffix){ const char *name; name = udev_device_get_sysname(dev); if (strncmp(name, "nst", 3) == 0 && strchr("lma", name[3]) != NULL) asprintf(suffix, "nst%c", name[3]); else if (strncmp(name, "st", 2) == 0 && strchr("lma", name[2]) != NULL) asprintf(suffix, "st%c", name[2]);}
开发者ID:Lingvorn,项目名称:udev,代码行数:10,
示例21: dce_double_frame_buffer_freevoid dce_double_frame_buffer_free(struct output *o){ void *sysname=(void*)udev_device_get_sysname(o->d); ul req=IOR('d',SI_MEM_FREE,o->fb.gpu_addr); l r=ioctl(o->fd,req,&o->fb.gpu_addr); if(ISERR(r)) PERR("output:%s:dce:unable to free frame buffer memory (LEAK!)/n",sysname); else LOG("output:%s:dce:double frame buffer freed successfully/n",sysname);}
开发者ID:sylware,项目名称:lwl,代码行数:10,
示例22: names_usbstatic int names_usb(struct udev_device *dev, struct netnames *names) { struct udev_device *usbdev; char name[256]; char *ports; char *config; char *interf; size_t l; char *s; assert(dev); assert(names); usbdev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface"); if (!usbdev) return -ENOENT; /* get USB port number chain, configuration, interface */ strscpy(name, sizeof(name), udev_device_get_sysname(usbdev)); s = strchr(name, '-'); if (!s) return -EINVAL; ports = s+1; s = strchr(ports, ':'); if (!s) return -EINVAL; s[0] = '/0'; config = s+1; s = strchr(config, '.'); if (!s) return -EINVAL; s[0] = '/0'; interf = s+1; /* prefix every port number in the chain with "u" */ s = ports; while ((s = strchr(s, '.'))) s[0] = 'u'; s = names->usb_ports; l = strpcpyl(&s, sizeof(names->usb_ports), "u", ports, NULL); /* append USB config number, suppress the common config == 1 */ if (!streq(config, "1")) l = strpcpyl(&s, sizeof(names->usb_ports), "c", config, NULL); /* append USB interface number, suppress the interface == 0 */ if (!streq(interf, "0")) l = strpcpyl(&s, sizeof(names->usb_ports), "i", interf, NULL); if (l == 0) return -ENAMETOOLONG; names->type = NET_USB; return 0;}
开发者ID:BenjaminLefoul,项目名称:systemd,代码行数:55,
示例23: read_usb_vudc_devicestaticint read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev){ const char *path, *name; char filepath[SYSFS_PATH_MAX]; struct usb_device_descriptor descr; unsigned i; FILE *fd = NULL; struct udev_device *plat; const char *speed; int ret = 0; plat = udev_device_get_parent(sdev); path = udev_device_get_syspath(plat); snprintf(filepath, SYSFS_PATH_MAX, "%s/%s", path, VUDC_DEVICE_DESCR_FILE); fd = fopen(filepath, "r"); if (!fd) return -1; ret = fread((char *) &descr, sizeof(descr), 1, fd); if (ret < 0) return -1; fclose(fd); copy_descr_attr(dev, &descr, bDeviceClass); copy_descr_attr(dev, &descr, bDeviceSubClass); copy_descr_attr(dev, &descr, bDeviceProtocol); copy_descr_attr(dev, &descr, bNumConfigurations); copy_descr_attr16(dev, &descr, idVendor); copy_descr_attr16(dev, &descr, idProduct); copy_descr_attr16(dev, &descr, bcdDevice); strncpy(dev->path, path, SYSFS_PATH_MAX); dev->speed = USB_SPEED_UNKNOWN; speed = udev_device_get_sysattr_value(sdev, "current_speed"); if (speed) { for (i = 0; i < ARRAY_SIZE(speed_names); i++) { if (!strcmp(speed_names[i].name, speed)) { dev->speed = speed_names[i].speed; break; } } } /* Only used for user output, little sense to output them in general */ dev->bNumInterfaces = 0; dev->bConfigurationValue = 0; dev->busnum = 0; name = udev_device_get_sysname(plat); strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE); return 0;}
开发者ID:513855417,项目名称:linux,代码行数:54,
示例24: regexpQObject *QKmsUdevDRMHandler::create(struct udev_device *device){ if (strcmp(udev_device_get_subsystem(device), "drm")) return 0; QRegExp regexp("^card//d+$"); if (!regexp.exactMatch(udev_device_get_sysname(device))) return 0; return m_integration->createDevice(udev_device_get_devnode(device));}
开发者ID:ghjinlei,项目名称:qt5,代码行数:11,
示例25: dce_mode_programs8 dce_mode_program(s32 output_name){ struct output *o=®istry[output_name].output; void *sysname=(void*)udev_device_get_sysname(o->d); //---------------------------------------------------------------------------- //alloc a properly sized double buffered frame buffer o->fb.align=PAGE_SZ;//align on a cpu memory page u64 sz=2*(o->current->h*o->current->v*alga_pixel_fmts_sz[o->pixel_fmt]); o->fb.sz=sz; ul req=IOWR('d',SI_MEM_ALLOC,o->fb); l r=ioctl(o->fd,req,(l)&o->fb); if(ISERR(r)){ PERR("output:%s:dce:unable to allocate proper vram for a frame buffer of" " size %llu bytes/n",sysname,o->fb.sz); goto err; } LOG("output:%s:dce:double buffered frame buffer of %llu bytes allocated/n", sysname,sz); //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- //program synchronously the video mode struct si_dce_dp_set dp_set; dp_set.idx=o->blk_idx; dp_set.primary=o->fb.gpu_addr; dp_set.secondary=o->fb.gpu_addr+sz/2; dp_set.pixel_fmt=o->pixel_fmt; dp_set.timing=*(o->current); dp_set.pitch=o->current->h; req=IOW('d',SI_DCE_DP_SET,dp_set); r=ioctl(o->fd,req,(l)&dp_set); if(ISERR(r)){ PERR("output:%s:dce:%ux%[email C++ udev_device_new_from_syspath函数代码示例 C++ udev_device_get_sysattr_value函数代码示例
|