X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Finitctl%2Finitctl.c;h=ecec7a16a75c1aa81b38187cc96f2a0f0575ee96;hb=2eec67acbb00593e414549a7e5b35eb7dd776b1b;hp=242ad3eca0f5c23ae5ed69c94125a4b99f664535;hpb=da927ba997d68401563b927f92e6e40e021a8e5c;p=elogind.git
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index 242ad3eca..ecec7a16a 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -19,18 +19,10 @@
along with systemd; If not, see .
***/
-#include
-#include
-#include
-#include
-#include
#include
#include
#include
-#include
#include
-#include
-#include
#include
#include "sd-daemon.h"
@@ -78,15 +70,15 @@ static const char *translate_runlevel(int runlevel, bool *isolate) {
const char *special;
bool isolate;
} table[] = {
- { '0', SPECIAL_POWEROFF_TARGET, false },
- { '1', SPECIAL_RESCUE_TARGET, true },
- { 's', SPECIAL_RESCUE_TARGET, true },
- { 'S', SPECIAL_RESCUE_TARGET, true },
- { '2', SPECIAL_RUNLEVEL2_TARGET, true },
- { '3', SPECIAL_RUNLEVEL3_TARGET, true },
- { '4', SPECIAL_RUNLEVEL4_TARGET, true },
- { '5', SPECIAL_RUNLEVEL5_TARGET, true },
- { '6', SPECIAL_REBOOT_TARGET, false },
+ { '0', SPECIAL_POWEROFF_TARGET, false },
+ { '1', SPECIAL_RESCUE_TARGET, true },
+ { 's', SPECIAL_RESCUE_TARGET, true },
+ { 'S', SPECIAL_RESCUE_TARGET, true },
+ { '2', SPECIAL_MULTI_USER_TARGET, true },
+ { '3', SPECIAL_MULTI_USER_TARGET, true },
+ { '4', SPECIAL_MULTI_USER_TARGET, true },
+ { '5', SPECIAL_GRAPHICAL_TARGET, true },
+ { '6', SPECIAL_REBOOT_TARGET, false },
};
unsigned i;
@@ -162,7 +154,7 @@ static void request_process(Server *s, const struct init_request *req) {
case 'u':
case 'U':
if (kill(1, SIGTERM) < 0)
- log_error("kill() failed: %m");
+ log_error_errno(errno, "kill() failed: %m");
/* The bus connection will be
* terminated if PID 1 is reexecuted,
@@ -175,7 +167,7 @@ static void request_process(Server *s, const struct init_request *req) {
case 'q':
case 'Q':
if (kill(1, SIGHUP) < 0)
- log_error("kill() failed: %m");
+ log_error_errno(errno, "kill() failed: %m");
break;
default:
@@ -217,7 +209,7 @@ static int fifo_process(Fifo *f) {
if (errno == EAGAIN)
return 0;
- log_warning("Failed to read from fifo: %m");
+ log_warning_errno(errno, "Failed to read from fifo: %m");
return -errno;
}
@@ -277,7 +269,7 @@ static int server_init(Server *s, unsigned n_sockets) {
s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (s->epoll_fd < 0) {
r = -errno;
- log_error("Failed to create epoll object: %m");
+ log_error_errno(errno, "Failed to create epoll object: %m");
goto fail;
}
@@ -290,8 +282,7 @@ static int server_init(Server *s, unsigned n_sockets) {
r = sd_is_fifo(fd, NULL);
if (r < 0) {
- log_error("Failed to determine file descriptor type: %s",
- strerror(-r));
+ log_error_errno(r, "Failed to determine file descriptor type: %m");
goto fail;
}
@@ -304,7 +295,7 @@ static int server_init(Server *s, unsigned n_sockets) {
f = new0(Fifo, 1);
if (!f) {
r = -ENOMEM;
- log_error("Failed to create fifo object: %m");
+ log_error_errno(errno, "Failed to create fifo object: %m");
goto fail;
}
@@ -316,7 +307,7 @@ static int server_init(Server *s, unsigned n_sockets) {
if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0) {
r = -errno;
fifo_free(f);
- log_error("Failed to add fifo fd to epoll object: %m");
+ log_error_errno(errno, "Failed to add fifo fd to epoll object: %m");
goto fail;
}
@@ -414,7 +405,7 @@ int main(int argc, char *argv[]) {
if (errno == EINTR)
continue;
- log_error("epoll_wait() failed: %m");
+ log_error_errno(errno, "epoll_wait() failed: %m");
goto fail;
}