return 1;
}
- if_class = udev_device_get_attr_value(dev_interface, "bInterfaceClass");
+ if_class = udev_device_get_sysattr_value(dev_interface, "bInterfaceClass");
if (!if_class) {
info(udev, "%s: cannot get bInterfaceClass attribute\n",
udev_device_get_sysname(dev));
}
if_class_num = strtoul(if_class, NULL, 16);
if (if_class_num == 8) {
- if_subclass = udev_device_get_attr_value(dev_interface, "bInterfaceSubClass");
+ if_subclass = udev_device_get_sysattr_value(dev_interface, "bInterfaceSubClass");
if (if_subclass != NULL)
protocol = set_usb_mass_storage_ifsubtype(type_str, if_subclass, sizeof(type_str)-1);
} else {
}
/* Generic SPC-2 device */
- scsi_vendor = udev_device_get_attr_value(dev_scsi, "vendor");
+ scsi_vendor = udev_device_get_sysattr_value(dev_scsi, "vendor");
if (!scsi_vendor) {
info(udev, "%s: cannot get SCSI vendor attribute\n",
udev_device_get_sysname(dev_scsi));
}
set_str(vendor_str, scsi_vendor, sizeof(vendor_str)-1);
- scsi_model = udev_device_get_attr_value(dev_scsi, "model");
+ scsi_model = udev_device_get_sysattr_value(dev_scsi, "model");
if (!scsi_model) {
info(udev, "%s: cannot get SCSI model attribute\n",
udev_device_get_sysname(dev_scsi));
}
set_str(model_str, scsi_model, sizeof(model_str)-1);
- scsi_type = udev_device_get_attr_value(dev_scsi, "type");
+ scsi_type = udev_device_get_sysattr_value(dev_scsi, "type");
if (!scsi_type) {
info(udev, "%s: cannot get SCSI type attribute\n",
udev_device_get_sysname(dev_scsi));
}
set_scsi_type(type_str, scsi_type, sizeof(type_str)-1);
- scsi_rev = udev_device_get_attr_value(dev_scsi, "rev");
+ scsi_rev = udev_device_get_sysattr_value(dev_scsi, "rev");
if (!scsi_rev) {
info(udev, "%s: cannot get SCSI revision attribute\n",
udev_device_get_sysname(dev_scsi));
const char *usb_vendor = NULL;
if (!use_num_info)
- usb_vendor = udev_device_get_attr_value(dev_usb, "manufacturer");
+ usb_vendor = udev_device_get_sysattr_value(dev_usb, "manufacturer");
if (!usb_vendor)
- usb_vendor = udev_device_get_attr_value(dev_usb, "idVendor");
+ usb_vendor = udev_device_get_sysattr_value(dev_usb, "idVendor");
if (!usb_vendor) {
info(udev, "No USB vendor information available\n");
const char *usb_model = NULL;
if (!use_num_info)
- usb_model = udev_device_get_attr_value(dev_usb, "product");
+ usb_model = udev_device_get_sysattr_value(dev_usb, "product");
if (!usb_model)
- usb_model = udev_device_get_attr_value(dev_usb, "idProduct");
+ usb_model = udev_device_get_sysattr_value(dev_usb, "idProduct");
if (!usb_model) {
dbg(udev, "No USB model information available\n");
if (revision_str[0] == '\0') {
const char *usb_rev;
- usb_rev = udev_device_get_attr_value(dev_usb, "bcdDevice");
+ usb_rev = udev_device_get_sysattr_value(dev_usb, "bcdDevice");
if (usb_rev)
set_str(revision_str, usb_rev, sizeof(revision_str)-1);
}
if (serial_str[0] == '\0') {
const char *usb_serial;
- usb_serial = udev_device_get_attr_value(dev_usb, "serial");
+ usb_serial = udev_device_get_sysattr_value(dev_usb, "serial");
if (usb_serial)
set_str(serial_str, usb_serial, sizeof(serial_str)-1);
}
udev-sysdeps.h \
udev-event.c \
udev-node.c \
- udev-rules.c \
+ udev-rules2.c \
udev-util.c \
lib/libudev.h \
lib/libudev-private.h \
udev_device_get_driver
udev_device_get_devnum
udev_device_get_seqnum
-udev_device_get_attr_value
+udev_device_get_sysattr_value
udev_enumerate_new
udev_enumerate_ref
udev_enumerate_unref
udev_enumerate_get_list_entry
udev_enumerate_add_match_subsystem
udev_enumerate_add_nomatch_subsystem
-udev_enumerate_add_match_attr
-udev_enumerate_add_nomatch_attr
+udev_enumerate_add_match_sysattr
+udev_enumerate_add_nomatch_sysattr
udev_enumerate_scan_devices
udev_enumerate_scan_subsystems
udev_enumerate_add_syspath
int num_fake_partitions;
int devlink_priority;
int ignore_remove;
- struct udev_list_node attr_list;
+ struct udev_list_node sysattr_list;
int info_loaded;
};
udev_device->udev = udev;
udev_list_init(&udev_device->devlinks_list);
udev_list_init(&udev_device->properties_list);
- udev_list_init(&udev_device->attr_list);
+ udev_list_init(&udev_device->sysattr_list);
udev_device->event_timeout = -1;
/* copy global properties */
udev_list_entry_foreach(list_entry, udev_get_properties_list_entry(udev))
free(udev_device->driver);
free(udev_device->devpath_old);
free(udev_device->physdevpath);
- udev_list_cleanup_entries(udev_device->udev, &udev_device->attr_list);
+ udev_list_cleanup_entries(udev_device->udev, &udev_device->sysattr_list);
for (i = 0; i < ARRAY_SIZE(udev_device->envp) && udev_device->envp[i] != NULL; i++)
free(udev_device->envp[i]);
info(udev_device->udev, "udev_device: %p released\n", udev_device);
return udev_device->seqnum;
}
-const char *udev_device_get_attr_value(struct udev_device *udev_device, const char *attr)
+const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr)
{
struct udev_list_entry *list_entry;
char path[UTIL_PATH_SIZE];
if (udev_device == NULL)
return NULL;
- if (attr == NULL)
+ if (sysattr == NULL)
return NULL;
/* look for possibly already cached result */
- udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_device->attr_list)) {
- if (strcmp(udev_list_entry_get_name(list_entry), attr) == 0) {
+ udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_device->sysattr_list)) {
+ if (strcmp(udev_list_entry_get_name(list_entry), sysattr) == 0) {
info(udev_device->udev, "got '%s' (%s) from cache\n",
- attr, udev_list_entry_get_value(list_entry));
+ sysattr, udev_list_entry_get_value(list_entry));
return udev_list_entry_get_value(list_entry);
}
}
util_strlcpy(path, udev_device_get_syspath(udev_device), sizeof(path));
util_strlcat(path, "/", sizeof(path));
- util_strlcat(path, attr, sizeof(path));
+ util_strlcat(path, sysattr, sizeof(path));
if (lstat(path, &statbuf) != 0) {
info(udev_device->udev, "no attribute '%s', keep negative entry\n", path);
- udev_list_entry_add(udev_device->udev, &udev_device->attr_list, attr, NULL, 0, 0);
+ udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, NULL, 0, 0);
goto out;
}
pos = strrchr(target, '/');
if (pos != NULL) {
pos = &pos[1];
- info(udev_device->udev, "cache '%s' with link value '%s'\n", attr, pos);
- list_entry = udev_list_entry_add(udev_device->udev, &udev_device->attr_list, attr, pos, 0, 0);
+ info(udev_device->udev, "cache '%s' with link value '%s'\n", sysattr, pos);
+ list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, pos, 0, 0);
val = udev_list_entry_get_value(list_entry);
}
}
value[size] = '\0';
util_remove_trailing_chars(value, '\n');
info(udev_device->udev, "'%s' has attribute value '%s'\n", path, value);
- list_entry = udev_list_entry_add(udev_device->udev, &udev_device->attr_list, attr, value, 0, 0);
+ list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, value, 0, 0);
val = udev_list_entry_get_value(list_entry);
out:
return val;
struct udev_enumerate {
struct udev *udev;
int refcount;
- struct udev_list_node attr_match_list;
- struct udev_list_node attr_nomatch_list;
+ struct udev_list_node sysattr_match_list;
+ struct udev_list_node sysattr_nomatch_list;
struct udev_list_node subsystem_match_list;
struct udev_list_node subsystem_nomatch_list;
struct udev_list_node devices_list;
udev_enumerate->refcount = 1;
udev_enumerate->udev = udev;
udev_list_init(&udev_enumerate->devices_list);
- udev_list_init(&udev_enumerate->attr_match_list);
- udev_list_init(&udev_enumerate->attr_nomatch_list);
+ udev_list_init(&udev_enumerate->sysattr_match_list);
+ udev_list_init(&udev_enumerate->sysattr_nomatch_list);
udev_list_init(&udev_enumerate->subsystem_match_list);
udev_list_init(&udev_enumerate->subsystem_nomatch_list);
return udev_enumerate;
if (udev_enumerate->refcount > 0)
return;
udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->devices_list);
- udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->attr_match_list);
- udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->attr_nomatch_list);
+ udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->sysattr_match_list);
+ udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->sysattr_nomatch_list);
udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->subsystem_match_list);
udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->subsystem_nomatch_list);
free(udev_enumerate);
return 0;
}
-int udev_enumerate_add_match_attr(struct udev_enumerate *udev_enumerate, const char *attr, const char *value)
+int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value)
{
if (udev_enumerate == NULL)
return -EINVAL;
- if (attr == NULL)
+ if (sysattr == NULL)
return 0;
if (udev_list_entry_add(udev_enumerate_get_udev(udev_enumerate),
- &udev_enumerate->attr_match_list, attr, value, 1, 0) == NULL)
+ &udev_enumerate->sysattr_match_list, sysattr, value, 1, 0) == NULL)
return -ENOMEM;
return 0;
}
-int udev_enumerate_add_nomatch_attr(struct udev_enumerate *udev_enumerate, const char *attr, const char *value)
+int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value)
{
if (udev_enumerate == NULL)
return -EINVAL;
- if (attr == NULL)
+ if (sysattr == NULL)
return 0;
if (udev_list_entry_add(udev_enumerate_get_udev(udev_enumerate),
- &udev_enumerate->attr_nomatch_list, attr, value, 1, 0) == NULL)
+ &udev_enumerate->sysattr_nomatch_list, sysattr, value, 1, 0) == NULL)
return -ENOMEM;
return 0;
}
-static int match_attr_value(struct udev *udev, const char *syspath, const char *attr, const char *match_val)
+static int match_sysattr_value(struct udev *udev, const char *syspath, const char *sysattr, const char *match_val)
{
struct udev_device *device;
const char *val = NULL;
device = udev_device_new_from_syspath(udev, syspath);
if (device == NULL)
return -EINVAL;
- val = udev_device_get_attr_value(device, attr);
+ val = udev_device_get_sysattr_value(device, sysattr);
if (val == NULL)
goto exit;
if (match_val == NULL) {
return match;
}
-static int match_attr(struct udev_enumerate *udev_enumerate, const char *syspath)
+static int match_sysattr(struct udev_enumerate *udev_enumerate, const char *syspath)
{
struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
struct udev_list_entry *list_entry;
/* skip list */
- udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->attr_nomatch_list)) {
- if (match_attr_value(udev, syspath,
+ udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->sysattr_nomatch_list)) {
+ if (match_sysattr_value(udev, syspath,
udev_list_entry_get_name(list_entry),
udev_list_entry_get_value(list_entry)))
return 0;
}
/* include list */
- if (udev_list_get_entry(&udev_enumerate->attr_match_list) != NULL) {
- udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->attr_match_list)) {
+ if (udev_list_get_entry(&udev_enumerate->sysattr_match_list) != NULL) {
+ udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->sysattr_match_list)) {
/* anything that does not match, will make it FALSE */
- if (!match_attr_value(udev, syspath,
+ if (!match_sysattr_value(udev, syspath,
udev_list_entry_get_name(list_entry),
udev_list_entry_get_value(list_entry)))
return 0;
util_strlcat(filename, "/uevent", sizeof(filename));
if (stat(filename, &statbuf) != 0)
continue;
- if (!match_attr(udev_enumerate, syspath))
+ if (!match_sysattr(udev_enumerate, syspath))
continue;
udev_list_entry_add(udev, &udev_enumerate->devices_list, syspath, NULL, 1, 1);
}
extern dev_t udev_device_get_devnum(struct udev_device *udev_device);
extern const char *udev_device_get_action(struct udev_device *udev_device);
extern unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);
-extern const char *udev_device_get_attr_value(struct udev_device *udev_device, const char *attr);
+extern const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
/* udev and kernel device events */
struct udev_monitor;
extern struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate);
extern int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
extern int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);
-extern int udev_enumerate_add_match_attr(struct udev_enumerate *udev_enumerate, const char *attr, const char *value);
-extern int udev_enumerate_add_nomatch_attr(struct udev_enumerate *udev_enumerate, const char *attr, const char *value);
+extern int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
+extern int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);
extern int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath);
extern int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate);
extern int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate);
if (count > 0)
printf("found %i properties\n", count);
- str = udev_device_get_attr_value(device, "dev");
+ str = udev_device_get_sysattr_value(device, "dev");
if (str != NULL)
printf("attr{dev}: '%s'\n", str);
if (read_value) {
const char *val;
- val = udev_device_get_attr_value(dev, attr);
+ val = udev_device_get_sysattr_value(dev, attr);
if (val != NULL)
util_strlcpy(result, val, maxsize);
else
if (value[0] == '\0' && event->dev_parent != NULL && event->dev_parent != event->dev) {
const char *val;
- val = udev_device_get_attr_value(event->dev_parent, attr);
+ val = udev_device_get_sysattr_value(event->dev_parent, attr);
if (val != NULL)
util_strlcpy(value, val, sizeof(value));
}
do {
dbg(event->udev, "looking at '%s'\n", udev_device_get_syspath(dev_parent));
- val = udev_device_get_attr_value(dev_parent, attr);
+ val = udev_device_get_sysattr_value(dev_parent, attr);
if (val != NULL) {
util_strlcpy(value, val, sizeof(value));
break;
if (S_ISLNK(statbuf.st_mode))
continue;
- value = udev_device_get_attr_value(device, dent->d_name);
+ value = udev_device_get_sysattr_value(device, dent->d_name);
if (value == NULL)
continue;
dbg(udev, "attr '%s'='%s'(%zi)\n", dent->d_name, value, len);
val[0] = 0;
val = &val[1];
}
- udev_enumerate_add_match_attr(udev_enumerate, attr, val);
+ udev_enumerate_add_match_sysattr(udev_enumerate, attr, val);
break;
case 'A':
util_strlcpy(attr, optarg, sizeof(attr));
val[0] = 0;
val = &val[1];
}
- udev_enumerate_add_nomatch_attr(udev_enumerate, attr, val);
+ udev_enumerate_add_nomatch_sysattr(udev_enumerate, attr, val);
break;
case 'h':
printf("Usage: udevadm trigger OPTIONS\n"