[linux-cifs-client] [PATCH] cifs: handle DFS path_names that don't start with double backslash

Jeff Layton jlayton at redhat.com
Mon Dec 15 12:47:08 GMT 2008


Apparently some servers (notably, Samba 3.0.x) do not respond to DFS
referrals with a DFS path_name that begins with a double backslash. When
this occurs, the path_consumed sent is generally too short by 1
character. Fix this by checking whether the second character in the
path_name is a '\'. If not, then adjust path_consumed by 1 when
building the mount option string.

Tested against Samba 3.0.28-ish server and Win2k8.

Signed-off-by: Jeff Layton <jlayton at redhat.com>
---
 fs/cifs/cifs_dfs_ref.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index e1c1836..9185dfa 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -127,7 +127,7 @@ static char *compose_mount_options(const char *sb_mountdata,
 	char *tkn_e;
 	char *srvIP = NULL;
 	char sep = ',';
-	int off, noff;
+	int off, noff, path_consumed;
 	char *fullpath;
 
 	if (sb_mountdata == NULL)
@@ -200,14 +200,22 @@ static char *compose_mount_options(const char *sb_mountdata,
 	if (tkn_e == NULL) /* invalid unc, missing share name*/
 		goto compose_mount_options_out;
 
+	/*
+	 * Some servers do not send a path_name that starts with a double '\\'.
+	 * This means that path_consumed will be off by one.
+	 */
+	path_consumed = ref->path_consumed;
+	if (ref->path_name[1] != '\\')
+		path_consumed++;
+
 	fullpath = build_path_from_dentry(dentry);
 	tkn_e = strchr(tkn_e + 1, '\\');
-	if (tkn_e || strlen(fullpath) - (ref->path_consumed)) {
+	if (tkn_e || strlen(fullpath) - path_consumed) {
 		strncat(mountdata, &sep, 1);
 		strcat(mountdata, "prefixpath=");
 		if (tkn_e)
 			strcat(mountdata, tkn_e + 1);
-		strcat(mountdata, fullpath + (ref->path_consumed));
+		strcat(mountdata, fullpath + path_consumed);
 	}
 	kfree(fullpath);
 
-- 
1.5.5.1



More information about the linux-cifs-client mailing list