From patchwork Mon Apr 24 17:00:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9696799 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 23105603F3 for ; Mon, 24 Apr 2017 17:02:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F15E2817F for ; Mon, 24 Apr 2017 17:02:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03F3828400; Mon, 24 Apr 2017 17:02:52 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 A6C162817F for ; Mon, 24 Apr 2017 17:02:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S975311AbdDXRCu (ORCPT ); Mon, 24 Apr 2017 13:02:50 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33468 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S975304AbdDXRCW (ORCPT ); Mon, 24 Apr 2017 13:02:22 -0400 Received: by mail-pf0-f194.google.com with SMTP id c198so5125977pfc.0; Mon, 24 Apr 2017 10:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tesUWqOWRTp7ZDN2kOUuMpSU8pRp76RFCP71petwl7s=; b=Aqo1qx0RcgJ7GRY00q0JGi7boLx+6hkNNumFmssKNpqFkAdtvMDDRnPmx44E1CrEsy Jpl5JkG0OfS5oIFE4KDLVlrDY1B3AsxHA8gNyAzGTHr8bQg5aMd1/eY3y7fgdoZOWpTO Pkt7xIwuvoDL3HNpRZwMrRULM5Uv0od/t1eTAZrxd7d4VPwsamNRURdGbUEfiBHob1f0 M9eaYLw1Xb3DyBCRGfPkLDcfWEyXBnywTV5NCQI9zDDrfJLzlS9tykEn5/dW+gfylHYb qny3b2NzOWA9kP8+QtyOGcQZPVF9fg5ZCAaEcK7GxmiYghY976uUOoKsgUY/VMvuknaD gRxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tesUWqOWRTp7ZDN2kOUuMpSU8pRp76RFCP71petwl7s=; b=auMlOpOlcRW1ZxYd0ZfzeHqlZa44e3nO5gMwsh4At4Rr8PIQhpebN/fUrb2HdHrvFU lX/icatSx5G6FEghRSpgyRhs+hHbkzid9JjD+TtBMhoY4ZPxfzw61b7jMLpeqc3lgfP+ ybov1YktEppSHuEJdrBxiNPcN6cSR2Bw6ZE2uG4vSVK68xPQ+NiB7UmB7LOiUqTC4UtH RMiIEotscK/BtbYnraxud8HGoG8SWIiTPyMXUMi4ZBDCv87g/OwHAw3Dd+WmLOLm79kS CPAsB66vMTwCHX757O9jaWyZGr0QW6exd5/WrjldYF+smQLcmw7JCimYyFTp+r7Vh7Tn bXyg== X-Gm-Message-State: AN3rC/4VsLQACoGee2TEbk9rTUi6f/t4hTdOIzZKvCuV33PeSziXnm22 esNb7U1VVAY4mw== X-Received: by 10.98.148.2 with SMTP id m2mr26011016pfe.28.1493053337080; Mon, 24 Apr 2017 10:02:17 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.119.30.131]) by smtp.gmail.com with ESMTPSA id s89sm31927267pfi.79.2017.04.24.10.02.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Apr 2017 10:02:16 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: "Theodore Y . Ts'o" , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-mtd@lists.infradead.org, Gwendal Grignou , hashimoto@chromium.org, kinaba@chromium.org, Eric Biggers Subject: [PATCH 5/6] f2fs: switch to using fscrypt_match_name() Date: Mon, 24 Apr 2017 10:00:12 -0700 Message-Id: <20170424170013.85175-6-ebiggers3@gmail.com> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog In-Reply-To: <20170424170013.85175-1-ebiggers3@gmail.com> References: <20170424170013.85175-1-ebiggers3@gmail.com> Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers Switch f2fs directory searches to use the fscrypt_match_name() helper function. There should be no functional change. Signed-off-by: Eric Biggers Acked-by: Jaegeuk Kim --- fs/f2fs/dir.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 5df3596a667a..c7ed25fb3003 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -111,8 +111,6 @@ struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname, struct f2fs_dir_entry *de; unsigned long bit_pos = 0; int max_len = 0; - struct fscrypt_str de_name = FSTR_INIT(NULL, 0); - struct fscrypt_str *name = &fname->disk_name; if (max_slots) *max_slots = 0; @@ -130,29 +128,11 @@ struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname, continue; } - if (de->hash_code != namehash) - goto not_match; - - de_name.name = d->filename[bit_pos]; - de_name.len = le16_to_cpu(de->name_len); - -#ifdef CONFIG_F2FS_FS_ENCRYPTION - if (unlikely(!name->name)) { - if (fname->usr_fname->name[0] == '_') { - if (de_name.len > 32 && - !memcmp(de_name.name + ((de_name.len - 17) & ~15), - fname->crypto_buf.name + 8, 16)) - goto found; - goto not_match; - } - name->name = fname->crypto_buf.name; - name->len = fname->crypto_buf.len; - } -#endif - if (de_name.len == name->len && - !memcmp(de_name.name, name->name, name->len)) + if (de->hash_code == namehash && + fscrypt_match_name(fname, d->filename[bit_pos], + le16_to_cpu(de->name_len))) goto found; -not_match: + if (max_slots && max_len > *max_slots) *max_slots = max_len; max_len = 0;