From: Daniel Golle Date: Sat, 21 Jun 2014 20:07:26 +0000 (+0200) Subject: fix jffs2reset on ubifs overlay X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=cd3d4999a622af4830e4da974f4baafc085bad4d;p=project%2Ffstools.git fix jffs2reset on ubifs overlay change find_mount_point parameter to match either all or only jffs2 and ubifs, which are typically used on embedded mtd devices. For now, find_mount_point was used without the fstype parameter except for a single occurance in jffs2reset. There it is desireable to apply the same logic as previously hard-coded to jffs2 also in the case of a ubifs overlay, so firstboot aka. factory-reset works as expected. Signed-off-by: Daniel Golle --- diff --git a/jffs2reset.c b/jffs2reset.c index 122e03b..5684872 100644 --- a/jffs2reset.c +++ b/jffs2reset.c @@ -84,7 +84,7 @@ jffs2_reset(int argc, char **argv) return -1; } - mp = find_mount_point(v->blk, "jffs2"); + mp = find_mount_point(v->blk, 1); if (mp) { fprintf(stderr, "%s is mounted as %s, only erasing files\n", v->blk, mp); foreachdir(mp, handle_rmdir); diff --git a/libfstools/find.c b/libfstools/find.c index 71548f5..d9df173 100644 --- a/libfstools/find.c +++ b/libfstools/find.c @@ -73,7 +73,7 @@ find_mount(char *mp) } char* -find_mount_point(char *block, char *fs) +find_mount_point(char *block, int mtd_only) { FILE *fp = fopen("/proc/mounts", "r"); static char line[256]; @@ -96,7 +96,9 @@ find_mount_point(char *block, char *fs) *t = '\0'; t++; - if (fs && strncmp(t, fs, strlen(fs))) { + if (mtd_only && + strncmp(t, "jffs2", 6) && + strncmp(t, "ubifs", 6)) { fclose(fp); fprintf(stderr, "block is mounted with wrong fs\n"); return NULL; diff --git a/libfstools/jffs2.c b/libfstools/jffs2.c index 0da9f2f..134e09d 100644 --- a/libfstools/jffs2.c +++ b/libfstools/jffs2.c @@ -172,7 +172,7 @@ jffs2_switch(int argc, char **argv) } v = volume_find("rootfs_data"); - mp = find_mount_point(v->blk, NULL); + mp = find_mount_point(v->blk, 0); if (mp) { fprintf(stderr, "rootfs_data:%s is already mounted as %s\n", v->blk, mp); return -1; @@ -240,7 +240,7 @@ int mount_overlay(void) if (!v) return -1; - mp = find_mount_point(v->blk, NULL); + mp = find_mount_point(v->blk, 0); if (mp) { fprintf(stderr, "rootfs_data:%s is already mounted as %s\n", v->blk, mp); return -1; diff --git a/libfstools/libfstools.h b/libfstools/libfstools.h index f9cafbd..70220c2 100644 --- a/libfstools/libfstools.h +++ b/libfstools/libfstools.h @@ -37,7 +37,7 @@ extern int ramoverlay(void); extern int find_overlay_mount(char *overlay); extern char* find_mount(char *mp); -extern char* find_mount_point(char *block, char *fs); +extern char* find_mount_point(char *block, int mtd_only); extern int find_filesystem(char *fs); extern int find_mtd_block(char *name, char *part, int plen); extern int find_mtd_char(char *name, char *part, int plen); diff --git a/libfstools/overlay.c b/libfstools/overlay.c index ae0ead3..dc350b5 100644 --- a/libfstools/overlay.c +++ b/libfstools/overlay.c @@ -158,7 +158,7 @@ jffs2_switch(int argc, char **argv) } v = volume_find("rootfs_data"); - mp = find_mount_point(v->blk, NULL); + mp = find_mount_point(v->blk, 0); if (mp) { fprintf(stderr, "rootfs_data:%s is already mounted as %s\n", v->blk, mp); return -1; @@ -244,7 +244,7 @@ int mount_overlay(void) if (!v) return -1; - mp = find_mount_point(v->blk, NULL); + mp = find_mount_point(v->blk, 0); if (mp) { fprintf(stderr, "rootfs_data:%s is already mounted as %s\n", v->blk, mp); return -1;