From patchwork Thu Oct 15 04:04:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Yang X-Patchwork-Id: 530468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 88FEA1402B6 for ; Thu, 15 Oct 2015 15:13:49 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmZtr-0002xb-5x; Thu, 15 Oct 2015 04:12:19 +0000 Received: from [59.151.112.132] (helo=heian.cn.fujitsu.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmZtf-0002pj-Ur for linux-mtd@lists.infradead.org; Thu, 15 Oct 2015 04:12:09 +0000 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101857415" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Oct 2015 12:14:04 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t9F4BAYK010869; Thu, 15 Oct 2015 12:11:10 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 15 Oct 2015 12:11:38 +0800 From: Dongsheng Yang To: , , , , Subject: [PATCH v2 02/27] ubifs: pick some common definitions into ubifs_common.h Date: Thu, 15 Oct 2015 12:04:25 +0800 Message-ID: <1444881890-4012-3-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1444881890-4012-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1444881890-4012-1-git-send-email-yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.66] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151014_211208_398295_D1CAD13B X-CRM114-Status: GOOD ( 10.10 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dongsheng Yang Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently, lpt.c is including mkfs.ubifs.h. That make the lpt depend on mkfs.ubifs. It's not good if we want to introduce some more tools for ubifs, such as fsck.ubifs. This patch start to cut off the dependence from libs, such as lpt, devtable, to mkfs.ubifs. Signed-off-by: Dongsheng Yang --- ubifs-utils/mkfs.ubifs/mkfs.ubifs.h | 46 +------------------------------- ubifs-utils/mkfs.ubifs/ubifs_common.h | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 ubifs-utils/mkfs.ubifs/ubifs_common.h diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h index 944a159..d6d46a2 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.h @@ -23,37 +23,12 @@ #ifndef __MKFS_UBIFS_H__ #define __MKFS_UBIFS_H__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include "ubifs_common.h" /* common.h requires the PROGRAM_NAME macro */ #define PROGRAM_NAME "mkfs.ubifs" #include "common.h" -#include "libubi.h" -#include "defs.h" #include "crc16.h" #include "ubifs.h" #include "key.h" @@ -74,25 +49,6 @@ #error MKFS_UBIFS_COMPR_ZLIB != UBIFS_COMPR_ZLIB #endif -extern int verbose; -extern int debug_level; - -#define dbg_msg(lvl, fmt, ...) do {if (debug_level >= lvl) \ - printf("mkfs.ubifs: %s: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ -} while(0) - -#define err_msg(fmt, ...) ({ \ - fprintf(stderr, "Error: " fmt "\n", ##__VA_ARGS__); \ - -1; \ -}) - -#define sys_err_msg(fmt, ...) ({ \ - int err_ = errno; \ - fprintf(stderr, "Error: " fmt "\n", ##__VA_ARGS__); \ - fprintf(stderr, " %s (error %d)\n", strerror(err_), err_); \ - -1; \ -}) - /** * struct path_htbl_element - an element of the path hash table. * @path: the UBIFS path the element describes (the key of the element) diff --git a/ubifs-utils/mkfs.ubifs/ubifs_common.h b/ubifs-utils/mkfs.ubifs/ubifs_common.h new file mode 100644 index 0000000..958c20a --- /dev/null +++ b/ubifs-utils/mkfs.ubifs/ubifs_common.h @@ -0,0 +1,50 @@ +#ifndef __UBIFS_COMMON_H__ +#define __UBIFS_COMMON_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "libubi.h" +#include "defs.h" + +extern int verbose; +extern int debug_level; + +#define dbg_msg(lvl, fmt, ...) do {if (debug_level >= lvl) \ + printf("ubifs: %s: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ +} while(0) + +#define err_msg(fmt, ...) ({ \ + fprintf(stderr, "Error: " fmt "\n", ##__VA_ARGS__); \ + -1; \ +}) + +#define sys_err_msg(fmt, ...) ({ \ + int err_ = errno; \ + fprintf(stderr, "Error: " fmt "\n", ##__VA_ARGS__); \ + fprintf(stderr, " %s (error %d)\n", strerror(err_), err_); \ + -1; \ +}) +#endif