* have udevadm control report system errors
@ 2009-09-14 1:04 Marco d'Itri
0 siblings, 0 replies; only message in thread
From: Marco d'Itri @ 2009-09-14 1:04 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 96 bytes --]
This patch makes udevadm control exit with rc=2 if there is some system
error.
--
ciao,
Marco
[-- Attachment #2: udevadm_report_failure --]
[-- Type: text/plain, Size: 3552 bytes --]
--- a/udev/udevadm-control.c
+++ b/udev/udevadm-control.c
@@ -68,8 +68,10 @@ int udevadm_control(struct udev *udev, i
}
uctrl = udev_ctrl_new_from_socket(udev, UDEV_CTRL_SOCK_PATH);
- if (uctrl == NULL)
+ if (uctrl == NULL) {
+ rc = 2;
goto exit;
+ }
while (1) {
int option;
@@ -93,31 +95,41 @@ int udevadm_control(struct udev *udev, i
fprintf(stderr, "invalid number '%s'\n", optarg);
goto exit;
}
- udev_ctrl_send_set_log_level(uctrl, util_log_priority(optarg));
- rc = 0;
+ if (udev_ctrl_send_set_log_level(uctrl, util_log_priority(optarg)) < 0)
+ rc = 2;
+ else
+ rc = 0;
break;
case 's':
case 's' + 256:
- udev_ctrl_send_stop_exec_queue(uctrl);
- rc = 0;
+ if (udev_ctrl_send_stop_exec_queue(uctrl) < 0)
+ rc = 2;
+ else
+ rc = 0;
break;
case 'S':
case 'S' + 256:
- udev_ctrl_send_start_exec_queue(uctrl);
- rc = 0;
+ if (udev_ctrl_send_start_exec_queue(uctrl) < 0)
+ rc = 2;
+ else
+ rc = 0;
break;
case 'R':
case 'R' + 256:
- udev_ctrl_send_reload_rules(uctrl);
- rc = 0;
+ if (udev_ctrl_send_reload_rules(uctrl) < 0)
+ rc = 2;
+ else
+ rc = 0;
break;
case 'p':
if (strchr(optarg, '=') == NULL) {
fprintf(stderr, "expect <KEY>=<value> instead of '%s'\n", optarg);
goto exit;
}
- udev_ctrl_send_set_env(uctrl, optarg);
- rc = 0;
+ if (udev_ctrl_send_set_env(uctrl, optarg) < 0)
+ rc = 2;
+ else
+ rc = 0;
break;
case 'm':
case 'm' + 256:
@@ -126,8 +138,10 @@ int udevadm_control(struct udev *udev, i
fprintf(stderr, "invalid number '%s'\n", optarg);
goto exit;
}
- udev_ctrl_send_set_max_childs(uctrl, i);
- rc = 0;
+ if (udev_ctrl_send_set_max_childs(uctrl, i) < 0)
+ rc = 2;
+ else
+ rc = 0;
break;
case 'h':
print_help();
@@ -146,33 +160,45 @@ int udevadm_control(struct udev *udev, i
"this will stop working in a future release\n");
if (!strncmp(arg, "log_priority=", strlen("log_priority="))) {
- udev_ctrl_send_set_log_level(uctrl, util_log_priority(&arg[strlen("log_priority=")]));
- rc = 0;
+ if (udev_ctrl_send_set_log_level(uctrl, util_log_priority(&arg[strlen("log_priority=")])) < 0)
+ rc = 2;
+ else
+ rc = 0;
goto exit;
} else if (!strcmp(arg, "stop_exec_queue")) {
- udev_ctrl_send_stop_exec_queue(uctrl);
- rc = 0;
+ if (udev_ctrl_send_stop_exec_queue(uctrl) < 0)
+ rc = 2;
+ else
+ rc = 0;
goto exit;
} else if (!strcmp(arg, "start_exec_queue")) {
- udev_ctrl_send_start_exec_queue(uctrl);
- rc = 0;
+ if (udev_ctrl_send_start_exec_queue(uctrl) < 0)
+ rc = 2;
+ else
+ rc = 0;
goto exit;
} else if (!strcmp(arg, "reload_rules")) {
- udev_ctrl_send_reload_rules(uctrl);
- rc = 0;
+ if (udev_ctrl_send_reload_rules(uctrl) < 0)
+ rc = 2;
+ else
+ rc = 0;
goto exit;
} else if (!strncmp(arg, "max_childs=", strlen("max_childs="))) {
- udev_ctrl_send_set_max_childs(uctrl, strtoul(&arg[strlen("max_childs=")], NULL, 0));
- rc = 0;
+ if (udev_ctrl_send_set_max_childs(uctrl, strtoul(&arg[strlen("max_childs=")], NULL, 0)) < 0)
+ rc = 2;
+ else
+ rc = 0;
goto exit;
} else if (!strncmp(arg, "env", strlen("env"))) {
- udev_ctrl_send_set_env(uctrl, &arg[strlen("env=")]);
- rc = 0;
+ if (udev_ctrl_send_set_env(uctrl, &arg[strlen("env=")]) < 0)
+ rc = 2;
+ else
+ rc = 0;
goto exit;
}
}
- if (rc != 0)
+ if (rc == 1)
err(udev, "unrecognized command\n");
exit:
udev_ctrl_unref(uctrl);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-14 1:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-14 1:04 have udevadm control report system errors Marco d'Itri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).