From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Biggers Subject: [PATCH 4/6] ext4: switch to using fscrypt_match_name() Date: Mon, 24 Apr 2017 10:00:11 -0700 Message-ID: <20170424170013.85175-5-ebiggers3@gmail.com> References: <20170424170013.85175-1-ebiggers3@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d2hNW-0004dX-7J for linux-f2fs-devel@lists.sourceforge.net; Mon, 24 Apr 2017 17:02:22 +0000 Received: from mail-pg0-f68.google.com ([74.125.83.68]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1d2hNV-0000zI-ES for linux-f2fs-devel@lists.sourceforge.net; Mon, 24 Apr 2017 17:02:22 +0000 Received: by mail-pg0-f68.google.com with SMTP id g2so5628096pge.2 for ; Mon, 24 Apr 2017 10:02:21 -0700 (PDT) In-Reply-To: <20170424170013.85175-1-ebiggers3@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: linux-fscrypt@vger.kernel.org Cc: hashimoto@chromium.org, Gwendal Grignou , "Theodore Y . Ts'o" , Eric Biggers , linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, Jaegeuk Kim , linux-ext4@vger.kernel.org, kinaba@chromium.org From: Eric Biggers Switch ext4 directory searches to use the fscrypt_match_name() helper function. There should be no functional change. Signed-off-by: Eric Biggers --- fs/ext4/namei.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index e6301b6933fc..6ecc3ae87a79 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1245,29 +1245,17 @@ static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block) static inline int ext4_match(struct ext4_filename *fname, struct ext4_dir_entry_2 *de) { - const void *name = fname_name(fname); - u32 len = fname_len(fname); + struct fscrypt_name f; if (!de->inode) return 0; + f.usr_fname = fname->usr_fname; + f.disk_name = fname->disk_name; #ifdef CONFIG_EXT4_FS_ENCRYPTION - if (unlikely(!name)) { - if (fname->usr_fname->name[0] == '_') { - int ret; - if (de->name_len <= 32) - return 0; - ret = memcmp(de->name + ((de->name_len - 17) & ~15), - fname->crypto_buf.name + 8, 16); - return (ret == 0) ? 1 : 0; - } - name = fname->crypto_buf.name; - len = fname->crypto_buf.len; - } + f.crypto_buf = fname->crypto_buf; #endif - if (de->name_len != len) - return 0; - return (memcmp(de->name, name, len) == 0) ? 1 : 0; + return fscrypt_match_name(&f, de->name, de->name_len); } /* -- 2.12.2.816.g2cccc81164-goog ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot