From patchwork Tue Oct 23 20:19:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10653617 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 234F213B5 for ; Tue, 23 Oct 2018 20:20:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1155B2A3F0 for ; Tue, 23 Oct 2018 20:20:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F7B12A41E; Tue, 23 Oct 2018 20:20:51 +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 ADE7F2A3F0 for ; Tue, 23 Oct 2018 20:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728641AbeJXEoz (ORCPT ); Wed, 24 Oct 2018 00:44:55 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45542 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbeJXEoy (ORCPT ); Wed, 24 Oct 2018 00:44:54 -0400 Received: by mail-wr1-f66.google.com with SMTP id f17-v6so3077800wrs.12 for ; Tue, 23 Oct 2018 13:19:57 -0700 (PDT) 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=95Fd5rI3XvksS6xocCMzSCrV7TdI040H8LYjyP/+fwo=; b=bunJ2uXkxmQaxPLh50ANlx5pUrnZXgnh6cXibToudhOLcIh9Io7LjOqY451eRPntaj C+qrp0bjdhc2hBfJ3ZAxCBZtjxBIKFu3zlY4/CNSqczjPCD7GdYr4nF5zsuHtDBU/F+l +DwGVQJ+nFJV6VVTs5miyebzOKg4z9UABmbHngilb0GIwTMueoTuW61EN083Q/3Ac0+s TtpR8G5kJaI6FIC+MSrgsVY+TWGVOtYPzpXp8RN4g63R1Qwj5vAe8j6VhkU7LEFCsSEK EpDUzLkFZ6cHSfrJzpGFmNeUhwSXUZX1hXcylFID358Xp2RKQS0feB8TEAhWzqBRFF37 QvNA== 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=95Fd5rI3XvksS6xocCMzSCrV7TdI040H8LYjyP/+fwo=; b=lWpPpQzBdaItlGEH2gRsIlNyoA4HYxiP51gNPsVlLGTbRNhBBcwwhPhg87W52As7Gz BPyMyC49Ni4FmQT3oLuiWBHwxkT5ulw3hYNkjz65dRHGlwjtvhy4rUj0L6AupC6e981Y KKADE48ZgSTV10/Q+Teb0lEf9R0Xr/G3PSDWY1QIGRcRga8h5XIu11NAgqmBNocZLcbO Lb5UMpDZHeWHL06A+1T+CUAFUZ5nDfy02My55bn0F78oHLw10dLEMOy2Veko8hioRmM8 95zljfzWB2W+Y1bC23b9/reDp8s3o91qINSlhuHpUDW9SNscmXicrnSvJKCsENYP5nue PFmg== X-Gm-Message-State: AGRZ1gLiQoxwVBwQMHrnaSoWePyEzqh6BAtVDyY0gsZVo9FHCtKcV/f5 ntiER1dDR2lSt17oWO/5xgjusg== X-Google-Smtp-Source: AJdET5ehCc00RM9LpCWbGfPgTkkR5UrJd8Tl1zumpw4iX0pR6rgoVxBYvFiDHNNHGuwbE1gxuCdR6g== X-Received: by 2002:a5d:4086:: with SMTP id o6-v6mr20755369wrp.133.1540325996303; Tue, 23 Oct 2018 13:19:56 -0700 (PDT) Received: from pathfinder (62-64-249-96.dynamic.dsl.as9105.com. [62.64.249.96]) by smtp.gmail.com with ESMTPSA id a18sm1470274wrx.55.2018.10.23.13.19.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 13:19:55 -0700 (PDT) Date: Tue, 23 Oct 2018 21:19:55 +0100 From: Phillip Potter To: dushistov@mail.ru Cc: linux-kernel@vger.kernel.org, amir73il@gmail.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH 02/10] ufs: use fs_umode_to_dtype() helper Message-ID: <20181023201955.GA15694@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 switch statement with common lookup table implementation. Original patch written by Amir Goldstein. Signed-off-by: Phillip Potter --- fs/ufs/util.h | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/fs/ufs/util.h b/fs/ufs/util.h index 1fd3011ea623..8c7759860739 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h @@ -158,34 +158,7 @@ ufs_set_de_type(struct super_block *sb, struct ufs_dir_entry *de, int mode) if ((UFS_SB(sb)->s_flags & UFS_DE_MASK) != UFS_DE_44BSD) return; - /* - * TODO turn this into a table lookup - */ - switch (mode & S_IFMT) { - case S_IFSOCK: - de->d_u.d_44.d_type = DT_SOCK; - break; - case S_IFLNK: - de->d_u.d_44.d_type = DT_LNK; - break; - case S_IFREG: - de->d_u.d_44.d_type = DT_REG; - break; - case S_IFBLK: - de->d_u.d_44.d_type = DT_BLK; - break; - case S_IFDIR: - de->d_u.d_44.d_type = DT_DIR; - break; - case S_IFCHR: - de->d_u.d_44.d_type = DT_CHR; - break; - case S_IFIFO: - de->d_u.d_44.d_type = DT_FIFO; - break; - default: - de->d_u.d_44.d_type = DT_UNKNOWN; - } + de->d_u.d_44.d_type = fs_umode_to_dtype(mode); } static inline u32 From patchwork Tue Oct 23 20:19:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10653605 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 76DC214BD for ; Tue, 23 Oct 2018 20:20:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FFB12A3E4 for ; Tue, 23 Oct 2018 20:20:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 544582A3EA; Tue, 23 Oct 2018 20:20:04 +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 AB7E92A3E5 for ; Tue, 23 Oct 2018 20:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728897AbeJXEo4 (ORCPT ); Wed, 24 Oct 2018 00:44:56 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51834 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727726AbeJXEoz (ORCPT ); Wed, 24 Oct 2018 00:44:55 -0400 Received: by mail-wm1-f67.google.com with SMTP id 143-v6so3069580wmf.1 for ; Tue, 23 Oct 2018 13:19:58 -0700 (PDT) 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=2rgD7RkIz8RrksTmcPFlaMjrDpZ6eKiDDFJ0lLZWZXQ=; b=X4sjJDFAynbd9O8BW0ZnALfYUXzqRyP+mt7/l5CCldfAf1ieebi23SSA7WpxTeP7g5 Y2bCbEHpbGidoESXsO5P2TrWFsioKjjzzyrMSAeQqSzVYhZMhh5AAxMhUbxU1aHLrROk reQX6I5blXzZ3AMjCpW+ggIJfUWTvAUm+IGFmXDznl/IZ0/NGXUvhQQt2GblGwu8jClM caaOgFyUv5JJBhlcPBY/K9c3JlF3PYtlFA1hrbWI8mL5VvU8d4ES0sf42gCpTiA6/nH4 YEnjtd+ZwrLwofNQ3gL2zBzpmpaauqvPCfuY4YcBunU/a7Diw/RXuThZwWRrIVOX44SC cRLQ== 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=2rgD7RkIz8RrksTmcPFlaMjrDpZ6eKiDDFJ0lLZWZXQ=; b=NaGvHl6WERt0RJU9MrsrBHf7oor0xELqRv+1cShRvLL55jYZM3FxUmo+yJ9mDTsVq8 8lXqeMMWvcLbeYli16NUeNCewk7UBs6YBzvW+WuZE3qE1csMrghotXLB2k+IG/Rj3YFS /rPv0RP1ydDz8cbYVn/i/PxEXwzhh+icoAmWX1YPa+OoYrJLIYcnNn16eQfJDsg1+LzR IYLjr157GbzTrIaWKcoGw0OIcNEwyoE3Lp2veL9q/1JCorGOc+KoRKKgfAjTiVS3uATP 5GXAGzhtSMC0IUONnF/pcWawORrJs/c2dunoQj9jKz7pazkyQ2SEPq2X/9BPtT3jkmXm qfew== X-Gm-Message-State: ABuFfognZ65q0girPcq8HrSQ2tMoYa+wJaNBjN4Hs6Hyw+CX5YWFDlKl ygWCk3WAIpo1JcEw7e8kSdjyyfSBCq6B0A7M X-Google-Smtp-Source: AJdET5dOnlEezDBSrlCRxBFT01dsGPmoMnL4LUxnbZXJjtMKZtVvz697LGaExXIKYvQsLfn4mTxGdg== X-Received: by 2002:a1c:1a45:: with SMTP id a66-v6mr5327821wma.20.1540325997514; Tue, 23 Oct 2018 13:19:57 -0700 (PDT) Received: from pathfinder (62-64-249-96.dynamic.dsl.as9105.com. [62.64.249.96]) by smtp.gmail.com with ESMTPSA id h78-v6sm3292578wmd.4.2018.10.23.13.19.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 13:19:56 -0700 (PDT) Date: Tue, 23 Oct 2018 21:19:56 +0100 From: Phillip Potter To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, amir73il@gmail.com, viro@zeniv.linux.org.uk Subject: [RFC][PATCH 03/10] hfsplus: use fs_umode_to_dtype() helper Message-ID: <20181023201956.GA15701@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. Original patch written by Amir Goldstein. Signed-off-by: Phillip Potter Reviewed-by: Vyacheslav Dubeyko --- 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");