diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-21 17:42:59 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-02-22 10:42:06 +0100 |
commit | c52a937b460f8f32d6bb55a405faf247822b70a7 (patch) | |
tree | 2d9a7a570424fe30b938726ed878a534ce122291 /src/basic/raw-reboot.h | |
parent | d06f3829cdfcf1798419a9efded245fd1202f0db (diff) | |
download | systemd-c52a937b460f8f32d6bb55a405faf247822b70a7.tar.gz |
basic: add a common syscall wrapper around reboot()
This mimics the raw_clone() call we have in place already and
establishes a new syscall wrapper raw_reboot() that wraps the kernel's
reboot() system call in a bit more low-level fashion that glibc's
reboot() wrapper. The main difference is that the extra "arg" argument
is supported.
Ultimately this just replaces the syscall wrapper implementation we
currently have at three places in our codebase by a single one.
With this change this means that all our syscall() invocations are
neatly separated out in static inline system call wrappers in our header
functions.
Diffstat (limited to 'src/basic/raw-reboot.h')
-rw-r--r-- | src/basic/raw-reboot.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/basic/raw-reboot.h b/src/basic/raw-reboot.h new file mode 100644 index 0000000000..8ecefe9e21 --- /dev/null +++ b/src/basic/raw-reboot.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ +#pragma once + +#include <linux/reboot.h> +#include <sys/reboot.h> +#include <sys/syscall.h> + +/* glibc defines the reboot() API call, which is a wrapper around the system call of the same name, but without the + * extra "arg" parameter. Since we need that parameter for some calls, let's add a "raw" wrapper that is defined the + * same way, except it takes the additional argument. */ + +static inline int raw_reboot(int cmd, const void *arg) { + return (int) syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, arg); +} |