X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffstools.git;a=blobdiff_plain;f=libfstools%2Fjffs2.c;h=1b8e1d9734d2054d9af6325254b8e1085c57ecf2;hp=134e09dd269ec8b07ead380bae773b8d86fe6486;hb=1a57eb9b7cc5e772d1090a23c51fdd4a01ec5df0;hpb=cd3d4999a622af4830e4da974f4baafc085bad4d diff --git a/libfstools/jffs2.c b/libfstools/jffs2.c index 134e09d..1b8e1d9 100644 --- a/libfstools/jffs2.c +++ b/libfstools/jffs2.c @@ -52,21 +52,13 @@ foreachdir(const char *dir, int (*cb)(const char*)) } static int -jffs2_mount(void) +jffs2_mount(struct volume *v) { - struct volume *v; - if (mkdir("/tmp/overlay", 0755)) { fprintf(stderr, "failed to mkdir /tmp/overlay: %s\n", strerror(errno)); return -1; } - v = volume_find("rootfs_data"); - if (!v) { - fprintf(stderr, "rootfs_data does not exist\n"); - return -1; - } - if (mount(v->blk, "/tmp/overlay", "jffs2", MS_NOATIME, NULL)) { fprintf(stderr, "failed to mount -t jffs2 %s /tmp/overlay: %s\n", v->blk, strerror(errno)); return -1; @@ -76,9 +68,8 @@ jffs2_mount(void) } static int -switch2jffs(void) +switch2jffs(struct volume *v) { - struct volume *v = volume_find("rootfs_data"); struct stat s; int ret; @@ -87,11 +78,6 @@ switch2jffs(void) return -1; } - if (!v) { - fprintf(stderr, "no rootfs_data was found\n"); - return -1; - } - creat("/tmp/.switch_jffs2", 0600); ret = mount(v->blk, "/rom/overlay", "jffs2", MS_NOATIME, NULL); unlink("/tmp/.switch_jffs2"); @@ -157,9 +143,8 @@ handle_whiteout(const char *dir) } int -jffs2_switch(int argc, char **argv) +jffs2_switch(struct volume *v) { - struct volume *v; char *mp; int ret = -1; @@ -171,7 +156,6 @@ jffs2_switch(int argc, char **argv) return ret; } - v = volume_find("rootfs_data"); mp = find_mount_point(v->blk, 0); if (mp) { fprintf(stderr, "rootfs_data:%s is already mounted as %s\n", v->blk, mp); @@ -184,7 +168,7 @@ jffs2_switch(int argc, char **argv) /* fall through */ case FS_DEADCODE: - ret = switch2jffs(); + ret = switch2jffs(v); if (!ret) { fprintf(stderr, "doing fo cleanup\n"); umount2("/tmp/root", MNT_DETACH); @@ -193,7 +177,7 @@ jffs2_switch(int argc, char **argv) break; case FS_JFFS2: - ret = jffs2_mount(); + ret = jffs2_mount(v); if (ret) break; if (mount_move("/tmp", "", "/overlay") || fopivot("/overlay", "/rom")) { @@ -206,21 +190,13 @@ jffs2_switch(int argc, char **argv) return ret; } -static int mount_overlay_fs(void) +static int mount_overlay_fs(struct volume *v) { - struct volume *v; - if (mkdir("/tmp/overlay", 0755)) { fprintf(stderr, "failed to mkdir /tmp/overlay: %s\n", strerror(errno)); return -1; } - v = volume_find("rootfs_data"); - if (!v) { - fprintf(stderr, "rootfs_data does not exist\n"); - return -1; - } - if (mount(v->blk, "/tmp/overlay", "jffs2", MS_NOATIME, NULL)) { fprintf(stderr, "failed to mount -t jffs2 %s /tmp/overlay: %s\n", v->blk, strerror(errno)); @@ -232,21 +208,17 @@ static int mount_overlay_fs(void) return -1; } -int mount_overlay(void) +int mount_overlay(struct volume *v) { - struct volume *v = volume_find("rootfs_data");; char *mp; - if (!v) - return -1; - 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; } - mount_overlay_fs(); + mount_overlay_fs(v); extroot_prefix = "/tmp/overlay"; if (!mount_extroot()) {