aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteve French <smfrench@gmail.com>2012-11-28 23:34:41 -0500
committerSteve French <smfrench@gmail.com>2012-12-05 14:27:28 -0500
commit6d3ea7e4975aed451fbee4dea2fef63b0de8cb4f (patch)
tree499881d40ec894a38bf017328fb48ebbaa30ec1b /fs
parente5e69abd058b3fcfd484dbe1c632347332cda9b6 (diff)
CIFS: Make use of common cifs_build_path_to_root for CIFS and SMB2
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifsfs.c4
-rw-r--r--fs/cifs/cifsglob.h12
-rw-r--r--fs/cifs/cifsproto.h3
-rw-r--r--fs/cifs/connect.c12
-rw-r--r--fs/cifs/dir.c31
-rw-r--r--fs/cifs/smb1ops.c32
-rw-r--r--fs/cifs/smb2ops.c18
7 files changed, 44 insertions, 68 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 07a8ab527c3a..273b34904d5b 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -539,8 +539,8 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
539 char *s, *p; 539 char *s, *p;
540 char sep; 540 char sep;
541 541
542 full_path = build_path_to_root(vol, cifs_sb, 542 full_path = cifs_build_path_to_root(vol, cifs_sb,
543 cifs_sb_master_tcon(cifs_sb)); 543 cifs_sb_master_tcon(cifs_sb));
544 if (full_path == NULL) 544 if (full_path == NULL)
545 return ERR_PTR(-ENOMEM); 545 return ERR_PTR(-ENOMEM);
546 546
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 2cd5ea2042ed..d1a93d32db81 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -280,9 +280,6 @@ struct smb_version_operations {
280 /* set attributes */ 280 /* set attributes */
281 int (*set_file_info)(struct inode *, const char *, FILE_BASIC_INFO *, 281 int (*set_file_info)(struct inode *, const char *, FILE_BASIC_INFO *,
282 const unsigned int); 282 const unsigned int);
283 /* build a full path to the root of the mount */
284 char * (*build_path_to_root)(struct smb_vol *, struct cifs_sb_info *,
285 struct cifs_tcon *);
286 /* check if we can send an echo or nor */ 283 /* check if we can send an echo or nor */
287 bool (*can_echo)(struct TCP_Server_Info *); 284 bool (*can_echo)(struct TCP_Server_Info *);
288 /* send echo request */ 285 /* send echo request */
@@ -1084,15 +1081,6 @@ convert_delimiter(char *path, char delim)
1084 } 1081 }
1085} 1082}
1086 1083
1087static inline char *
1088build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
1089 struct cifs_tcon *tcon)
1090{
1091 if (!vol->ops->build_path_to_root)
1092 return NULL;
1093 return vol->ops->build_path_to_root(vol, cifs_sb, tcon);
1094}
1095
1096#ifdef CONFIG_CIFS_STATS 1084#ifdef CONFIG_CIFS_STATS
1097#define cifs_stats_inc atomic_inc 1085#define cifs_stats_inc atomic_inc
1098 1086
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 5144e9fbeb8c..7494358ba533 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -60,6 +60,9 @@ extern int init_cifs_idmap(void);
60extern void exit_cifs_idmap(void); 60extern void exit_cifs_idmap(void);
61extern void cifs_destroy_idmaptrees(void); 61extern void cifs_destroy_idmaptrees(void);
62extern char *build_path_from_dentry(struct dentry *); 62extern char *build_path_from_dentry(struct dentry *);
63extern char *cifs_build_path_to_root(struct smb_vol *vol,
64 struct cifs_sb_info *cifs_sb,
65 struct cifs_tcon *tcon);
63extern char *build_wildcard_path_from_dentry(struct dentry *direntry); 66extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
64extern char *cifs_compose_mount_options(const char *sb_mountdata, 67extern char *cifs_compose_mount_options(const char *sb_mountdata,
65 const char *fullpath, const struct dfs_info3_param *ref, 68 const char *fullpath, const struct dfs_info3_param *ref,
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index a48387265cd4..5ce5686353f1 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3261,8 +3261,10 @@ cifs_cleanup_volume_info(struct smb_vol *volume_info)
3261 3261
3262 3262
3263#ifdef CONFIG_CIFS_DFS_UPCALL 3263#ifdef CONFIG_CIFS_DFS_UPCALL
3264/* build_path_to_root returns full path to root when 3264/*
3265 * we do not have an exiting connection (tcon) */ 3265 * cifs_build_path_to_root returns full path to root when we do not have an
3266 * exiting connection (tcon)
3267 */
3266static char * 3268static char *
3267build_unc_path_to_root(const struct smb_vol *vol, 3269build_unc_path_to_root(const struct smb_vol *vol,
3268 const struct cifs_sb_info *cifs_sb) 3270 const struct cifs_sb_info *cifs_sb)
@@ -3518,8 +3520,10 @@ remote_path_check:
3518 rc = -ENOSYS; 3520 rc = -ENOSYS;
3519 goto mount_fail_check; 3521 goto mount_fail_check;
3520 } 3522 }
3521 /* build_path_to_root works only when we have a valid tcon */ 3523 /*
3522 full_path = build_path_to_root(volume_info, cifs_sb, tcon); 3524 * cifs_build_path_to_root works only when we have a valid tcon
3525 */
3526 full_path = cifs_build_path_to_root(volume_info, cifs_sb, tcon);
3523 if (full_path == NULL) { 3527 if (full_path == NULL) {
3524 rc = -ENOMEM; 3528 rc = -ENOMEM;
3525 goto mount_fail_check; 3529 goto mount_fail_check;
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index d3671f2acb29..3b7e0c1266f7 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -44,6 +44,37 @@ renew_parental_timestamps(struct dentry *direntry)
44 } while (!IS_ROOT(direntry)); 44 } while (!IS_ROOT(direntry));
45} 45}
46 46
47char *
48cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
49 struct cifs_tcon *tcon)
50{
51 int pplen = vol->prepath ? strlen(vol->prepath) : 0;
52 int dfsplen;
53 char *full_path = NULL;
54
55 /* if no prefix path, simply set path to the root of share to "" */
56 if (pplen == 0) {
57 full_path = kzalloc(1, GFP_KERNEL);
58 return full_path;
59 }
60
61 if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
62 dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
63 else
64 dfsplen = 0;
65
66 full_path = kmalloc(dfsplen + pplen + 1, GFP_KERNEL);
67 if (full_path == NULL)
68 return full_path;
69
70 if (dfsplen)
71 strncpy(full_path, tcon->treeName, dfsplen);
72 strncpy(full_path + dfsplen, vol->prepath, pplen);
73 convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
74 full_path[dfsplen + pplen] = 0; /* add trailing null */
75 return full_path;
76}
77
47/* Note: caller must free return buffer */ 78/* Note: caller must free return buffer */
48char * 79char *
49build_path_from_dentry(struct dentry *direntry) 80build_path_from_dentry(struct dentry *direntry)
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 34cea2798333..a5d234c8d5d9 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -575,37 +575,6 @@ cifs_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
575 return CIFSSMBQFileInfo(xid, tcon, fid->netfid, data); 575 return CIFSSMBQFileInfo(xid, tcon, fid->netfid, data);
576} 576}
577 577
578static char *
579cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
580 struct cifs_tcon *tcon)
581{
582 int pplen = vol->prepath ? strlen(vol->prepath) : 0;
583 int dfsplen;
584 char *full_path = NULL;
585
586 /* if no prefix path, simply set path to the root of share to "" */
587 if (pplen == 0) {
588 full_path = kzalloc(1, GFP_KERNEL);
589 return full_path;
590 }
591
592 if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
593 dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
594 else
595 dfsplen = 0;
596
597 full_path = kmalloc(dfsplen + pplen + 1, GFP_KERNEL);
598 if (full_path == NULL)
599 return full_path;
600
601 if (dfsplen)
602 strncpy(full_path, tcon->treeName, dfsplen);
603 strncpy(full_path + dfsplen, vol->prepath, pplen);
604 convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
605 full_path[dfsplen + pplen] = 0; /* add trailing null */
606 return full_path;
607}
608
609static void 578static void
610cifs_clear_stats(struct cifs_tcon *tcon) 579cifs_clear_stats(struct cifs_tcon *tcon)
611{ 580{
@@ -943,7 +912,6 @@ struct smb_version_operations smb1_operations = {
943 .set_path_size = CIFSSMBSetEOF, 912 .set_path_size = CIFSSMBSetEOF,
944 .set_file_size = CIFSSMBSetFileSize, 913 .set_file_size = CIFSSMBSetFileSize,
945 .set_file_info = smb_set_file_info, 914 .set_file_info = smb_set_file_info,
946 .build_path_to_root = cifs_build_path_to_root,
947 .echo = CIFSSMBEcho, 915 .echo = CIFSSMBEcho,
948 .mkdir = CIFSSMBMkDir, 916 .mkdir = CIFSSMBMkDir,
949 .mkdir_setinfo = cifs_mkdir_setinfo, 917 .mkdir_setinfo = cifs_mkdir_setinfo,
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 4d9dbe0b7385..137aaf8d6f38 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -262,23 +262,6 @@ smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
262 return rc; 262 return rc;
263} 263}
264 264
265static char *
266smb2_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
267 struct cifs_tcon *tcon)
268{
269 int pplen = vol->prepath ? strlen(vol->prepath) : 0;
270 char *full_path = NULL;
271
272 /* if no prefix path, simply set path to the root of share to "" */
273 if (pplen == 0) {
274 full_path = kzalloc(2, GFP_KERNEL);
275 return full_path;
276 }
277
278 cERROR(1, "prefixpath is not supported for SMB2 now");
279 return NULL;
280}
281
282static bool 265static bool
283smb2_can_echo(struct TCP_Server_Info *server) 266smb2_can_echo(struct TCP_Server_Info *server)
284{ 267{
@@ -613,7 +596,6 @@ struct smb_version_operations smb21_operations = {
613 .set_path_size = smb2_set_path_size, 596 .set_path_size = smb2_set_path_size,
614 .set_file_size = smb2_set_file_size, 597 .set_file_size = smb2_set_file_size,
615 .set_file_info = smb2_set_file_info, 598 .set_file_info = smb2_set_file_info,
616 .build_path_to_root = smb2_build_path_to_root,
617 .mkdir = smb2_mkdir, 599 .mkdir = smb2_mkdir,
618 .mkdir_setinfo = smb2_mkdir_setinfo, 600 .mkdir_setinfo = smb2_mkdir_setinfo,
619 .rmdir = smb2_rmdir, 601 .rmdir = smb2_rmdir,