mtd: Fail when verify fails
authorMichal Hrusecky <michal.hrusecky@nic.cz>
Thu, 25 Oct 2018 10:53:02 +0000 (12:53 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Tue, 11 Aug 2020 17:08:11 +0000 (19:08 +0200)
Return non-zero exit code when mtd verify fails.

Signed-off-by: Michal Hrusecky <michal.hrusecky@nic.cz>
package/system/mtd/src/mtd.c

index 9baed3fd5e9938792320320d45e9c4976d00dc47..99851c517bb0a0ce3fff25603bd86d0207026e75 100644 (file)
@@ -848,7 +848,7 @@ static void do_reboot(void)
 
 int main (int argc, char **argv)
 {
-       int ch, i, boot, imagefd = 0, force, unlocked;
+       int ch, i, boot, imagefd = 0, force, unlocked, ret = 0;
        char *erase[MAX_ARGS], *device = NULL;
        char *fis_layout = NULL;
        size_t offset = 0, data_size = 0, part_offset = 0, dump_len = 0;
@@ -1046,7 +1046,7 @@ int main (int argc, char **argv)
                                mtd_unlock(device);
                        break;
                case CMD_VERIFY:
-                       mtd_verify(device, imagefile);
+                       ret |= mtd_verify(device, imagefile);
                        break;
                case CMD_DUMP:
                        mtd_dump(device, offset, dump_len);
@@ -1095,5 +1095,5 @@ int main (int argc, char **argv)
        if (boot)
                do_reboot();
 
-       return 0;
+       return ret;
 }