From f2f3fc9356bfba3b45588ddbbd96b0a80464b14d Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Sat, 24 Nov 2018 01:12:52 -0500 Subject: Add to startup relevant shutdown rpc call --- startup/Makefile | 1 + startup/startup.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/startup/Makefile b/startup/Makefile index bda3ffb3..8df0bd85 100644 --- a/startup/Makefile +++ b/startup/Makefile @@ -20,6 +20,7 @@ makemode := server SRCS = startup.c OBJS = $(SRCS:.c=.o) \ + shutdownUser.o \ startupServer.o notifyServer.o startup_replyUser.o msgServer.o \ startup_notifyUser.o fsysServer.o fsServer.o ioServer.o target = startup diff --git a/startup/startup.c b/startup/startup.c index 3679ebc9..3ca38e64 100644 --- a/startup/startup.c +++ b/startup/startup.c @@ -52,7 +52,9 @@ #include #include #include +#include +#include "shutdown_U.h" #include "startup_notify_U.h" #include "startup_reply_U.h" #include "startup_S.h" @@ -74,6 +76,8 @@ const char *argp_program_version = STANDARD_HURD_VERSION (startup); #define OPT_KERNEL_TASK -1 +#define _SERVERS_SHUTDOWN _SERVERS "/shutdown" + static struct argp_option options[] = { @@ -173,6 +177,22 @@ getstring (char *buf, size_t bufsize) /** System shutdown **/ +/* Do an RPC to /servers/shutdown + * to call platform specific shutdown routine + */ +error_t +do_shutdown (void) +{ + shutdown_t pc; + + pc = file_name_lookup (_SERVERS_SHUTDOWN, O_READ, 0); + if (! MACH_PORT_VALID (pc)) + return errno; + + shutdown (pc); + return 0; +} + /* Reboot the microkernel. */ void reboot_mach (int flags) @@ -189,9 +209,13 @@ reboot_mach (int flags) fprintf (stderr, "%s: %sing Mach (flags %#x)...\n", program_invocation_short_name, BOOT (flags), flags); sleep (5); - err = host_reboot (host_priv, flags); - if (err) - error (1, err, "reboot"); + if (flags & RB_HALT) { + do_shutdown(); + } else { + err = host_reboot (host_priv, flags); + if (err) + error (1, err, "reboot"); + } for (;;) sleep (1); } } -- cgit v1.2.3