Files
makronix/mobile/base/reboot2.c
T
lotherkandClaude Sonnet 5.5 73c9de51a6 licence: the CNCL line in every file Makronix wrote (tools, docs, www, mobile, top level)
consmirror.c: the BSD notice is replaced (Makronix's own file).  Files with
changes of other sessions pending are left for their commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 11:50:26 +00:00

36 lines
1.1 KiB
C

/* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. */
/*
* reboot2 MODE -- restart now and hand MODE to the kernel
* (LINUX_REBOOT_CMD_RESTART2), whose reboot-mode driver writes it where
* the bootloader reads it: "bootloader" (fastboot), "recovery". The modes
* a phone knows are the mode-* properties of its reboot-mode node in the
* DT (e.g. pon@800, qcom-pon.c).
*
* No unmounting: called last in runit's stage 3
* (/etc/runit/shutdown.d/95-reboot-mode.sh, after 80-filesystems), the way
* Void's 90-kexec.sh calls kexec -e. Users run reboot-mode(1) instead.
*
* Built by tools/mkrootimg.sh with the device's cross compiler, static,
* into /usr/libexec/makronix/reboot2: no shell, perl or python on Void
* can make this system call, and its reboot(8) takes no argument.
*/
#include <linux/reboot.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <unistd.h>
int
main(int argc, char **argv)
{
if (argc != 2) {
fprintf(stderr, "usage: reboot2 MODE\n");
return 2;
}
sync();
syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
LINUX_REBOOT_CMD_RESTART2, argv[1]);
perror("reboot2");
return 1;
}