From: maximilian attems <max@stro.at>
To: Simon Horman <horms@verge.net.au>
Cc: maximilian attems <max@stro.at>,
klibc@zytor.com, kexec@lists.infradead.org
Subject: [PATCH] kexec: simply pass LINUX_REBOOT_CMD_KEXEC to reboot
Date: Tue, 22 May 2012 18:09:58 +0200 [thread overview]
Message-ID: <1337702998-15080-1-git-send-email-max@stro.at> (raw)
While trying to port kexec cleanly to klibc,
came across this syscall usage for reboot(2).
Calling reboot directly simplifies the code.
Signed-off-by: maximilian attems <max@stro.at>
---
kexec/kexec-syscall.h | 20 --------------------
kexec/kexec.c | 4 +++-
2 files changed, 3 insertions(+), 21 deletions(-)
The next TODO item is to add proper syscall kexec_load() to glibc.
Funnily here klibc has an head start! -maks
diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h
index f4df45c..415fbd7 100644
--- a/kexec/kexec-syscall.h
+++ b/kexec/kexec-syscall.h
@@ -5,22 +5,6 @@
#include <sys/syscall.h>
#include <unistd.h>
-#define LINUX_REBOOT_MAGIC1 0xfee1dead
-#define LINUX_REBOOT_MAGIC2 672274793
-#define LINUX_REBOOT_MAGIC2A 85072278
-#define LINUX_REBOOT_MAGIC2B 369367448
-
-#define LINUX_REBOOT_CMD_RESTART 0x01234567
-#define LINUX_REBOOT_CMD_HALT 0xCDEF0123
-#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
-#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000
-#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC
-#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
-#define LINUX_REBOOT_CMD_EXEC_KERNEL 0x18273645
-#define LINUX_REBOOT_CMD_KEXEC_OLD 0x81726354
-#define LINUX_REBOOT_CMD_KEXEC_OLD2 0x18263645
-#define LINUX_REBOOT_CMD_KEXEC 0x45584543
-
#ifndef __NR_kexec_load
#ifdef __i386__
#define __NR_kexec_load 283
@@ -70,10 +54,6 @@ static inline long kexec_load(void *entry, unsigned long nr_segments,
return (long) syscall(__NR_kexec_load, entry, nr_segments, segments, flags);
}
-static inline long kexec_reboot(void)
-{
- return (long) syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_KEXEC, 0);
-}
#define KEXEC_ON_CRASH 0x00000001
diff --git a/kexec/kexec.c b/kexec/kexec.c
index d2d05a8..ee23b5e 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -28,6 +28,8 @@
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/reboot.h>
+#include <linux/reboot.h>
#include <unistd.h>
#include <fcntl.h>
#ifndef _O_BINARY
@@ -822,7 +824,7 @@ static int my_shutdown(void)
*/
static int my_exec(void)
{
- kexec_reboot();
+ reboot(LINUX_REBOOT_CMD_KEXEC);
/* I have failed if I make it here */
fprintf(stderr, "kexec failed: %s\n",
strerror(errno));
--
1.7.10
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
reply other threads:[~2012-05-22 16:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337702998-15080-1-git-send-email-max@stro.at \
--to=max@stro.at \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=klibc@zytor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox