summaryrefslogtreecommitdiff
path: root/src/udev/udevadm-trigger.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-11-25 19:39:19 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-11-25 21:16:47 -0500
commitd6170d27b26eeeace966bb9720d66fcac2a6ef1b (patch)
tree0610f7c4abf3e350ad56d804015778917138dd47 /src/udev/udevadm-trigger.c
parent6c78f43c7b0e54e695af49917fda79b584f46830 (diff)
udevadm: split out find_device helper
The idea is to unify the way that devices can be specified.
Diffstat (limited to 'src/udev/udevadm-trigger.c')
-rw-r--r--src/udev/udevadm-trigger.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index a52d1b5ad5..49e256289c 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -32,6 +32,7 @@
#include "udev.h"
#include "udev-util.h"
+#include "udevadm-util.h"
#include "util.h"
static int verbose;
@@ -174,25 +175,18 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) {
udev_enumerate_add_match_sysname(udev_enumerate, optarg);
break;
case 'b': {
- char path[UTIL_PATH_SIZE];
- struct udev_device *dev;
-
- /* add sys dir if needed */
- if (!startswith(optarg, "/sys"))
- strscpyl(path, sizeof(path), "/sys", optarg, NULL);
- else
- strscpy(path, sizeof(path), optarg);
- util_remove_trailing_chars(path, '/');
- dev = udev_device_new_from_syspath(udev, path);
+ _cleanup_udev_device_unref_ struct udev_device *dev;
+
+ dev = find_device(udev, optarg, "/sys");
if (dev == NULL) {
log_error("unable to open the device '%s'", optarg);
return 2;
}
+
udev_enumerate_add_match_parent(udev_enumerate, dev);
- /* drop reference immediately, enumerate pins the device as long as needed */
- udev_device_unref(dev);
break;
}
+
case 'h':
help();
return 0;