ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit bb10563c7aac765de704131b6cbd4c64f6605110
parent 5c73758bba3cabadd34871c0361b938c05282168
Author: sin <sin@2f30.org>
Date:   Mon Aug 19 16:27:21 +0100

Make ubase compile with musl-gcc

Diffstat:
Makefile | 2+-
chvt.c | 7+++++--
halt.c | 2+-
reboot.c | 2+-
reboot.h | 32++++++++++++++++++++++++++++++++
5 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile @@ -3,7 +3,7 @@ include config.mk .POSIX: .SUFFIXES: .c .o -HDR = arg.h grabmntinfo.h proc.h util.h +HDR = arg.h grabmntinfo.h proc.h reboot.h util.h LIB = \ util/agetcwd.o \ util/apathmax.o \ diff --git a/chvt.c b/chvt.c @@ -1,5 +1,3 @@ -#include <linux/vt.h> -#include <linux/kd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -9,6 +7,11 @@ #include <sys/ioctl.h> #include "util.h" +#define KDGKBTYPE 0x4B33 /* get keyboard type */ + +#define VT_ACTIVATE 0x5606 /* make vt active */ +#define VT_WAITACTIVE 0x5607 /* wait for vt active */ + char *vts[] = { "/proc/self/fd/0", "/dev/console", diff --git a/halt.c b/halt.c @@ -1,8 +1,8 @@ /* See LICENSE file for copyright and license details. */ -#include <linux/reboot.h> #include <sys/syscall.h> #include <unistd.h> #include <stdio.h> +#include "reboot.h" #include "util.h" static void diff --git a/reboot.c b/reboot.c @@ -1,8 +1,8 @@ /* See LICENSE file for copyright and license details. */ -#include <linux/reboot.h> #include <sys/syscall.h> #include <unistd.h> #include <stdio.h> +#include "reboot.h" #include "util.h" static void diff --git a/reboot.h b/reboot.h @@ -0,0 +1,32 @@ +/* + * Magic values required to use _reboot() system call. + */ + +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_MAGIC2A 85072278 +#define LINUX_REBOOT_MAGIC2B 369367448 +#define LINUX_REBOOT_MAGIC2C 537993216 + + +/* + * Commands accepted by the _reboot() system call. + * + * RESTART Restart system using default command and mode. + * HALT Stop OS and give system control to ROM monitor, if any. + * CAD_ON Ctrl-Alt-Del sequence causes RESTART command. + * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task. + * POWER_OFF Stop OS and remove all power from system, if possible. + * RESTART2 Restart system using given command string. + * SW_SUSPEND Suspend system using software suspend if compiled in. + * KEXEC Restart system using a previously loaded Linux kernel + */ + +#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_SW_SUSPEND 0xD000FCE2 +#define LINUX_REBOOT_CMD_KEXEC 0x45584543