From patchwork Sun Feb 14 10:37:48 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: 582485 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 9C55914031F for ; Sun, 14 Feb 2016 21:38:04 +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=XnsvgpS+; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 247C328446B; Sun, 14 Feb 2016 11:37:56 +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 BBADA2810B2 for ; Sun, 14 Feb 2016 11:37:49 +0100 (CET) X-policyd-weight: using cached result; rate: -7.66 Received: from smtpbg64.qq.com (smtpbg62.qq.com [103.7.29.139]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 14 Feb 2016 11:37:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1455446254; bh=39+N30UN78iMU11N+zZbZiVMFuBJr9oifShjFVmpr4I=; h=From:To:Cc:Subject:Date:Message-Id; b=XnsvgpS+NI1i1kvzVP0c/G7TISefuBfnpjKP3OJCGETx3LAI98p3pxZEvmSgxVpZ3 PAX0bqMuE+flxRpLwIOh563BaofwGIPfKw1PDNi1CcVOoLhlgoqskNhw7eQHcJZXtR xpXlr3hRU6XHPqHQ6En6R0FBjNQ9LaKwoKbxWuGw= X-QQ-mid: esmtp32t1455446253t555t28807 Received: from localhost (unknown [27.38.56.24]) by esmtp4.qq.com (ESMTP) with id ; Sun, 14 Feb 2016 18:37:33 +0800 (CST) X-QQ-SSF: B1010000000000F0FG100F00000000Z X-QQ-FEAT: /d/5qLpbrmmqfCbj6/rTtMvuDiQWp/gZle0mgRSwaiTPZaMEnXIwnTSVcAgtF tlqMqUp3i61x0+LqG3agCLNB+NFjKj4bviNov8TjejESvn0VR72Aifk3S1TC82xPTQDrfPI uFC6q5Rx2ic5Kjra08yI8i5/6qdenjvesnod059TiM0/WD4UucHkBH69eBJ7mGeflyxrRFF 2G5QQ/9V4YO9T24v4iynqAtdAqd5TYaAyg3RDPvqKLIDbz/kQw5DdXNPEKI3kiCo= X-QQ-GoodBg: 0 From: tymon To: openwrt-devel@lists.openwrt.org Date: Sun, 14 Feb 2016 18:37:48 +0800 Message-Id: <1455446268-22289-1-git-send-email-banglang.huang@foxmail.com> X-Mailer: git-send-email 1.7.9.5 X-QQ-SENDSIZE: 520 Subject: [OpenWrt-Devel] [PATCH] 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 | 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)