From patchwork Thu Nov 11 07:42:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Piggin X-Patchwork-Id: 316722 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAB7lNoe032167 for ; Thu, 11 Nov 2010 07:47:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757821Ab0KKHrj (ORCPT ); Thu, 11 Nov 2010 02:47:39 -0500 Received: from ipmail06.adl2.internode.on.net ([150.101.137.129]:46714 "EHLO ipmail06.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757788Ab0KKHrj (ORCPT ); Thu, 11 Nov 2010 02:47:39 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 11 Nov 2010 07:47:39 +0000 (UTC) X-Greylist: delayed 303 seconds by postgrey-1.27 at vger.kernel.org; Thu, 11 Nov 2010 02:47:38 EST X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AloEAI4t20x5LcZKgWdsb2JhbACiPhYBARYiIr9ohUoEj2c Received: from ppp121-45-198-74.lns20.cbr1.internode.on.net (HELO laptop.local0.net) ([121.45.198.74]) by ipmail06.adl2.internode.on.net with ESMTP; 11 Nov 2010 18:12:20 +1030 Received: by laptop.local0.net (Postfix, from userid 1000) id 025E22981A; Thu, 11 Nov 2010 18:42:16 +1100 (EST) Date: Thu, 11 Nov 2010 18:42:16 +1100 From: Nick Piggin To: Steve French , linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [patch] cifs: don't overwrite dentry name in d_revalidate Message-ID: <20101111074216.GA10159@amd> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Index: linux-2.6/fs/cifs/dir.c =================================================================== --- linux-2.6.orig/fs/cifs/dir.c 2010-11-11 18:05:55.000000000 +1100 +++ linux-2.6/fs/cifs/dir.c 2010-11-11 18:06:49.000000000 +1100 @@ -656,22 +656,34 @@ cifs_lookup(struct inode *parent_dir_ino static int cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd) { - int isValid = 1; - if (direntry->d_inode) { if (cifs_revalidate_dentry(direntry)) return 0; - } else { - cFYI(1, "neg dentry 0x%p name = %s", - direntry, direntry->d_name.name); - if (time_after(jiffies, direntry->d_time + HZ) || - !lookupCacheEnabled) { - d_drop(direntry); - isValid = 0; - } + else + return 1; + } + + /* + * This may be nfsd (or something), anyway, we can't see the + * intent of this. So, since this can be for creation, drop it. + */ + if (!nd) + return 0; + + /* + * Drop the negative dentry, in order to make sure to use the + * case sensitive name which is specified by user if this is + * for creation. + */ + if (!(nd->flags & (LOOKUP_CONTINUE | LOOKUP_PARENT))) { + if (nd->flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET)) + return 0; } - return isValid; + if (time_after(jiffies, direntry->d_time + HZ) || !lookupCacheEnabled) + return 0; + + return 1; } /* static int cifs_d_delete(struct dentry *direntry) @@ -709,15 +721,8 @@ static int cifs_ci_compare(struct dentry struct nls_table *codepage = CIFS_SB(dentry->d_inode->i_sb)->local_nls; if ((a->len == b->len) && - (nls_strnicmp(codepage, a->name, b->name, a->len) == 0)) { - /* - * To preserve case, don't let an existing negative dentry's - * case take precedence. If a is not a negative dentry, this - * should have no side effects - */ - memcpy((void *)a->name, b->name, a->len); + (nls_strnicmp(codepage, a->name, b->name, a->len) == 0)) return 0; - } return 1; }