X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev%2Fudevadm-trigger.c;h=c256a9e5daaa0e5808e4da648d21e6ca990c2456;hp=8d25f923995bfa66733c4bddc41cc2e05c935cf1;hb=065db052211d3bf08d9b0f698a79a8798faf11d2;hpb=13ddea815496b32bd0ae0a648cdc50af28d69bb1 diff --git a/udev/udevadm-trigger.c b/udev/udevadm-trigger.c index 8d25f9239..c256a9e5d 100644 --- a/udev/udevadm-trigger.c +++ b/udev/udevadm-trigger.c @@ -49,8 +49,7 @@ static void exec_list(struct udev_enumerate *udev_enumerate, const char *action) printf("%s\n", udev_list_entry_get_name(entry)); if (dry_run) continue; - util_strlcpy(filename, udev_list_entry_get_name(entry), sizeof(filename)); - util_strlcat(filename, "/uevent", sizeof(filename)); + util_strscpyl(filename, sizeof(filename), udev_list_entry_get_name(entry), "/uevent", NULL); fd = open(filename, O_WRONLY); if (fd < 0) { dbg(udev, "error on opening %s: %m\n", filename); @@ -79,16 +78,16 @@ static int scan_failed(struct udev_enumerate *udev_enumerate) int udevadm_trigger(struct udev *udev, int argc, char *argv[]) { static const struct option options[] = { - { "verbose", 0, NULL, 'v' }, - { "dry-run", 0, NULL, 'n' }, - { "type", 1, NULL, 't' }, - { "retry-failed", 0, NULL, 'F' }, - { "action", 1, NULL, 'c' }, - { "subsystem-match", 1, NULL, 's' }, - { "subsystem-nomatch", 1, NULL, 'S' }, - { "attr-match", 1, NULL, 'a' }, - { "attr-nomatch", 1, NULL, 'A' }, - { "help", 0, NULL, 'h' }, + { "verbose", no_argument, NULL, 'v' }, + { "dry-run", no_argument, NULL, 'n' }, + { "type", required_argument, NULL, 't' }, + { "retry-failed", no_argument, NULL, 'F' }, + { "action", required_argument, NULL, 'c' }, + { "subsystem-match", required_argument, NULL, 's' }, + { "subsystem-nomatch", required_argument, NULL, 'S' }, + { "attr-match", required_argument, NULL, 'a' }, + { "attr-nomatch", required_argument, NULL, 'A' }, + { "help", no_argument, NULL, 'h' }, {} }; enum { @@ -150,38 +149,38 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[]) udev_enumerate_add_nomatch_subsystem(udev_enumerate, optarg); break; case 'a': - util_strlcpy(attr, optarg, sizeof(attr)); + util_strscpy(attr, sizeof(attr), optarg); val = strchr(attr, '='); if (val != NULL) { val[0] = 0; val = &val[1]; } - udev_enumerate_add_match_attr(udev_enumerate, attr, val); + udev_enumerate_add_match_sysattr(udev_enumerate, attr, val); break; case 'A': - util_strlcpy(attr, optarg, sizeof(attr)); + util_strscpy(attr, sizeof(attr), optarg); val = strchr(attr, '='); if (val != NULL) { val[0] = 0; val = &val[1]; } - udev_enumerate_add_nomatch_attr(udev_enumerate, attr, val); + udev_enumerate_add_nomatch_sysattr(udev_enumerate, attr, val); break; case 'h': printf("Usage: udevadm trigger OPTIONS\n" " --verbose print the list of devices while running\n" " --dry-run do not actually trigger the events\n" " --type= type of events to trigger\n" - " devices sys devices\n" + " devices sys devices (default)\n" " subsystems sys subsystems and drivers\n" " failed trigger only the events which have been\n" " marked as failed during a previous run\n" + " --action= event action value, default is \"add\"\n" " --subsystem-match= trigger devices from a matching subystem\n" " --subsystem-nomatch= exclude devices from a matching subystem\n" " --attr-match=]> trigger devices with a matching attribute\n" " --attr-nomatch=]> exclude devices with a matching attribute\n" - " --help print this text\n" - "\n"); + " --help\n\n"); goto exit; default: goto exit;