From: Lennart Poettering Date: Mon, 4 Apr 2022 14:01:25 +0000 (+0200) Subject: udevadm: if invalid devices are specified on "info" verb, continue X-Git-Tag: v251-rc2~203^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ba77d8f5510d5b86c8ab94590e8a030c40509b6;p=thirdparty%2Fsystemd.git udevadm: if invalid devices are specified on "info" verb, continue If multiple devices are specified on "udevadm info", then show data about them all even if one is missing. Return first encountered error though. --- diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index 73dbbcaa333..12a1769bd86 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -489,7 +489,7 @@ static int help(void) { int info_main(int argc, char *argv[], void *userdata) { _cleanup_strv_free_ char **devices = NULL; _cleanup_free_ char *name = NULL; - int c, r; + int c, r, ret; enum { ARG_PROPERTY = 0x100, @@ -631,14 +631,21 @@ int info_main(int argc, char *argv[], void *userdata) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "-x/--export or -P/--export-prefix cannot be used with --value"); + ret = 0; STRV_FOREACH(p, devices) { _cleanup_(sd_device_unrefp) sd_device *device = NULL; r = find_device(*p, NULL, &device); - if (r == -EINVAL) - return log_error_errno(r, "Bad argument \"%s\", expected an absolute path in /dev/ or /sys or a unit name: %m", *p); - if (r < 0) - return log_error_errno(r, "Unknown device \"%s\": %m", *p); + if (r < 0) { + if (r == -EINVAL) + log_error_errno(r, "Bad argument \"%s\", expected an absolute path in /dev/ or /sys/ or a unit name: %m", *p); + else + log_error_errno(r, "Unknown device \"%s\": %m", *p); + + if (ret == 0) + ret = r; + continue; + } if (arg_wait_for_initialization_timeout > 0) { sd_device *d; @@ -665,5 +672,5 @@ int info_main(int argc, char *argv[], void *userdata) { return r; } - return 0; + return ret; }