From patchwork Sun Jan 31 13:01:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "b.l.huang" X-Patchwork-Id: 576185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 08B75140C4F for ; Mon, 1 Feb 2016 00:01:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=foxmail.com header.i=@foxmail.com header.b=Y3r4lZVx; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 9BB1C2814BC; Sun, 31 Jan 2016 14:01:32 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 99849281200 for ; Sun, 31 Jan 2016 14:01:25 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from smtpbg298.qq.com (smtpbg298.qq.com [184.105.67.102]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 31 Jan 2016 14:01:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1454245271; bh=QvNd/oarQNSqqtP1gz24SXvhTxjpOl41D1Ij5BvcIXI=; h=From:To:Cc:Subject:Date:Message-Id; b=Y3r4lZVxK7R48uqbOBY+G+sEIhl3jvWgaLptYn1AQVhD0YnHeS6F+Li9DjYKG0FSj n35/c/1viXuuI35AFPGnbqZvtG38PK3NfyfXNmIow52rStRptiEN3BjV0zdU6RVlZD AOgKtbgKDiIolWGjm4SLeuaA653ijMU5Kubt9uLY= X-QQ-mid: esmtp31t1454245267t878t13965 Received: from localhost (unknown [27.38.56.28]) by esmtp4.qq.com (ESMTP) with id ; Sun, 31 Jan 2016 21:01:07 +0800 (CST) X-QQ-SSF: B1010000000000F0FG100F00000000Z X-QQ-FEAT: 0TlhUl35Zqfz7eTzfNKvtyGddOX/pipDf1/IPWavXko5lVIzBkogf4Mwk6mCF XVczuSYfAjSTV+gTkmy4X9rJWB6CLvU0U2YULlle6WMZXWL6bJ52hPyE6uI22O3qsJ82GT6 GGFscB6e9X9KOelCj+qb5AR/eagq9aArFHjd+YnTj25qmjwo3it8DruU16OwmIFllTSkbBY PrPJania5EnC650p0nKBcm6OK0yFf5IJB0IUyyLb3d5zizNjPw4gKWbVf7Xogwn4= X-QQ-GoodBg: 0 From: tymon To: openwrt-devel@lists.openwrt.org Date: Sun, 31 Jan 2016 21:01:06 +0800 Message-Id: <1454245266-11684-1-git-send-email-banglang.huang@foxmail.com> X-Mailer: git-send-email 1.7.9.5 X-QQ-SENDSIZE: 520 X-QQ-FName: B692C6842B944623A01539402561F866 X-QQ-LocalIP: 10.198.131.167 Subject: [OpenWrt-Devel] [PATCH] fstools: add reusable function for getting fs type txt X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 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 --- 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)