summaryrefslogtreecommitdiffstats
path: root/upgraded/upgraded.c
diff options
context:
space:
mode:
Diffstat (limited to 'upgraded/upgraded.c')
-rw-r--r--upgraded/upgraded.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c
index 1e4057a..d7433e7 100644
--- a/upgraded/upgraded.c
+++ b/upgraded/upgraded.c
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include <libubox/uloop.h>
@@ -55,12 +56,14 @@ int main(int argc, char **argv)
{
pid_t p = getpid();
- chdir("/tmp");
-
if (p != 1) {
fprintf(stderr, "this tool needs to run as pid 1\n");
return -1;
}
+ if (chdir("/tmp") == -1) {
+ fprintf(stderr, "failed to chdir to /tmp: %s\n", strerror(errno));
+ return -1;
+ }
if (argc != 2) {
fprintf(stderr, "sysupgrade stage 2 failed, no folder specified\n");
return -1;