From patchwork Fri Jan 19 05:37:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10174581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE3BE6055D for ; Fri, 19 Jan 2018 05:38:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFABE28563 for ; Fri, 19 Jan 2018 05:38:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A478828583; Fri, 19 Jan 2018 05:38:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E0D628563 for ; Fri, 19 Jan 2018 05:38:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754118AbeASFiD (ORCPT ); Fri, 19 Jan 2018 00:38:03 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:53637 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753175AbeASFhs (ORCPT ); Fri, 19 Jan 2018 00:37:48 -0500 Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Thu, 18 Jan 2018 22:37:42 -0700 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 06/16] btrfs-progs: check: Move imode_to_type function to check/common.h Date: Fri, 19 Jan 2018 13:37:21 +0800 Message-Id: <20180119053731.10795-7-wqu@suse.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180119053731.10795-1-wqu@suse.com> References: <20180119053731.10795-1-wqu@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This function is shared between original and lowmem mode, and it's small enough, so move it to check/common.h. Signed-off-by: Qu Wenruo --- check/common.h | 19 +++++++++++++++++++ check/main.c | 17 ----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/check/common.h b/check/common.h index 8d93ddbf4afb..3e0a5ebee54b 100644 --- a/check/common.h +++ b/check/common.h @@ -20,6 +20,8 @@ */ #ifndef __BTRFS_CHECK_COMMON_H__ #define __BTRFS_CHECK_COMMON_H__ + +#include #include "ctree.h" /* @@ -53,4 +55,21 @@ extern struct btrfs_fs_info *global_info; extern struct task_ctx ctx; extern struct cache_tree *roots_info_cache; +static inline u8 imode_to_type(u32 imode) +{ +#define S_SHIFT 12 + static unsigned char btrfs_type_by_mode[S_IFMT >> S_SHIFT] = { + [S_IFREG >> S_SHIFT] = BTRFS_FT_REG_FILE, + [S_IFDIR >> S_SHIFT] = BTRFS_FT_DIR, + [S_IFCHR >> S_SHIFT] = BTRFS_FT_CHRDEV, + [S_IFBLK >> S_SHIFT] = BTRFS_FT_BLKDEV, + [S_IFIFO >> S_SHIFT] = BTRFS_FT_FIFO, + [S_IFSOCK >> S_SHIFT] = BTRFS_FT_SOCK, + [S_IFLNK >> S_SHIFT] = BTRFS_FT_SYMLINK, + }; + + return btrfs_type_by_mode[(imode & S_IFMT) >> S_SHIFT]; +#undef S_SHIFT +} + #endif diff --git a/check/main.c b/check/main.c index bb927ecc87ee..eaa8e7fbde20 100644 --- a/check/main.c +++ b/check/main.c @@ -425,23 +425,6 @@ static void record_root_in_trans(struct btrfs_trans_handle *trans, } } -static u8 imode_to_type(u32 imode) -{ -#define S_SHIFT 12 - static unsigned char btrfs_type_by_mode[S_IFMT >> S_SHIFT] = { - [S_IFREG >> S_SHIFT] = BTRFS_FT_REG_FILE, - [S_IFDIR >> S_SHIFT] = BTRFS_FT_DIR, - [S_IFCHR >> S_SHIFT] = BTRFS_FT_CHRDEV, - [S_IFBLK >> S_SHIFT] = BTRFS_FT_BLKDEV, - [S_IFIFO >> S_SHIFT] = BTRFS_FT_FIFO, - [S_IFSOCK >> S_SHIFT] = BTRFS_FT_SOCK, - [S_IFLNK >> S_SHIFT] = BTRFS_FT_SYMLINK, - }; - - return btrfs_type_by_mode[(imode & S_IFMT) >> S_SHIFT]; -#undef S_SHIFT -} - static int device_record_compare(struct rb_node *node1, struct rb_node *node2) { struct device_record *rec1;