diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2011-07-08 00:42:35 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2011-07-08 00:42:35 +0200 |
commit | b05211fa3e19608f96db53f388959ab57f88c566 (patch) | |
tree | bced29fa24ad3f7f70e6ac8160739cd0c2c39cee /udev | |
parent | b59c22a7587201d24087567e2eb93ab78c74187a (diff) |
libudev: enumerate - add udev_enumerate_add_match_parent()
Diffstat (limited to 'udev')
-rw-r--r-- | udev/udevadm-trigger.c | 25 | ||||
-rw-r--r-- | udev/udevadm.xml | 6 |
2 files changed, 30 insertions, 1 deletions
diff --git a/udev/udevadm-trigger.c b/udev/udevadm-trigger.c index d31b4fbd8d..3b53be5646 100644 --- a/udev/udevadm-trigger.c +++ b/udev/udevadm-trigger.c @@ -103,6 +103,7 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[]) { "property-match", required_argument, NULL, 'p' }, { "tag-match", required_argument, NULL, 'g' }, { "sysname-match", required_argument, NULL, 'y' }, + { "parent-match", required_argument, NULL, 'b' }, { "help", no_argument, NULL, 'h' }, {} }; @@ -128,7 +129,7 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[]) const char *val; char buf[UTIL_PATH_SIZE]; - option = getopt_long(argc, argv, "vng:o:t:hc:p:s:S:a:A:y:", options, NULL); + option = getopt_long(argc, argv, "vng:o:t:hc:p:s:S:a:A:y:b:", options, NULL); if (option == -1) break; @@ -179,6 +180,27 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[]) case 'y': 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 (strncmp(optarg, udev_get_sys_path(udev), strlen(udev_get_sys_path(udev))) != 0) + util_strscpyl(path, sizeof(path), udev_get_sys_path(udev), optarg, NULL); + else + util_strscpy(path, sizeof(path), optarg); + util_remove_trailing_chars(path, '/'); + dev = udev_device_new_from_syspath(udev, path); + if (dev == NULL) { + err(udev, "unable to open the device '%s'\n", optarg); + rc = 2; + goto exit; + } + 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': printf("Usage: udevadm trigger OPTIONS\n" " --verbose print the list of devices while running\n" @@ -196,6 +218,7 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[]) " --property-match=<key>=<value> trigger devices with a matching property\n" " --tag-match=<key>=<value> trigger devices with a matching property\n" " --sysname-match=<name> trigger devices with a matching name\n" + " --parent-match=<name> trigger devices with that parent device\n" " --help\n\n"); goto exit; default: diff --git a/udev/udevadm.xml b/udev/udevadm.xml index b5fb971f3b..a106093569 100644 --- a/udev/udevadm.xml +++ b/udev/udevadm.xml @@ -252,6 +252,12 @@ specified multiple times and supports shell style pattern matching.</para> </listitem> </varlistentry> + <varlistentry> + <term><option>--parent-match=<replaceable>syspath</replaceable></option></term> + <listitem> + <para>Trigger events for all children of a given device.</para> + </listitem> + </varlistentry> </variablelist> </refsect2> |