[OpenWrt-Devel] add reusable function for getting fs type txt
diff mbox

Message ID 1455446268-22289-1-git-send-email-banglang.huang@foxmail.com
State Superseded
Headers show

Commit Message

=?ISO-8859-1?B?VHltb24=?= Feb. 14, 2016, 10:37 a.m. UTC
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@foxmail.com>
---
 libfstools/overlay.c |   10 ++--------
 libfstools/volume.c  |   12 ++++++++++++
 libfstools/volume.h  |    2 ++
 3 files changed, 16 insertions(+), 8 deletions(-)

Patch
diff mbox

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)