diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-10-29 15:16:00 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-07 13:35:03 +0900 |
commit | f3d241feb2f2337098b53bfa1f86014b5c882df5 (patch) | |
tree | a713d83c8aeb10abf76b932bf62229450fda670c /src | |
parent | 5ba7e79885ba769f5a016631bf95c756c1c7e02c (diff) | |
download | systemd-f3d241feb2f2337098b53bfa1f86014b5c882df5.tar.gz systemd-f3d241feb2f2337098b53bfa1f86014b5c882df5.tar.bz2 systemd-f3d241feb2f2337098b53bfa1f86014b5c882df5.zip |
udev: use sd_device for udev_event.dev_parent
Diffstat (limited to 'src')
-rw-r--r-- | src/udev/udev-event.c | 8 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 24 | ||||
-rw-r--r-- | src/udev/udev.h | 2 |
3 files changed, 21 insertions, 13 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 1270369321..29845486ac 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -159,7 +159,7 @@ static ssize_t subst_format_var(struct udev_event *event, case SUBST_ID: if (!event->dev_parent) return 0; - r = sd_device_get_sysname(event->dev_parent->device, &val); + r = sd_device_get_sysname(event->dev_parent, &val); if (r < 0) return r; l = strpcpy(&s, l, val); @@ -167,7 +167,7 @@ static ssize_t subst_format_var(struct udev_event *event, case SUBST_DRIVER: if (!event->dev_parent) return 0; - r = sd_device_get_driver(event->dev_parent->device, &val); + r = sd_device_get_driver(event->dev_parent, &val); if (r < 0) return r == -ENOENT ? 0 : r; l = strpcpy(&s, l, val); @@ -240,8 +240,8 @@ static ssize_t subst_format_var(struct udev_event *event, (void) sd_device_get_sysattr_value(dev, attr, &val); /* try to read the attribute of the parent device, other matches have selected */ - if (!val && event->dev_parent && event->dev_parent->device != dev) - (void) sd_device_get_sysattr_value(event->dev_parent->device, attr, &val); + if (!val && event->dev_parent && event->dev_parent != dev) + (void) sd_device_get_sysattr_value(event->dev_parent, attr, &val); if (!val) return 0; diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index daa3fd2208..cf1c44236f 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1861,32 +1861,39 @@ int udev_rules_apply_to_event( next++; /* loop over parents */ - event->dev_parent = event->dev; + event->dev_parent = event->dev->device; for (;;) { struct token *key; + const char *val; /* loop over sequence of parent match keys */ for (key = cur; key < next; key++ ) { dump_token(rules, key); switch(key->type) { case TK_M_KERNELS: - if (match_key(rules, key, udev_device_get_sysname(event->dev_parent)) != 0) + if (sd_device_get_sysname(event->dev_parent, &val) < 0) + goto try_parent; + if (match_key(rules, key, val) != 0) goto try_parent; break; case TK_M_SUBSYSTEMS: - if (match_key(rules, key, udev_device_get_subsystem(event->dev_parent)) != 0) + if (sd_device_get_subsystem(event->dev_parent, &val) < 0) + goto try_parent; + if (match_key(rules, key, val) != 0) goto try_parent; break; case TK_M_DRIVERS: - if (match_key(rules, key, udev_device_get_driver(event->dev_parent)) != 0) + if (sd_device_get_driver(event->dev_parent, &val) < 0) + goto try_parent; + if (match_key(rules, key, val) != 0) goto try_parent; break; case TK_M_ATTRS: - if (match_attr(rules, event->dev_parent->device, event, key) != 0) + if (match_attr(rules, event->dev_parent, event, key) != 0) goto try_parent; break; case TK_M_TAGS: { - bool match = udev_device_has_tag(event->dev_parent, rules_str(rules, cur->key.value_off)); + bool match = sd_device_has_tag(event->dev_parent, rules_str(rules, cur->key.value_off)); if (match && key->key.op == OP_NOMATCH) goto try_parent; @@ -1901,9 +1908,10 @@ int udev_rules_apply_to_event( break; try_parent: - event->dev_parent = udev_device_get_parent(event->dev_parent); - if (event->dev_parent == NULL) + if (sd_device_get_parent(event->dev_parent, &event->dev_parent) < 0) { + event->dev_parent = NULL; goto nomatch; + } } /* move behind our sequence of parent match keys */ cur = next; diff --git a/src/udev/udev.h b/src/udev/udev.h index c963af8cb4..85fcdc439f 100644 --- a/src/udev/udev.h +++ b/src/udev/udev.h @@ -22,7 +22,7 @@ struct udev_event { struct udev_device *dev; - struct udev_device *dev_parent; + sd_device *dev_parent; sd_device *dev_db_clone; char *name; char *program_result; |