From patchwork Wed Nov 21 19:06:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10693089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC2F65A4 for ; Wed, 21 Nov 2018 19:06:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9899A2B68D for ; Wed, 21 Nov 2018 19:06:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C9792BBD8; Wed, 21 Nov 2018 19:06:58 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 E5F4C2B68D for ; Wed, 21 Nov 2018 19:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387604AbeKVFm2 (ORCPT ); Thu, 22 Nov 2018 00:42:28 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35368 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731652AbeKVFm1 (ORCPT ); Thu, 22 Nov 2018 00:42:27 -0500 Received: by mail-wm1-f66.google.com with SMTP id c126so6838341wmh.0 for ; Wed, 21 Nov 2018 11:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=TmS1fJ2p3HHs72FwPm8tH2F4GxL8g3gv4cjnbLcwU/E=; b=yafzqe5MZZhM5MdmzFDoCRzFEzDSu1VHjahsyzHwiAGFI4iSD7bQS/K7tCKw2O4fXK YWwtLMRMdLSD57mMBt75S4Dc8PqT++XLcxZrZe+w0tdxr2lfSS0S09WxUQ5RjnLsly+G hO0oA04ilfr7vgPJk4eD/ouqxCcA5W27E683y2fHzT+BFzGlz+jKLkioRpOMIX6dS9aJ YUYkeTofABbbtcoSpyoutQnTdWgdbl6xn/AQxggaYEt9G8VYP3/SMEwtMgt5bgseKLnm FbX/OoKBWvJCCd5UrEJ+Un9CWawm0S9lDviYqa22gqdd/39ksbcjTdqyP0dzI35EcOWw E67Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=TmS1fJ2p3HHs72FwPm8tH2F4GxL8g3gv4cjnbLcwU/E=; b=KfWGflaiEzouyovd8+PLIyVYxEUwM/5KtdbUcSKnxI4C/29R73mnyX9/DXjVD+9+Af 1/g/V9Kx02vCLNyrqUYu7riaqFZqz2Kdvf/GqvdKgKyAJTV/LS2VgRx9WInciugs56wB psozQ1w73MSN+ymDY7SltnkcxSPN3/hNRB3IIfN0d9DLyIiuKhrBCavDL0X68TkL8XMM xzIeE+GXbZiBL+xZdStqhqNbM6sPaFxVZxjJieXBckQnbHio3/JtWpGwTO/P18xzwnqy OToi6M3lnBgJ15DEWlCBpNCroR3uy0DEp0ICCIzGyRnfyw/46fQZYbyGcC0nt6BMFlQx Th9w== X-Gm-Message-State: AGRZ1gKX2DKlwnUeN2szAzVGmh4fwMyGOXvDhzHTJmne3SyMXs5htbrQ 5PkxDfgl1Om4FBf9Bw5YMzYWtQeB4Np/8Q== X-Google-Smtp-Source: AFSGD/UEazrZInxWaX3VGpr+4tTCYceztWUzByum6j1NU6RhYXLh2PnMnLQjEZTzgBjZ552rZ7E1rQ== X-Received: by 2002:a1c:f614:: with SMTP id w20-v6mr6657254wmc.136.1542827213706; Wed, 21 Nov 2018 11:06:53 -0800 (PST) Received: from pathfinder (62-64-249-96.dynamic.dsl.as9105.com. [62.64.249.96]) by smtp.gmail.com with ESMTPSA id x10sm15237507wrn.29.2018.11.21.11.06.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:06:53 -0800 (PST) Date: Wed, 21 Nov 2018 19:06:52 +0000 From: Phillip Potter To: linux-fsdevel@vger.kernel.org Cc: amir73il@gmail.com, viro@zeniv.linux.org.uk, slava@dubeyko.com Subject: [RFC][PATCH v4 03/09] hfsplus: use fs_umode_to_dtype() helper Message-ID: <20181121190652.GA7703@pathfinder> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace if/else statements with common lookup table implementation - file systems that use the same file types as defined by POSIX do not need to define their own versions and can use the common helper functions decared in fs_types.h and implemented in fs_types.c Reviewed-by: Vyacheslav Dubeyko Signed-off-by: Amir Goldstein Signed-off-by: Phillip Potter Reviewed-by: Jan Kara --- fs/hfsplus/dir.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index f37662675c3a..7b798a46c8ac 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -223,7 +223,6 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) break; } else if (type == HFSPLUS_FILE) { u16 mode; - unsigned type = DT_UNKNOWN; if (fd.entrylength < sizeof(struct hfsplus_cat_file)) { pr_err("small file entry\n"); @@ -232,21 +231,10 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) } mode = be16_to_cpu(entry.file.permissions.mode); - if (S_ISREG(mode)) - type = DT_REG; - else if (S_ISLNK(mode)) - type = DT_LNK; - else if (S_ISFIFO(mode)) - type = DT_FIFO; - else if (S_ISCHR(mode)) - type = DT_CHR; - else if (S_ISBLK(mode)) - type = DT_BLK; - else if (S_ISSOCK(mode)) - type = DT_SOCK; if (!dir_emit(ctx, strbuf, len, - be32_to_cpu(entry.file.id), type)) + be32_to_cpu(entry.file.id), + fs_umode_to_dtype(mode))) break; } else { pr_err("bad catalog entry type\n");