[OpenWrt-Devel] [PATCH] fstools: add reusable function for getting fs type txt
tymon
banglang.huang at foxmail.com
Sun Jan 31 08:01:06 EST 2016
Add 'volume_identity_txt()' function so that we can use it to print the coressponding fs
type as 'char *' type when we need.
Signed-off-by: tymon <banglang.huang at foxmail.com>
---
libfstools/overlay.c | 10 ++--------
libfstools/volume.c | 14 ++++++++++++++
libfstools/volume.h | 2 ++
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/libfstools/overlay.c b/libfstools/overlay.c
index cdac23e..21101b0 100644
--- a/libfstools/overlay.c
+++ b/libfstools/overlay.c
@@ -264,13 +264,7 @@ static int overlay_mount_fs(struct volume *v)
return -1;
}
- fstype = "jffs2";
-
- switch (volume_identify(v)) {
- case FS_UBIFS:
- fstype = "ubifs";
- break;
- }
+ fstype = volume_identity_txt(v);
volume_init(v);
@@ -359,7 +353,7 @@ int mount_overlay(struct volume *v)
break;
}
- ULOG_INFO("switching to jffs2 overlay\n");
+ ULOG_INFO("switching to %s overlay\n", volume_identity_txt(v));
if (mount_move("/tmp", "", "/overlay") || fopivot("/overlay", "/rom")) {
ULOG_ERR("switching to jffs2 failed - fallback to ramoverlay\n");
return ramoverlay();
diff --git a/libfstools/volume.c b/libfstools/volume.c
index e81491e..007d525 100644
--- a/libfstools/volume.c
+++ b/libfstools/volume.c
@@ -50,3 +50,17 @@ struct volume* volume_find(char *name)
return NULL;
}
+
+char *volume_identity_txt(struct volume *v)
+{
+ if (v && v->drv->identify) {
+ switch (v->drv->identify(v)) {
+ case FS_UBIFS:
+ return "ubifs";
+ case FS_JFFS2:
+ return "jffs2";
+ }
+ }
+
+ return "UNKNOWN";
+}
diff --git a/libfstools/volume.h b/libfstools/volume.h
index 9c679f7..654f570 100644
--- a/libfstools/volume.h
+++ b/libfstools/volume.h
@@ -77,6 +77,8 @@ static inline int volume_identify(struct volume *v)
return -1;
}
+extern char *volume_identity_txt(struct volume *v);
+
static inline int volume_erase(struct volume *v, int offset, int len)
{
if (v && v->drv->erase)
--
1.7.9.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list