[OpenWrt-Devel] [PATCH] add reusable function for getting fs type txt
tymon
banglang.huang at foxmail.com
Sun Feb 14 05:37:48 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 | 12 ++++++++++++
libfstools/volume.h | 2 ++
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/libfstools/overlay.c b/libfstools/overlay.c
index cdac23e..358dbec 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_identify_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_identify_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..c08f0de 100644
--- a/libfstools/volume.c
+++ b/libfstools/volume.c
@@ -50,3 +50,15 @@ struct volume* volume_find(char *name)
return NULL;
}
+
+char *volume_identify_txt(struct volume *v)
+{
+ switch (volume_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..fdd82c8 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_identify_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