syspath_to_db_path(udev_device, filename, sizeof(filename));
if (lstat(filename, &stats) != 0) {
- info(udev_device->udev, "no db file to read %s: %s\n", filename, strerror(errno));
+ info(udev_device->udev, "no db file to read %s: %m\n", filename);
return -1;
}
if ((stats.st_mode & S_IFMT) == S_IFLNK) {
if (target_len > 0)
target[target_len] = '\0';
else {
- info(udev_device->udev, "error reading db link %s: %s\n", filename, strerror(errno));
+ info(udev_device->udev, "error reading db link %s: %m\n", filename);
return -1;
}
if (asprintf(&udev_device->devnode, "%s/%s", udev_get_dev_path(udev_device->udev), target) < 0)
f = fopen(filename, "r");
if (f == NULL) {
- info(udev_device->udev, "error reading db file %s: %s\n", filename, strerror(errno));
+ info(udev_device->udev, "error reading db file %s: %m\n", filename);
return -1;
}
while (fgets(line, sizeof(line), f)) {
device->info_loaded = 1;
}
-struct udev_device *device_init(struct udev *udev)
+struct udev_device *device_new(struct udev *udev)
{
struct udev_device *udev_device;
}
}
- udev_device = device_init(udev);
+ udev_device = device_new(udev);
if (udev_device == NULL)
return NULL;
/* fallback to search sys devices for the major/minor */
if (type == 'b')
- udev_enumerate_scan_devices(udev_enumerate, "block", NULL);
+ udev_enumerate_add_match_subsystem(udev_enumerate, "block");
else if (type == 'c')
- udev_enumerate_scan_devices(udev_enumerate, "!block", NULL);
+ udev_enumerate_add_nomatch_subsystem(udev_enumerate, "block");
+ udev_enumerate_scan_devices(udev_enumerate);
udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(udev_enumerate)) {
struct udev_device *device_loop;
device_loop = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list_entry));
if (device_loop != NULL) {
if (udev_device_get_devnum(device_loop) == devnum) {
- const char *subsystem;
-
- subsystem = udev_device_get_subsystem(device_loop);
- if (type == 'b' && strcmp(subsystem, "block") != 0)
+ if (type == 'b' && strcmp(udev_device_get_subsystem(device_loop), "block") != 0)
continue;
- if (type == 'c' && strcmp(subsystem, "block") == 0)
+ if (type == 'c' && strcmp(udev_device_get_subsystem(device_loop), "block") == 0)
continue;
device = device_loop;
break;
util_strlcat(path, attr, sizeof(path));
if (lstat(path, &statbuf) != 0) {
- info(udev_device->udev, "stat '%s' failed: %s\n", path, strerror(errno));
+ info(udev_device->udev, "stat '%s' failed: %m\n", path);
goto out;
}