From: Lennart Poettering Date: Wed, 21 Feb 2018 16:42:59 +0000 (+0100) Subject: basic: add a common syscall wrapper around reboot() X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=608b07b67bf9f097cec658e15d0adbff5f18985b;p=elogind.git 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. --- diff --git a/src/basic/meson.build b/src/basic/meson.build index 360c5db0b..cf0038b83 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -158,6 +158,7 @@ # ratelimit.c # ratelimit.h # raw-clone.h +# raw-reboot.h # refcnt.h # replace-var.c # replace-var.h diff --git a/src/basic/raw-reboot.h b/src/basic/raw-reboot.h new file mode 100644 index 000000000..3f7f63b4b --- /dev/null +++ b/src/basic/raw-reboot.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ +#pragma once + +//#include +//#include +//#include + +/* 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); +}