]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
CIFS: add build_path_from_dentry_optional_prefix()
authorAurelien Aptel <aaptel@suse.com>
Mon, 13 Feb 2017 15:14:17 +0000 (16:14 +0100)
committerSteve French <smfrench@gmail.com>
Thu, 2 Mar 2017 04:26:10 +0000 (22:26 -0600)
this function does the same thing as add build_path_from_dentry() but
takes a boolean parameter to decide whether or not to prefix the path
with the tree name.

we cannot rely on tcon->Flags & SMB_SHARE_IS_IN_DFS for SMB2 as smb2
code never sets tcon->Flags but it sets tcon->share_flags and it seems
the SMB_SHARE_IS_IN_DFS has different semantics in SMB2: the prefix
shouldn't be added everytime it was in SMB1.

Signed-off-by: Aurelien Aptel <aaptel@suse.com>
Acked-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/cifs_dfs_ref.c
fs/cifs/cifsproto.h
fs/cifs/dir.c

index 9156be545b0f103703c70462a219da06d2bf44bf..6b61df117fd48c456f30275053187ffd720d46e1 100644 (file)
@@ -303,7 +303,9 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
         * gives us the latter, so we must adjust the result.
         */
        mnt = ERR_PTR(-ENOMEM);
-       full_path = build_path_from_dentry(mntpt);
+
+       /* always use tree name prefix */
+       full_path = build_path_from_dentry_optional_prefix(mntpt, true);
        if (full_path == NULL)
                goto cdda_exit;
 
index c0978304528841138a2e5fda886bd666b03bacff..9ee46c1c3ebda325cc243d6dbeb54953bfd96352 100644 (file)
@@ -61,6 +61,8 @@ extern void exit_cifs_idmap(void);
 extern int init_cifs_spnego(void);
 extern void exit_cifs_spnego(void);
 extern char *build_path_from_dentry(struct dentry *);
+extern char *build_path_from_dentry_optional_prefix(struct dentry *direntry,
+                                                   bool prefix);
 extern char *cifs_build_path_to_root(struct smb_vol *vol,
                                     struct cifs_sb_info *cifs_sb,
                                     struct cifs_tcon *tcon,
index 2c227a99f369f08e8941652eb87dd685a6f66b61..56366e9840769dd8a45250ec3a7b65097c979ff9 100644 (file)
@@ -80,6 +80,17 @@ cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
 /* Note: caller must free return buffer */
 char *
 build_path_from_dentry(struct dentry *direntry)
+{
+       struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
+       struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
+       bool prefix = tcon->Flags & SMB_SHARE_IS_IN_DFS;
+
+       return build_path_from_dentry_optional_prefix(direntry,
+                                                     prefix);
+}
+
+char *
+build_path_from_dentry_optional_prefix(struct dentry *direntry, bool prefix)
 {
        struct dentry *temp;
        int namelen;
@@ -92,7 +103,7 @@ build_path_from_dentry(struct dentry *direntry)
        unsigned seq;
 
        dirsep = CIFS_DIR_SEP(cifs_sb);
-       if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
+       if (prefix)
                dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
        else
                dfsplen = 0;