diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-04-04 22:09:19 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-04-16 02:42:20 +0200 |
commit | 7b3048358b79f1eb7485c0c926cd32edc4ba8aa7 (patch) | |
tree | 14d795dcb2ff70a292eecc236bf10f3c3a107778 /src/udev | |
parent | udevadm-control: check if control command really specified (diff) | |
download | systemd-7b3048358b79f1eb7485c0c926cd32edc4ba8aa7.tar.xz systemd-7b3048358b79f1eb7485c0c926cd32edc4ba8aa7.zip |
udevadm-control: split out send_control_commands()
No functional change, just refactoring and preparation for later
commits.
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/udevadm-control.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c index 530dca8a5f..428d590413 100644 --- a/src/udev/udevadm-control.c +++ b/src/udev/udevadm-control.c @@ -165,19 +165,10 @@ static int parse_argv(int argc, char *argv[]) { return 1; } -int control_main(int argc, char *argv[], void *userdata) { +static int send_control_commands(void) { _cleanup_(udev_ctrl_unrefp) UdevCtrl *uctrl = NULL; int r; - if (running_in_chroot() > 0) { - log_info("Running in chroot, ignoring request."); - return 0; - } - - r = parse_argv(argc, argv); - if (r <= 0) - return r; - r = udev_ctrl_new(&uctrl); if (r < 0) return log_error_errno(r, "Failed to initialize udev control: %m"); @@ -237,3 +228,24 @@ int control_main(int argc, char *argv[], void *userdata) { return 0; } + +int control_main(int argc, char *argv[], void *userdata) { + int r; + + if (running_in_chroot() > 0) { + log_info("Running in chroot, ignoring request."); + return 0; + } + + r = parse_argv(argc, argv); + if (r <= 0) + return r; + + if (arg_has_control_commands()) { + r = send_control_commands(); + if (r < 0) + return r; + } + + return 0; +} |