sysupgrade: print errno on failure
authorStijn Tintel <stijn@linux-ipv6.be>
Tue, 8 Nov 2022 12:43:25 +0000 (14:43 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 10 Nov 2022 20:30:59 +0000 (20:30 +0000)
The error message "Failed to exec upgraded." is not very informative.
Add errno to the message to make it more useful.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
sysupgrade.c

index fc588b0248353137d4b81fce130d2d35d8dfa710..96a29e919e0db0458695774519f0508c2ef41bdc 100644 (file)
 #include "sysupgrade.h"
 
 #include <ctype.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #include <libubox/blobmsg.h>
@@ -103,7 +105,7 @@ void sysupgrade_exec_upgraded(const char *prefix, char *path,
        execvp(argv[0], argv);
 
        /* Cleanup on failure */
-       fprintf(stderr, "Failed to exec upgraded.\n");
+       fprintf(stderr, "Failed to exec upgraded: %s\n", strerror(-errno));
        unsetenv("WDTFD");
        watchdog_set_cloexec(true);
        ret = chroot(".");