mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
Merge pull request #23051 from poettering/udev-tweaklets-2
udev: three minor tweaks
This commit is contained in:
commit
e2185ffef8
@ -638,7 +638,12 @@ static bool match_subsystem(sd_device_enumerator *enumerator, const char *subsys
|
||||
return false;
|
||||
}
|
||||
|
||||
static int enumerator_scan_dir(sd_device_enumerator *enumerator, const char *basedir, const char *subdir, const char *subsystem) {
|
||||
static int enumerator_scan_dir(
|
||||
sd_device_enumerator *enumerator,
|
||||
const char *basedir,
|
||||
const char *subdir,
|
||||
const char *subsystem) {
|
||||
|
||||
_cleanup_closedir_ DIR *dir = NULL;
|
||||
char *path;
|
||||
int r = 0;
|
||||
@ -997,7 +1002,7 @@ _public_ sd_device *sd_device_enumerator_get_subsystem_next(sd_device_enumerator
|
||||
}
|
||||
|
||||
int device_enumerator_scan_devices_and_subsystems(sd_device_enumerator *enumerator) {
|
||||
int r = 0, k;
|
||||
int r;
|
||||
|
||||
assert(enumerator);
|
||||
|
||||
@ -1007,22 +1012,14 @@ int device_enumerator_scan_devices_and_subsystems(sd_device_enumerator *enumerat
|
||||
|
||||
device_enumerator_unref_devices(enumerator);
|
||||
|
||||
if (!set_isempty(enumerator->match_tag)) {
|
||||
k = enumerator_scan_devices_tags(enumerator);
|
||||
if (k < 0)
|
||||
r = k;
|
||||
} else if (enumerator->match_parent) {
|
||||
k = enumerator_scan_devices_children(enumerator);
|
||||
if (k < 0)
|
||||
r = k;
|
||||
} else {
|
||||
k = enumerator_scan_dir(enumerator, "class", NULL, NULL);
|
||||
if (k < 0)
|
||||
r = log_debug_errno(k, "sd-device-enumerator: Failed to scan /sys/class: %m");
|
||||
if (!set_isempty(enumerator->match_tag))
|
||||
r = enumerator_scan_devices_tags(enumerator);
|
||||
else if (enumerator->match_parent)
|
||||
r = enumerator_scan_devices_children(enumerator);
|
||||
else {
|
||||
int k;
|
||||
|
||||
k = enumerator_scan_dir(enumerator, "bus", "devices", NULL);
|
||||
if (k < 0)
|
||||
r = log_debug_errno(k, "sd-device-enumerator: Failed to scan /sys/bus: %m");
|
||||
r = enumerator_scan_devices_all(enumerator);
|
||||
|
||||
if (match_subsystem(enumerator, "module")) {
|
||||
k = enumerator_scan_dir_and_add_devices(enumerator, "module", NULL, NULL);
|
||||
|
@ -207,10 +207,11 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
|
||||
syspath = strdup(_syspath);
|
||||
if (!syspath)
|
||||
return log_oom_debug();
|
||||
|
||||
path_simplify(syspath);
|
||||
}
|
||||
|
||||
devpath = syspath + STRLEN("/sys");
|
||||
|
||||
assert_se(devpath = startswith(syspath, "/sys"));
|
||||
if (devpath[0] != '/')
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENODEV), "sd-device: \"/sys\" alone is not a valid device path.");
|
||||
|
||||
@ -584,11 +585,15 @@ int device_set_devnum(sd_device *device, const char *major, const char *minor) {
|
||||
return r;
|
||||
if (maj == 0)
|
||||
return 0;
|
||||
if (!DEVICE_MAJOR_VALID(maj))
|
||||
return -EINVAL;
|
||||
|
||||
if (minor) {
|
||||
r = safe_atou(minor, &min);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!DEVICE_MINOR_VALID(min))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
r = device_add_property_internal(device, "MAJOR", major);
|
||||
|
Loading…
x
Reference in New Issue
Block a user