sysupgrade: print errno on failure staging/stintel/sysupgrade
authorStijn Tintel <stijn@linux-ipv6.be>
Tue, 8 Nov 2022 12:43:25 +0000 (14:43 +0200)
committerStijn Tintel <stijn@linux-ipv6.be>
Wed, 23 Nov 2022 15:25:25 +0000 (17:25 +0200)
The error message "Failed to exec upgraded." is not very informative.
Add errno to the message to make it more useful.

Lacks SoB to avoid people merging/pushing this to master.

sysupgrade.c

index fc588b0248353137d4b81fce130d2d35d8dfa710..e6c1c959bce4ed3a786afeec1778ec43b75da585 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>
@@ -100,10 +102,12 @@ void sysupgrade_exec_upgraded(const char *prefix, char *path,
                free(name);
        }
 
+       errno = 0;
+
        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(".");