From patchwork Wed Nov 21 19:06:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10693087 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 DDFF65A4 for ; Wed, 21 Nov 2018 19:06:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA1E22B68D for ; Wed, 21 Nov 2018 19:06:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDD4C2BBD8; Wed, 21 Nov 2018 19:06:57 +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 66D702B694 for ; Wed, 21 Nov 2018 19:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387601AbeKVFm1 (ORCPT ); Thu, 22 Nov 2018 00:42:27 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:56027 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387566AbeKVFm0 (ORCPT ); Thu, 22 Nov 2018 00:42:26 -0500 Received: by mail-wm1-f68.google.com with SMTP id y139so6577038wmc.5 for ; Wed, 21 Nov 2018 11:06:53 -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=b4xhfmuJsvdLPfnEGpFEWrPBrAzhegd7lc5tStSVP6U=; b=nIKMEB6Co8CrAWuEU1sodccyMRD9sm7v+0GbZJhYOll0ZKlYkdx9QKvJHmVglzw7OK JUVa8Efm575aw7/yWhM4y1krp3IPBtMm0JhRXUy0M3OxUT57/7f+U0AO57qf2jpVe/UW OTKoUrK7iYY8X7iH8eb6QiPDHRqOtaGSTPIH/qs8R/iqBbiUB9X53yRSdfJHI0vlCJVR TpwFqF0Md9pnKw9pwrLqTmifxOJx8pF+yMtf+7oZXbcI8OUwaap4TUtGuSOk9v22gm3F hVdKZqOE0vN7TFC/5xMaZcMLZ1wEorDCmDGPyVJ+EtstIqSSoi1lYwTXB0JejebsPjWd uXbQ== 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=b4xhfmuJsvdLPfnEGpFEWrPBrAzhegd7lc5tStSVP6U=; b=BdqTRYDHfWI0IX2WRADOEzgpmYCmPRiA4kqZl6mm3gOQtMPzzxjzJEG6mzOzXOLOC2 FgIj3aoGpQOnr5qn6tLVYQk7hDFS6Irw1U9sIC0LIyeNZV02EhH0D2aUI3weOsiN5c6E GDWt462kKEbNvandIsWwsoIGg5p14ASVANl9a+zsnKOihU9An4v9VkRGFEaTvkQW680d TqZ9vEM/1setGHYA2kVm+YEeco7Kc/B3meDDTo73RQK4iA8W3s3hN3heKohCmCXsaxSl mB4nMq7spC3QlCOBf+D0a6IMiW8SfLZCLlQmY1RfU6WnvvQ24njjdOlOQP5Z8m80rTfH 4cYA== X-Gm-Message-State: AGRZ1gIVUHjZ4DhLKxLk5TKHhClwSYqcp6C9SfTrrXTIjcOJOUGtm8h0 BlnOr2wdyCIK+cw+Bx+3JqvFvg== X-Google-Smtp-Source: AJdET5faQYXN7b2twJMfnQ9kcz9tHj3YmerYDtI+Q5hPUmkcObqItecriahRVLf5edqh3hWMeeUdTQ== X-Received: by 2002:a7b:c5d1:: with SMTP id n17mr6928515wmk.152.1542827212263; Wed, 21 Nov 2018 11:06:52 -0800 (PST) Received: from pathfinder (62-64-249-96.dynamic.dsl.as9105.com. [62.64.249.96]) by smtp.gmail.com with ESMTPSA id g129sm1856252wmf.39.2018.11.21.11.06.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:06:51 -0800 (PST) Date: Wed, 21 Nov 2018 19:06:50 +0000 From: Phillip Potter To: dushistov@mail.ru Cc: amir73il@gmail.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH v4 02/09] ufs: use fs_umode_to_dtype() helper Message-ID: <20181121190650.GA7696@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 - 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 Signed-off-by: Amir Goldstein Signed-off-by: Phillip Potter Reviewed-by: Jan Kara --- 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