diff options
author | Kay Sievers <kay@vrfy.org> | 2012-10-09 00:16:50 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2012-10-09 00:16:50 +0200 |
commit | 07845c142b41083bc759a18e601123aa5f6864f1 (patch) | |
tree | 190d67aa648caa60263a865d78b627bf4e6feb80 /src/core/device.c | |
parent | cc30f5f388a96ab261e73fabf968b2ec3a8fd63b (diff) |
udev: support multiple entries for ENV{SYSTEMD_ALIAS} and ENV{SYSTEM_WANTS}
Diffstat (limited to 'src/core/device.c')
-rw-r--r-- | src/core/device.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/core/device.c b/src/core/device.c index 5307341d70..8121dc95d1 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -251,30 +251,49 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p * interpret for the main object */ const char *wants, *alias; - if ((alias = udev_device_get_property_value(dev, "SYSTEMD_ALIAS"))) { - if (!is_path(alias)) - log_warning("SYSTEMD_ALIAS for %s is not a path, ignoring: %s", sysfs, alias); - else { - if ((r = device_add_escaped_name(u, alias)) < 0) + alias = udev_device_get_property_value(dev, "SYSTEMD_ALIAS"); + if (alias) { + char *state, *w; + size_t l; + + FOREACH_WORD_QUOTED(w, l, alias, state) { + char *e; + + e = strndup(w, l); + if (!e) { + r = -ENOMEM; goto fail; + } + + if (!is_path(e)) { + log_warning("SYSTEMD_ALIAS for %s is not a path, ignoring: %s", sysfs, e); + free(e); + } else { + + r = device_add_escaped_name(u, e); + free(e); + if (r < 0) + goto fail; + } } } - if ((wants = udev_device_get_property_value(dev, "SYSTEMD_WANTS"))) { + wants = udev_device_get_property_value(dev, "SYSTEMD_WANTS"); + if (wants) { char *state, *w; size_t l; FOREACH_WORD_QUOTED(w, l, wants, state) { char *e; - if (!(e = strndup(w, l))) { + e = strndup(w, l); + if (!e) { r = -ENOMEM; goto fail; } r = unit_add_dependency_by_name(u, UNIT_WANTS, e, NULL, true); free(e); - if (r < 0) goto fail; } |