Commit b669f33ca61738171aecc5ae90d776d91b122eb8

Authored by Pavel Shilovsky
1 parent aa24d1e969

CIFS: Move getting dfs referalls to ops struct

Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>

Showing 5 changed files with 27 additions and 22 deletions Side-by-side Diff

... ... @@ -162,6 +162,7 @@
162 162 struct cifsFileInfo;
163 163 struct cifs_ses;
164 164 struct cifs_tcon;
  165 +struct dfs_info3_param;
165 166  
166 167 struct smb_version_operations {
167 168 int (*send_cancel)(struct TCP_Server_Info *, void *,
... ... @@ -208,6 +209,10 @@
208 209 struct cifs_tcon *, const struct nls_table *);
209 210 /* close tree connecion */
210 211 int (*tree_disconnect)(const unsigned int, struct cifs_tcon *);
  212 + /* get DFS referrals */
  213 + int (*get_dfs_refer)(const unsigned int, struct cifs_ses *,
  214 + const char *, struct dfs_info3_param **,
  215 + unsigned int *, const struct nls_table *, int);
211 216 };
212 217  
213 218 struct smb_version_values {
... ... @@ -226,17 +226,16 @@
226 226 const struct nls_table *nls_codepage, int remap);
227 227  
228 228 extern int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
229   - const unsigned char *searchName,
230   - struct dfs_info3_param **target_nodes,
231   - unsigned int *number_of_nodes_in_array,
232   - const struct nls_table *nls_codepage, int remap);
  229 + const char *search_name,
  230 + struct dfs_info3_param **target_nodes,
  231 + unsigned int *num_of_nodes,
  232 + const struct nls_table *nls_codepage, int remap);
233 233  
234   -extern int get_dfs_path(unsigned int xid, struct cifs_ses *pSesInfo,
  234 +extern int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
235 235 const char *old_path,
236 236 const struct nls_table *nls_codepage,
237   - unsigned int *pnum_referrals,
238   - struct dfs_info3_param **preferrals,
239   - int remap);
  237 + unsigned int *num_referrals,
  238 + struct dfs_info3_param **referrals, int remap);
240 239 extern void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
241 240 struct cifs_sb_info *cifs_sb,
242 241 struct smb_vol *vol);
... ... @@ -4766,8 +4766,7 @@
4766 4766  
4767 4767 int
4768 4768 CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
4769   - const unsigned char *searchName,
4770   - struct dfs_info3_param **target_nodes,
  4769 + const char *search_name, struct dfs_info3_param **target_nodes,
4771 4770 unsigned int *num_of_nodes,
4772 4771 const struct nls_table *nls_codepage, int remap)
4773 4772 {
... ... @@ -4781,7 +4780,7 @@
4781 4780 *num_of_nodes = 0;
4782 4781 *target_nodes = NULL;
4783 4782  
4784   - cFYI(1, "In GetDFSRefer the path %s", searchName);
  4783 + cFYI(1, "In GetDFSRefer the path %s", search_name);
4785 4784 if (ses == NULL)
4786 4785 return -ENODEV;
4787 4786 getDFSRetry:
4788 4787  
4789 4788  
... ... @@ -4804,14 +4803,14 @@
4804 4803 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
4805 4804 name_len =
4806 4805 cifsConvertToUTF16((__le16 *) pSMB->RequestFileName,
4807   - searchName, PATH_MAX, nls_codepage,
  4806 + search_name, PATH_MAX, nls_codepage,
4808 4807 remap);
4809 4808 name_len++; /* trailing null */
4810 4809 name_len *= 2;
4811 4810 } else { /* BB improve the check for buffer overruns BB */
4812   - name_len = strnlen(searchName, PATH_MAX);
  4811 + name_len = strnlen(search_name, PATH_MAX);
4813 4812 name_len++; /* trailing null */
4814   - strncpy(pSMB->RequestFileName, searchName, name_len);
  4813 + strncpy(pSMB->RequestFileName, search_name, name_len);
4815 4814 }
4816 4815  
4817 4816 if (ses->server) {
... ... @@ -4867,7 +4866,7 @@
4867 4866 /* parse returned result into more usable form */
4868 4867 rc = parse_DFS_referrals(pSMBr, num_of_nodes,
4869 4868 target_nodes, nls_codepage, remap,
4870   - searchName);
  4869 + search_name);
4871 4870  
4872 4871 GetDFSRefExit:
4873 4872 cifs_buf_release(pSMB);
... ... @@ -2767,14 +2767,14 @@
2767 2767 }
2768 2768  
2769 2769 int
2770   -get_dfs_path(unsigned int xid, struct cifs_ses *ses, const char *old_path,
  2770 +get_dfs_path(const unsigned int xid, struct cifs_ses *ses, const char *old_path,
2771 2771 const struct nls_table *nls_codepage, unsigned int *num_referrals,
2772 2772 struct dfs_info3_param **referrals, int remap)
2773 2773 {
2774 2774 char *temp_unc;
2775 2775 int rc = 0;
2776 2776  
2777   - if (!ses->server->ops->tree_connect)
  2777 + if (!ses->server->ops->tree_connect || !ses->server->ops->get_dfs_refer)
2778 2778 return -ENOSYS;
2779 2779  
2780 2780 *num_referrals = 0;
2781 2781  
... ... @@ -2796,11 +2796,12 @@
2796 2796 kfree(temp_unc);
2797 2797 }
2798 2798 if (rc == 0)
2799   - rc = CIFSGetDFSRefer(xid, ses, old_path, referrals,
2800   - num_referrals, nls_codepage, remap);
  2799 + rc = ses->server->ops->get_dfs_refer(xid, ses, old_path,
  2800 + referrals, num_referrals,
  2801 + nls_codepage, remap);
2801 2802 /*
2802 2803 * BB - map targetUNCs to dfs_info3 structures, here or in
2803   - * CIFSGetDFSRefer.
  2804 + * ses->server->ops->get_dfs_refer.
2804 2805 */
2805 2806  
2806 2807 return rc;
... ... @@ -3488,7 +3489,7 @@
3488 3489 * determine whether there were referrals.
3489 3490 */
3490 3491 static int
3491   -expand_dfs_referral(unsigned int xid, struct cifs_ses *pSesInfo,
  3492 +expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses,
3492 3493 struct smb_vol *volume_info, struct cifs_sb_info *cifs_sb,
3493 3494 int check_prefix)
3494 3495 {
... ... @@ -3504,7 +3505,7 @@
3504 3505 /* For DFS paths, skip the first '\' of the UNC */
3505 3506 ref_path = check_prefix ? full_path + 1 : volume_info->UNC + 1;
3506 3507  
3507   - rc = get_dfs_path(xid, pSesInfo , ref_path, cifs_sb->local_nls,
  3508 + rc = get_dfs_path(xid, ses, ref_path, cifs_sb->local_nls,
3508 3509 &num_referrals, &referrals,
3509 3510 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
3510 3511  
... ... @@ -434,6 +434,7 @@
434 434 .logoff = CIFSSMBLogoff,
435 435 .tree_connect = CIFSTCon,
436 436 .tree_disconnect = CIFSSMBTDis,
  437 + .get_dfs_refer = CIFSGetDFSRefer,
437 438 };
438 439  
439 440 struct smb_version_values smb1_values = {