jffs2reset: use jffs2_mark if rootfs_data isn't mounted
authorRafał Miłecki <zajec5@gmail.com>
Sat, 11 Apr 2015 07:56:44 +0000 (09:56 +0200)
committerJohn Crispin <blogic@openwrt.org>
Sun, 12 Apr 2015 19:08:22 +0000 (21:08 +0200)
Erasing all rootfs_data blocks may cause some problems with partition
identification. It won't contain MAGIC, but will be successfully mounted
with delayed blocks marking. This may be really confusing when user
reboots before JFFS2 finishes its blocks management. During the next
boot rootfs_data will be a valid partition (possibly with data) but
libblkid won't detect it.
Also adjust message in jffs2_mark to make more sense when used together
with jffs2_reset.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
jffs2reset.c

index 778a97e..0410466 100644 (file)
@@ -27,6 +27,8 @@
 #include "libfstools/libfstools.h"
 #include "libfstools/volume.h"
 
 #include "libfstools/libfstools.h"
 #include "libfstools/volume.h"
 
+static int jffs2_mark(struct volume *v);
+
 static int
 ask_user(int argc, char **argv)
 {
 static int
 ask_user(int argc, char **argv)
 {
@@ -50,8 +52,8 @@ static int jffs2_reset(struct volume *v)
                overlay_delete(mp, false);
                mount(mp, "/", NULL, MS_REMOUNT, 0);
        } else {
                overlay_delete(mp, false);
                mount(mp, "/", NULL, MS_REMOUNT, 0);
        } else {
-               ULOG_INFO("%s is not mounted, erasing it\n", v->blk);
-               volume_erase_all(v);
+               ULOG_INFO("%s is not mounted\n", v->blk);
+               return jffs2_mark(v);
        }
 
        return 0;
        }
 
        return 0;
@@ -64,7 +66,7 @@ static int jffs2_mark(struct volume *v)
        int fd;
 
        fd = open(v->blk, O_WRONLY);
        int fd;
 
        fd = open(v->blk, O_WRONLY);
-       ULOG_INFO("%s - marking with deadc0de\n", v->blk);
+       ULOG_INFO("%s will be erased on next mount\n", v->blk);
        if (!fd) {
                ULOG_ERR("opening %s failed\n", v->blk);
                return -1;
        if (!fd) {
                ULOG_ERR("opening %s failed\n", v->blk);
                return -1;