summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2016-09-07 17:30:09 +0200
committerFelix Fietkau <nbd@nbd.name>2016-09-08 13:05:57 +0200
commit9668e2ef2855ab95d8f2b2868d72c8ca5d742047 (patch)
tree713fab8d7bb48afc686b20483a0af706e392f0f0
parentb71082c52e4855bc2c8c5ca70cf21ee27e88f2bd (diff)
downloadfstools-9668e2ef2855ab95d8f2b2868d72c8ca5d742047.tar.gz
libfstools: call volume_init() before accessing v->blk
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--jffs2reset.c1
-rw-r--r--libfstools/overlay.c5
-rw-r--r--libfstools/ubi.c2
-rw-r--r--mount_root.c1
-rw-r--r--snapshot.c7
5 files changed, 12 insertions, 4 deletions
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 {