CIFS: Make use of common cifs_build_path_to_root for CIFS and SMB2
authorSteve French <smfrench@gmail.com>
Thu, 29 Nov 2012 04:34:41 +0000 (22:34 -0600)
committerSteve French <smfrench@gmail.com>
Wed, 5 Dec 2012 19:27:28 +0000 (13:27 -0600)
because the is no difference here. This also adds support of prefixpath
mount option for SMB2.

Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/cifsfs.c
fs/cifs/cifsglob.h
fs/cifs/cifsproto.h
fs/cifs/connect.c
fs/cifs/dir.c
fs/cifs/smb1ops.c
fs/cifs/smb2ops.c

index 07a8ab527c3a2fd28d10a55d8b75104c7258618a..273b34904d5b8d62975fa574103518b39967f19a 100644 (file)
@@ -539,8 +539,8 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
        char *s, *p;
        char sep;
 
-       full_path = build_path_to_root(vol, cifs_sb,
-                                      cifs_sb_master_tcon(cifs_sb));
+       full_path = cifs_build_path_to_root(vol, cifs_sb,
+                                           cifs_sb_master_tcon(cifs_sb));
        if (full_path == NULL)
                return ERR_PTR(-ENOMEM);
 
index 2cd5ea2042edf16eed2d850d462dded67394757a..d1a93d32db81116119b4c2f5c419afff40c380d6 100644 (file)
@@ -280,9 +280,6 @@ struct smb_version_operations {
        /* set attributes */
        int (*set_file_info)(struct inode *, const char *, FILE_BASIC_INFO *,
                             const unsigned int);
-       /* build a full path to the root of the mount */
-       char * (*build_path_to_root)(struct smb_vol *, struct cifs_sb_info *,
-                                    struct cifs_tcon *);
        /* check if we can send an echo or nor */
        bool (*can_echo)(struct TCP_Server_Info *);
        /* send echo request */
@@ -1084,15 +1081,6 @@ convert_delimiter(char *path, char delim)
        }
 }
 
-static inline char *
-build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
-                  struct cifs_tcon *tcon)
-{
-       if (!vol->ops->build_path_to_root)
-               return NULL;
-       return vol->ops->build_path_to_root(vol, cifs_sb, tcon);
-}
-
 #ifdef CONFIG_CIFS_STATS
 #define cifs_stats_inc atomic_inc
 
index 5144e9fbeb8cc9d58682dac81b66da81a81a3329..7494358ba533f0127613b1d5935c213beb96095e 100644 (file)
@@ -60,6 +60,9 @@ extern int init_cifs_idmap(void);
 extern void exit_cifs_idmap(void);
 extern void cifs_destroy_idmaptrees(void);
 extern char *build_path_from_dentry(struct dentry *);
+extern char *cifs_build_path_to_root(struct smb_vol *vol,
+                                    struct cifs_sb_info *cifs_sb,
+                                    struct cifs_tcon *tcon);
 extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
 extern char *cifs_compose_mount_options(const char *sb_mountdata,
                const char *fullpath, const struct dfs_info3_param *ref,
index a48387265cd4e04a25bf036f4a459778413da285..5ce5686353f11d516f0c19939d8bf9bcf8d034db 100644 (file)
@@ -3261,8 +3261,10 @@ cifs_cleanup_volume_info(struct smb_vol *volume_info)
 
 
 #ifdef CONFIG_CIFS_DFS_UPCALL
-/* build_path_to_root returns full path to root when
- * we do not have an exiting connection (tcon) */
+/*
+ * cifs_build_path_to_root returns full path to root when we do not have an
+ * exiting connection (tcon)
+ */
 static char *
 build_unc_path_to_root(const struct smb_vol *vol,
                const struct cifs_sb_info *cifs_sb)
@@ -3518,8 +3520,10 @@ remote_path_check:
                        rc = -ENOSYS;
                        goto mount_fail_check;
                }
-               /* build_path_to_root works only when we have a valid tcon */
-               full_path = build_path_to_root(volume_info, cifs_sb, tcon);
+               /*
+                * cifs_build_path_to_root works only when we have a valid tcon
+                */
+               full_path = cifs_build_path_to_root(volume_info, cifs_sb, tcon);
                if (full_path == NULL) {
                        rc = -ENOMEM;
                        goto mount_fail_check;
index d3671f2acb29bd313779cf8022efe4c41e9987ef..3b7e0c1266f7d86805a740a9ad4f711c96c9b85a 100644 (file)
@@ -44,6 +44,37 @@ renew_parental_timestamps(struct dentry *direntry)
        } while (!IS_ROOT(direntry));
 }
 
+char *
+cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
+                       struct cifs_tcon *tcon)
+{
+       int pplen = vol->prepath ? strlen(vol->prepath) : 0;
+       int dfsplen;
+       char *full_path = NULL;
+
+       /* if no prefix path, simply set path to the root of share to "" */
+       if (pplen == 0) {
+               full_path = kzalloc(1, GFP_KERNEL);
+               return full_path;
+       }
+
+       if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
+               dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
+       else
+               dfsplen = 0;
+
+       full_path = kmalloc(dfsplen + pplen + 1, GFP_KERNEL);
+       if (full_path == NULL)
+               return full_path;
+
+       if (dfsplen)
+               strncpy(full_path, tcon->treeName, dfsplen);
+       strncpy(full_path + dfsplen, vol->prepath, pplen);
+       convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
+       full_path[dfsplen + pplen] = 0; /* add trailing null */
+       return full_path;
+}
+
 /* Note: caller must free return buffer */
 char *
 build_path_from_dentry(struct dentry *direntry)
index 34cea27983335fbf9dea43697cc8663ecf5aa091..a5d234c8d5d9295f41e947188ba020da68ec33dd 100644 (file)
@@ -575,37 +575,6 @@ cifs_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
        return CIFSSMBQFileInfo(xid, tcon, fid->netfid, data);
 }
 
-static char *
-cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
-                       struct cifs_tcon *tcon)
-{
-       int pplen = vol->prepath ? strlen(vol->prepath) : 0;
-       int dfsplen;
-       char *full_path = NULL;
-
-       /* if no prefix path, simply set path to the root of share to "" */
-       if (pplen == 0) {
-               full_path = kzalloc(1, GFP_KERNEL);
-               return full_path;
-       }
-
-       if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
-               dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
-       else
-               dfsplen = 0;
-
-       full_path = kmalloc(dfsplen + pplen + 1, GFP_KERNEL);
-       if (full_path == NULL)
-               return full_path;
-
-       if (dfsplen)
-               strncpy(full_path, tcon->treeName, dfsplen);
-       strncpy(full_path + dfsplen, vol->prepath, pplen);
-       convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
-       full_path[dfsplen + pplen] = 0; /* add trailing null */
-       return full_path;
-}
-
 static void
 cifs_clear_stats(struct cifs_tcon *tcon)
 {
@@ -943,7 +912,6 @@ struct smb_version_operations smb1_operations = {
        .set_path_size = CIFSSMBSetEOF,
        .set_file_size = CIFSSMBSetFileSize,
        .set_file_info = smb_set_file_info,
-       .build_path_to_root = cifs_build_path_to_root,
        .echo = CIFSSMBEcho,
        .mkdir = CIFSSMBMkDir,
        .mkdir_setinfo = cifs_mkdir_setinfo,
index 4d9dbe0b7385646f2db0dbc223ae83da60d14171..137aaf8d6f38e8c63d9c619009b1b0ab6b646584 100644 (file)
@@ -262,23 +262,6 @@ smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
        return rc;
 }
 
-static char *
-smb2_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
-                       struct cifs_tcon *tcon)
-{
-       int pplen = vol->prepath ? strlen(vol->prepath) : 0;
-       char *full_path = NULL;
-
-       /* if no prefix path, simply set path to the root of share to "" */
-       if (pplen == 0) {
-               full_path = kzalloc(2, GFP_KERNEL);
-               return full_path;
-       }
-
-       cERROR(1, "prefixpath is not supported for SMB2 now");
-       return NULL;
-}
-
 static bool
 smb2_can_echo(struct TCP_Server_Info *server)
 {
@@ -613,7 +596,6 @@ struct smb_version_operations smb21_operations = {
        .set_path_size = smb2_set_path_size,
        .set_file_size = smb2_set_file_size,
        .set_file_info = smb2_set_file_info,
-       .build_path_to_root = smb2_build_path_to_root,
        .mkdir = smb2_mkdir,
        .mkdir_setinfo = smb2_mkdir_setinfo,
        .rmdir = smb2_rmdir,