aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-05-27 12:39:52 -0400
committerPavel Shilovsky <pshilovsky@samba.org>2012-07-24 13:55:10 -0400
commit9224dfc2f92f4faff7b3d9e169255278129b47e8 (patch)
tree43a5736568aaf772a1612d15d55781d33a643fd5 /fs/cifs
parentbe4cb9e3d4ef7af1aaf66cebab1391ff91b48beb (diff)
CIFS: Move building path to root to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsfs.c4
-rw-r--r--fs/cifs/cifsglob.h13
-rw-r--r--fs/cifs/cifsproto.h3
-rw-r--r--fs/cifs/connect.c2
-rw-r--r--fs/cifs/inode.c32
-rw-r--r--fs/cifs/smb1ops.c32
6 files changed, 48 insertions, 38 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 7a7cda9f7912..db8a404a51dd 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -549,8 +549,8 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
549 char *s, *p; 549 char *s, *p;
550 char sep; 550 char sep;
551 551
552 full_path = cifs_build_path_to_root(vol, cifs_sb, 552 full_path = build_path_to_root(vol, cifs_sb,
553 cifs_sb_master_tcon(cifs_sb)); 553 cifs_sb_master_tcon(cifs_sb));
554 if (full_path == NULL) 554 if (full_path == NULL)
555 return ERR_PTR(-ENOMEM); 555 return ERR_PTR(-ENOMEM);
556 556
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 2b1234599e72..340dce0ed07b 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -164,6 +164,7 @@ struct cifs_ses;
164struct cifs_tcon; 164struct cifs_tcon;
165struct dfs_info3_param; 165struct dfs_info3_param;
166struct cifs_fattr; 166struct cifs_fattr;
167struct smb_vol;
167 168
168struct smb_version_operations { 169struct smb_version_operations {
169 int (*send_cancel)(struct TCP_Server_Info *, void *, 170 int (*send_cancel)(struct TCP_Server_Info *, void *,
@@ -227,6 +228,9 @@ struct smb_version_operations {
227 int (*get_srv_inum)(const unsigned int, struct cifs_tcon *, 228 int (*get_srv_inum)(const unsigned int, struct cifs_tcon *,
228 struct cifs_sb_info *, const char *, 229 struct cifs_sb_info *, const char *,
229 u64 *uniqueid, FILE_ALL_INFO *); 230 u64 *uniqueid, FILE_ALL_INFO *);
231 /* build a full path to the root of the mount */
232 char * (*build_path_to_root)(struct smb_vol *, struct cifs_sb_info *,
233 struct cifs_tcon *);
230}; 234};
231 235
232struct smb_version_values { 236struct smb_version_values {
@@ -803,6 +807,15 @@ convert_delimiter(char *path, char delim)
803 } 807 }
804} 808}
805 809
810static inline char *
811build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
812 struct cifs_tcon *tcon)
813{
814 if (!vol->ops->build_path_to_root)
815 return NULL;
816 return vol->ops->build_path_to_root(vol, cifs_sb, tcon);
817}
818
806#ifdef CONFIG_CIFS_STATS 819#ifdef CONFIG_CIFS_STATS
807#define cifs_stats_inc atomic_inc 820#define cifs_stats_inc atomic_inc
808 821
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 8e93de01c79d..334b867a81ff 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -57,9 +57,6 @@ extern int init_cifs_idmap(void);
57extern void exit_cifs_idmap(void); 57extern void exit_cifs_idmap(void);
58extern void cifs_destroy_idmaptrees(void); 58extern void cifs_destroy_idmaptrees(void);
59extern char *build_path_from_dentry(struct dentry *); 59extern char *build_path_from_dentry(struct dentry *);
60extern char *cifs_build_path_to_root(struct smb_vol *vol,
61 struct cifs_sb_info *cifs_sb,
62 struct cifs_tcon *tcon);
63extern char *build_wildcard_path_from_dentry(struct dentry *direntry); 60extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
64extern char *cifs_compose_mount_options(const char *sb_mountdata, 61extern char *cifs_compose_mount_options(const char *sb_mountdata,
65 const char *fullpath, const struct dfs_info3_param *ref, 62 const char *fullpath, const struct dfs_info3_param *ref,
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 34588fe11c57..7b4bc1e0b08e 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3684,7 +3684,7 @@ remote_path_check:
3684 goto mount_fail_check; 3684 goto mount_fail_check;
3685 } 3685 }
3686 /* build_path_to_root works only when we have a valid tcon */ 3686 /* build_path_to_root works only when we have a valid tcon */
3687 full_path = cifs_build_path_to_root(volume_info, cifs_sb, tcon); 3687 full_path = build_path_to_root(volume_info, cifs_sb, tcon);
3688 if (full_path == NULL) { 3688 if (full_path == NULL) {
3689 rc = -ENOMEM; 3689 rc = -ENOMEM;
3690 goto mount_fail_check; 3690 goto mount_fail_check;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index df071fb2567f..def10064fe9d 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -731,38 +731,6 @@ static const struct inode_operations cifs_ipc_inode_ops = {
731 .lookup = cifs_lookup, 731 .lookup = cifs_lookup,
732}; 732};
733 733
734char *cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
735 struct cifs_tcon *tcon)
736{
737 int pplen = vol->prepath ? strlen(vol->prepath) : 0;
738 int dfsplen;
739 char *full_path = NULL;
740
741 /* if no prefix path, simply set path to the root of share to "" */
742 if (pplen == 0) {
743 full_path = kmalloc(1, GFP_KERNEL);
744 if (full_path)
745 full_path[0] = 0;
746 return full_path;
747 }
748
749 if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
750 dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
751 else
752 dfsplen = 0;
753
754 full_path = kmalloc(dfsplen + pplen + 1, GFP_KERNEL);
755 if (full_path == NULL)
756 return full_path;
757
758 if (dfsplen)
759 strncpy(full_path, tcon->treeName, dfsplen);
760 strncpy(full_path + dfsplen, vol->prepath, pplen);
761 convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
762 full_path[dfsplen + pplen] = 0; /* add trailing null */
763 return full_path;
764}
765
766static int 734static int
767cifs_find_inode(struct inode *inode, void *opaque) 735cifs_find_inode(struct inode *inode, void *opaque)
768{ 736{
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index fa210010358d..7195fadf1cfa 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -489,6 +489,37 @@ cifs_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
489 CIFS_MOUNT_MAP_SPECIAL_CHR); 489 CIFS_MOUNT_MAP_SPECIAL_CHR);
490} 490}
491 491
492static char *
493cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
494 struct cifs_tcon *tcon)
495{
496 int pplen = vol->prepath ? strlen(vol->prepath) : 0;
497 int dfsplen;
498 char *full_path = NULL;
499
500 /* if no prefix path, simply set path to the root of share to "" */
501 if (pplen == 0) {
502 full_path = kzalloc(1, GFP_KERNEL);
503 return full_path;
504 }
505
506 if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
507 dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
508 else
509 dfsplen = 0;
510
511 full_path = kmalloc(dfsplen + pplen + 1, GFP_KERNEL);
512 if (full_path == NULL)
513 return full_path;
514
515 if (dfsplen)
516 strncpy(full_path, tcon->treeName, dfsplen);
517 strncpy(full_path + dfsplen, vol->prepath, pplen);
518 convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
519 full_path[dfsplen + pplen] = 0; /* add trailing null */
520 return full_path;
521}
522
492struct smb_version_operations smb1_operations = { 523struct smb_version_operations smb1_operations = {
493 .send_cancel = send_nt_cancel, 524 .send_cancel = send_nt_cancel,
494 .compare_fids = cifs_compare_fids, 525 .compare_fids = cifs_compare_fids,
@@ -518,6 +549,7 @@ struct smb_version_operations smb1_operations = {
518 .is_path_accessible = cifs_is_path_accessible, 549 .is_path_accessible = cifs_is_path_accessible,
519 .query_path_info = cifs_query_path_info, 550 .query_path_info = cifs_query_path_info,
520 .get_srv_inum = cifs_get_srv_inum, 551 .get_srv_inum = cifs_get_srv_inum,
552 .build_path_to_root = cifs_build_path_to_root,
521}; 553};
522 554
523struct smb_version_values smb1_values = { 555struct smb_version_values smb1_values = {