jffs2reset: support fristboot on unmounted UBI overlay
[project/fstools.git] / jffs2reset.c
index 2236e380bd82b9fd5e2c7171549b27cbb3e3ec5c..acff913409da7a7dd271cd16c6f76848905fdc53 100644 (file)
 
 #include <fcntl.h>
 #include <dirent.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <getopt.h>
 
+#include <mtd/ubi-user.h>
 
 #include "libfstools/libfstools.h"
 #include "libfstools/volume.h"
@@ -79,6 +81,13 @@ static int jffs2_mark(struct volume *v)
                return -1;
        }
 
+       if (volume_identify(v) == FS_UBIFS) {
+               uint64_t llz = 0;
+               int ret = ioctl(fd, UBI_IOCVOLUP, &llz);
+               close(fd);
+               return ret;
+       }
+
        sz = write(fd, &deadc0de, sizeof(deadc0de));
        close(fd);