summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-01-04 18:05:07 +0000
committerDaniel Golle <daniel@makrotopia.org>2021-01-04 20:55:32 +0000
commitc53b18820756f6f32ad0782d3bf489422b7c4ad3 (patch)
treeebb145b8f22dee9a9e3b57aab373480a287757fb
parentf415323b7c87d66ab11d89325937d5dae5eb65c9 (diff)
downloadfstools-c53b18820756f6f32ad0782d3bf489422b7c4ad3.tar.gz
jffs2reset: support fristboot on unmounted UBI overlay
To erase the overlay partitions on systems using UBIFS overlay, instead of writing the jffs2-marker, truncating the UBI volume to 0 has the desired effect. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--jffs2reset.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/jffs2reset.c b/jffs2reset.c
index 2236e38..acff913 100644
--- a/jffs2reset.c
+++ b/jffs2reset.c
@@ -19,12 +19,14 @@
#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);