From: Felix Fietkau Date: Wed, 7 Sep 2016 15:30:09 +0000 (+0200) Subject: libfstools: call volume_init() before accessing v->blk X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffstools.git;a=commitdiff_plain;h=9668e2ef2855ab95d8f2b2868d72c8ca5d742047 libfstools: call volume_init() before accessing v->blk Signed-off-by: Felix Fietkau --- diff --git a/jffs2reset.c b/jffs2reset.c index 97fd0ab..9a31fdd 100644 --- a/jffs2reset.c +++ b/jffs2reset.c @@ -125,6 +125,7 @@ int main(int argc, char **argv) return -1; } + volume_init(v); if (!strcmp(*argv, "jffs2mark")) return jffs2_mark(v); return jffs2_reset(v, reset); diff --git a/libfstools/overlay.c b/libfstools/overlay.c index db80798..f68065e 100644 --- a/libfstools/overlay.c +++ b/libfstools/overlay.c @@ -111,7 +111,7 @@ overlay_mount(struct volume *v, char *fs) return -1; } - return volume_init(v); + return 0; } static int @@ -206,6 +206,7 @@ jffs2_switch(struct volume *v) return ret; } + volume_init(v); mp = find_mount_point(v->blk, 0); if (mp) { ULOG_ERR("rootfs_data:%s is already mounted as %s\n", v->blk, mp); @@ -272,8 +273,6 @@ static int overlay_mount_fs(struct volume *v) break; } - volume_init(v); - if (mount(v->blk, "/tmp/overlay", fstype, MS_NOATIME, NULL)) { ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %s\n", fstype, v->blk, strerror(errno)); diff --git a/libfstools/ubi.c b/libfstools/ubi.c index c5a33df..c1dce46 100644 --- a/libfstools/ubi.c +++ b/libfstools/ubi.c @@ -160,7 +160,7 @@ static int ubi_volume_match(struct volume *v, char *name, int ubi_num, int volid p->ubi_num = ubi_num; p->ubi_volid = volid; - return ubi_volume_init(v); + return 0; } static int ubi_part_match(struct volume *v, char *name, unsigned int ubi_num) diff --git a/mount_root.c b/mount_root.c index 6e06b45..dbe1d65 100644 --- a/mount_root.c +++ b/mount_root.c @@ -56,6 +56,7 @@ start(int argc, char *argv[1]) } /* There isn't extroot, so just try to mount "rootfs_data" */ + volume_init(data); switch (volume_identify(data)) { case FS_NONE: ULOG_WARN("no usable overlay filesystem found, using tmpfs overlay\n"); diff --git a/snapshot.c b/snapshot.c index 6552a74..bb44cd3 100644 --- a/snapshot.c +++ b/snapshot.c @@ -45,6 +45,7 @@ config_write(int argc, char **argv) if (!v) return -1; + volume_init(v); ret = volatile_write(v, 0); if (!ret) ret = sentinel_write(v, 0); @@ -63,6 +64,7 @@ config_read(int argc, char **argv) if (!v) return -1; + volume_init(v); block = config_find(v, &conf, &sentinel); next = snapshot_next_free(v, &seq); if (is_config(&conf) && conf.seq == seq) @@ -89,6 +91,7 @@ snapshot_write(int argc, char **argv) if (!v) return -1; + volume_init(v); block = snapshot_next_free(v, &seq); if (block < 0) block = 0; @@ -120,6 +123,8 @@ snapshot_mark(int argc, char **argv) return -1; } + volume_init(v); + fd = open(v->blk, O_WRONLY); ULOG_INFO("%s - marking with 0x%08x\n", v->blk, owrt); if (fd < 0) { @@ -148,6 +153,7 @@ snapshot_read(int argc, char **argv) if (!v) return -1; + volume_init(v); if (argc > 2) { block = atoi(argv[2]); if (block >= (v->size / v->block_size)) { @@ -180,6 +186,7 @@ snapshot_info(void) if (!v) return -1; + volume_init(v); ULOG_INFO("sectors:\t%" PRIu64 ", block_size:\t%dK\n", (uint64_t) v->size / v->block_size, v->block_size / 1024); do {