Skip to content
Snippets Groups Projects
Unverified Commit dfdba5b4 authored by Luca Weiss's avatar Luca Weiss Committed by Martijn Braam
Browse files

main/reboot-mode: Fix printing of error (!551)

Previously, running reboot-mode as an unprivileged user resulted in

    Error: No error information

without a newline at the end. According to SYSCALL(2), the return value
of -1 indicated an error, but the actual error code is stored in errno.
parent 9d6a3540
Branches
No related tags found
No related merge requests found
Pipeline #196243 failed
# Contributor: Daniele Debernardi <drebrez@gmail.com>
# Maintainer: Daniele Debernardi <drebrez@gmail.com>
pkgname=reboot-mode
pkgver=0.1
pkgver=0.2
pkgrel=0
pkgdesc="Reboot the device to a specific mode"
url="https://postmarketos.org"
......@@ -22,4 +22,4 @@ package() {
"${pkgdir}/usr/sbin/reboot-mode"
}
sha512sums="37d282608f30b1b8fa4f7501a8afcaa81902c9dfaee0c4c92ab05028e3a99a69c601dc7fce6ab06582db044b6fd0f5bffabe9d6064af9e670266978d66fe2515 reboot-mode.c"
sha512sums="a0cd4097d24fb6c66edce60558942d18ccf45925013013e5af5437471b1a855abe12857deb45b5f970b04e8b9dba99177b9080fff584fbd16262f0a7aabbf4b1 reboot-mode.c"
......@@ -4,6 +4,7 @@
*
* Copyright (C) 2019 Daniele Debernardi <drebrez@gmail.com>
*/
#include <errno.h>
#include <linux/reboot.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -42,8 +43,8 @@ int main(int argc, char **argv)
int ret;
ret = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, argv[1]);
if (ret) {
printf("Error: %s", strerror(ret));
if (ret < 0) {
printf("Error: %s\n", strerror(errno));
}
return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment