[PATCH v2 1/2] ctrlaltdel: use reboot() provided by libc, assuming it is 1-adic.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 configure.ac           | 6 ++++++
 sys-utils/ctrlaltdel.c | 8 ++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6748dd2..6075f72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -378,6 +378,7 @@ AC_CHECK_FUNCS([ioperm iopl], [have_io=yes])
 AC_CHECK_FUNCS([futimens], [have_futimens=yes])
 AC_CHECK_FUNCS([inotify_init1], [have_inotify_init1=yes])
 AC_CHECK_FUNCS([open_memstream], [have_open_memstream=yes],[have_open_memstream=no])
+AC_CHECK_FUNCS([reboot], [have_reboot=yes],[have_reboot=no])
 
 dnl lib/mononotic.c may require -lrt
 AC_CHECK_FUNCS([clock_gettime], [],
@@ -1420,6 +1421,11 @@ AM_CONDITIONAL([BUILD_DMESG], [test "x$build_dmesg" = xyes])
 
 UL_BUILD_INIT([ctrlaltdel], [check])
 UL_REQUIRES_LINUX([ctrlaltdel])
+dnl we assume reboot() to be the 1-argument variant, because even considering
+dnl widely used alternative C libraries like uclibc, dietlibc and musl,
+dnl reboot() with multiple arguments is yet only found in glibc versions
+dnl earlier than 2.x.
+UL_REQUIRES_HAVE([ctrlaltdel], [reboot])
 AM_CONDITIONAL([BUILD_CTRLALTDEL], [test "x$build_ctrlaltdel" = xyes])
 
 UL_BUILD_INIT([fsfreeze], [check])
diff --git a/sys-utils/ctrlaltdel.c b/sys-utils/ctrlaltdel.c
index 4388925..4a69584 100644
--- a/sys-utils/ctrlaltdel.c
+++ b/sys-utils/ctrlaltdel.c
@@ -10,13 +10,17 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include "linux_reboot.h"
+#include <unistd.h>
+#include <sys/reboot.h>
 #include "nls.h"
 #include "c.h"
 #include "closestream.h"
 #include "pathnames.h"
 #include "path.h"
 
+#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
+#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000
+
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
 {
 	fprintf(out, USAGE_HEADER);
@@ -67,7 +71,7 @@ static int set_cad(const char *arg)
 		warnx(_("unknown argument: %s"), arg);
 		return EXIT_FAILURE;
 	}
-	if (my_reboot(cmd) < 0) {
+	if (reboot(cmd) < 0) {
 		warnx("reboot");
 		return EXIT_FAILURE;
 	}
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux