From mboxrd@z Thu Jan 1 00:00:00 1970 From: Igor Mammedov Subject: Re: dfs path construction fix - send dfs paths on all path based operations on share in dfs Date: Fri, 16 May 2008 14:03:58 +0400 Message-ID: <482D5C0E.2020007@gmail.com> References: <524f69650805131545id9be81et97549c74ecd0e7c8@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050403030102000703020301" Cc: "Q (Igor Mammedov)" , Jeremy Allison , Jeff Layton , linux-cifs-client@lists.samba.org, linux-fsdevel To: Steve French Return-path: Received: from fg-out-1718.google.com ([72.14.220.159]:47018 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbYEPKEF (ORCPT ); Fri, 16 May 2008 06:04:05 -0400 Received: by fg-out-1718.google.com with SMTP id 19so659043fgg.17 for ; Fri, 16 May 2008 03:04:02 -0700 (PDT) In-Reply-To: <524f69650805131545id9be81et97549c74ecd0e7c8@mail.gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This is a multi-part message in MIME format. --------------050403030102000703020301 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Steve French wrote: > Samba was not handling paths without the \\server\share prefix (which > our current code sends on QueryPathInfo) when "SHARE_IN_DFS" on > operations such as rmdir and delete. > > This patch fixes that: A set of patches that fixes path handling (broken by 646dd539878a194) in the DFS related parts of code in accordance with a new 'build_path_from_dentry' behavior. -- Best regards, ------------------------- Igor Mammedov, niallain "at" gmail.com --------------050403030102000703020301 Content-Type: text/x-patch; name="0002-Fixed-DFS-code-to-work-with-new-build_path_from_den.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0002-Fixed-DFS-code-to-work-with-new-build_path_from_den.pat"; filename*1="ch" >>From b5a37238de56db6a99db746b169fe3deba27b510 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Fri, 16 May 2008 13:10:32 +0400 Subject: [PATCH] Fixed DFS code to work with new 'build_path_from_dentry', that returns full path if share in the dfs, now. Signed-off-by: Igor Mammedov --- fs/cifs/cifs_dfs_ref.c | 49 +----------------------------------------------- 1 files changed, 1 insertions(+), 48 deletions(-) diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index f6fdecf..d82374c 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c @@ -219,53 +219,6 @@ static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent, } -static char *build_full_dfs_path_from_dentry(struct dentry *dentry) -{ - char *full_path = NULL; - char *search_path; - char *tmp_path; - size_t l_max_len; - struct cifs_sb_info *cifs_sb; - - if (dentry->d_inode == NULL) - return NULL; - - cifs_sb = CIFS_SB(dentry->d_inode->i_sb); - - if (cifs_sb->tcon == NULL) - return NULL; - - search_path = build_path_from_dentry(dentry); - if (search_path == NULL) - return NULL; - - if (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS) { - int i; - /* we should use full path name for correct working with DFS */ - l_max_len = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE+1) + - strnlen(search_path, MAX_PATHCONF) + 1; - tmp_path = kmalloc(l_max_len, GFP_KERNEL); - if (tmp_path == NULL) { - kfree(search_path); - return NULL; - } - strncpy(tmp_path, cifs_sb->tcon->treeName, l_max_len); - tmp_path[l_max_len-1] = 0; - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) - for (i = 0; i < l_max_len; i++) { - if (tmp_path[i] == '\\') - tmp_path[i] = '/'; - } - strncat(tmp_path, search_path, l_max_len - strlen(tmp_path)); - - full_path = tmp_path; - kfree(search_path); - } else { - full_path = search_path; - } - return full_path; -} - static int add_mount_helper(struct vfsmount *newmnt, struct nameidata *nd, struct list_head *mntlist) { @@ -333,7 +286,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) goto out_err; } - full_path = build_full_dfs_path_from_dentry(dentry); + full_path = build_path_from_dentry(dentry); if (full_path == NULL) { rc = -ENOMEM; goto out_err; -- 1.5.3.7 --------------050403030102000703020301 Content-Type: text/x-patch; name="0003-Fixed-inode-lookup-code-DFS-related-part-to-suppor.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0003-Fixed-inode-lookup-code-DFS-related-part-to-suppor.patc"; filename*1="h" >>From fd33ede1ca0b157ecf26711bdf12c2b15336e0cd Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Fri, 16 May 2008 13:24:59 +0400 Subject: [PATCH] Fixed inode lookup code (DFS related part) to support new build_path_from_dentry behaviour. Signed-off-by: Igor Mammedov --- fs/cifs/inode.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 9d9b56a..c7c5242 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -184,6 +184,9 @@ try_again_CIFSSMBUnixQPathInfo: if (rc) { if (rc == -EREMOTE && !is_dfs_referral) { is_dfs_referral = true; + full_path = strchr(full_path + 2, '/'); + full_path++; + full_path = strchr(full_path + 2, '/'); goto try_again_CIFSSMBUnixQPathInfo; } goto cgiiu_exit; @@ -230,6 +233,11 @@ try_again_CIFSSMBUnixQPathInfo: (unsigned long) inode->i_size, (unsigned long long)inode->i_blocks)); + if (is_dfs_referral && ((inode->i_mode & S_IFMT) == S_IFLNK)) { + inode->i_mode &= ~S_IFLNK; + inode->i_mode |= S_IFDIR; + } + cifs_set_ops(inode, is_dfs_referral); } cgiiu_exit: @@ -389,6 +397,9 @@ try_again_CIFSSMBQPathInfo: if (rc) { if (rc == -EREMOTE && !is_dfs_referral) { is_dfs_referral = true; + full_path = strchr(full_path + 2, '\\'); + full_path++; + full_path = strchr(full_path + 2, '\\'); goto try_again_CIFSSMBQPathInfo; } goto cgii_exit; -- 1.5.3.7 --------------050403030102000703020301--