diff options
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r-- | fs/cifs/cifssmb.c | 436 |
1 files changed, 264 insertions, 172 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index df6a619a6821..741ff0c69f37 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -75,7 +75,8 @@ static void mark_open_files_invalid(struct cifsTconInfo * pTcon) | |||
75 | } | 75 | } |
76 | } | 76 | } |
77 | write_unlock(&GlobalSMBSeslock); | 77 | write_unlock(&GlobalSMBSeslock); |
78 | /* BB Add call to invalidate_inodes(sb) for all superblocks mounted to this tcon */ | 78 | /* BB Add call to invalidate_inodes(sb) for all superblocks mounted |
79 | to this tcon */ | ||
79 | } | 80 | } |
80 | 81 | ||
81 | /* If the return code is zero, this function must fill in request_buf pointer */ | 82 | /* If the return code is zero, this function must fill in request_buf pointer */ |
@@ -89,11 +90,12 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
89 | check for tcp and smb session status done differently | 90 | check for tcp and smb session status done differently |
90 | for those three - in the calling routine */ | 91 | for those three - in the calling routine */ |
91 | if(tcon) { | 92 | if(tcon) { |
92 | if((tcon->ses) && (tcon->ses->server)){ | 93 | if((tcon->ses) && (tcon->ses->status != CifsExiting) && |
94 | (tcon->ses->server)){ | ||
93 | struct nls_table *nls_codepage; | 95 | struct nls_table *nls_codepage; |
94 | /* Give Demultiplex thread up to 10 seconds to | 96 | /* Give Demultiplex thread up to 10 seconds to |
95 | reconnect, should be greater than cifs socket | 97 | reconnect, should be greater than cifs socket |
96 | timeout which is 7 seconds */ | 98 | timeout which is 7 seconds */ |
97 | while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { | 99 | while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { |
98 | wait_event_interruptible_timeout(tcon->ses->server->response_q, | 100 | wait_event_interruptible_timeout(tcon->ses->server->response_q, |
99 | (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); | 101 | (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); |
@@ -103,8 +105,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
103 | (tcon->ses->status == CifsExiting)) { | 105 | (tcon->ses->status == CifsExiting)) { |
104 | cFYI(1,("gave up waiting on reconnect in smb_init")); | 106 | cFYI(1,("gave up waiting on reconnect in smb_init")); |
105 | return -EHOSTDOWN; | 107 | return -EHOSTDOWN; |
106 | } /* else "hard" mount - keep retrying until | 108 | } /* else "hard" mount - keep retrying |
107 | process is killed or server comes back up */ | 109 | until process is killed or server |
110 | comes back on-line */ | ||
108 | } else /* TCP session is reestablished now */ | 111 | } else /* TCP session is reestablished now */ |
109 | break; | 112 | break; |
110 | 113 | ||
@@ -115,23 +118,24 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
115 | simultaneously reconnect the same SMB session */ | 118 | simultaneously reconnect the same SMB session */ |
116 | down(&tcon->ses->sesSem); | 119 | down(&tcon->ses->sesSem); |
117 | if(tcon->ses->status == CifsNeedReconnect) | 120 | if(tcon->ses->status == CifsNeedReconnect) |
118 | rc = cifs_setup_session(0, tcon->ses, nls_codepage); | 121 | rc = cifs_setup_session(0, tcon->ses, |
122 | nls_codepage); | ||
119 | if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { | 123 | if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { |
120 | mark_open_files_invalid(tcon); | 124 | mark_open_files_invalid(tcon); |
121 | rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon, | 125 | rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon |
122 | nls_codepage); | 126 | , nls_codepage); |
123 | up(&tcon->ses->sesSem); | 127 | up(&tcon->ses->sesSem); |
124 | if(rc == 0) | 128 | if(rc == 0) |
125 | atomic_inc(&tconInfoReconnectCount); | 129 | atomic_inc(&tconInfoReconnectCount); |
126 | 130 | ||
127 | cFYI(1, ("reconnect tcon rc = %d", rc)); | 131 | cFYI(1, ("reconnect tcon rc = %d", rc)); |
128 | /* Removed call to reopen open files here - | 132 | /* Removed call to reopen open files here - |
129 | it is safer (and faster) to reopen files | 133 | it is safer (and faster) to reopen files |
130 | one at a time as needed in read and write */ | 134 | one at a time as needed in read and write */ |
131 | 135 | ||
132 | /* Check if handle based operation so we | 136 | /* Check if handle based operation so we |
133 | know whether we can continue or not without | 137 | know whether we can continue or not without |
134 | returning to caller to reset file handle */ | 138 | returning to caller to reset file handle */ |
135 | switch(smb_command) { | 139 | switch(smb_command) { |
136 | case SMB_COM_READ_ANDX: | 140 | case SMB_COM_READ_ANDX: |
137 | case SMB_COM_WRITE_ANDX: | 141 | case SMB_COM_WRITE_ANDX: |
@@ -182,22 +186,25 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
182 | check for tcp and smb session status done differently | 186 | check for tcp and smb session status done differently |
183 | for those three - in the calling routine */ | 187 | for those three - in the calling routine */ |
184 | if(tcon) { | 188 | if(tcon) { |
185 | if((tcon->ses) && (tcon->ses->server)){ | 189 | if((tcon->ses) && (tcon->ses->status != CifsExiting) && |
190 | (tcon->ses->server)){ | ||
186 | struct nls_table *nls_codepage; | 191 | struct nls_table *nls_codepage; |
187 | /* Give Demultiplex thread up to 10 seconds to | 192 | /* Give Demultiplex thread up to 10 seconds to |
188 | reconnect, should be greater than cifs socket | 193 | reconnect, should be greater than cifs socket |
189 | timeout which is 7 seconds */ | 194 | timeout which is 7 seconds */ |
190 | while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { | 195 | while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { |
191 | wait_event_interruptible_timeout(tcon->ses->server->response_q, | 196 | wait_event_interruptible_timeout(tcon->ses->server->response_q, |
192 | (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); | 197 | (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); |
193 | if(tcon->ses->server->tcpStatus == CifsNeedReconnect) { | 198 | if(tcon->ses->server->tcpStatus == |
199 | CifsNeedReconnect) { | ||
194 | /* on "soft" mounts we wait once */ | 200 | /* on "soft" mounts we wait once */ |
195 | if((tcon->retry == FALSE) || | 201 | if((tcon->retry == FALSE) || |
196 | (tcon->ses->status == CifsExiting)) { | 202 | (tcon->ses->status == CifsExiting)) { |
197 | cFYI(1,("gave up waiting on reconnect in smb_init")); | 203 | cFYI(1,("gave up waiting on reconnect in smb_init")); |
198 | return -EHOSTDOWN; | 204 | return -EHOSTDOWN; |
199 | } /* else "hard" mount - keep retrying until | 205 | } /* else "hard" mount - keep retrying |
200 | process is killed or server comes back up */ | 206 | until process is killed or server |
207 | comes on-line */ | ||
201 | } else /* TCP session is reestablished now */ | 208 | } else /* TCP session is reestablished now */ |
202 | break; | 209 | break; |
203 | 210 | ||
@@ -208,23 +215,24 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
208 | simultaneously reconnect the same SMB session */ | 215 | simultaneously reconnect the same SMB session */ |
209 | down(&tcon->ses->sesSem); | 216 | down(&tcon->ses->sesSem); |
210 | if(tcon->ses->status == CifsNeedReconnect) | 217 | if(tcon->ses->status == CifsNeedReconnect) |
211 | rc = cifs_setup_session(0, tcon->ses, nls_codepage); | 218 | rc = cifs_setup_session(0, tcon->ses, |
219 | nls_codepage); | ||
212 | if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { | 220 | if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { |
213 | mark_open_files_invalid(tcon); | 221 | mark_open_files_invalid(tcon); |
214 | rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon, | 222 | rc = CIFSTCon(0, tcon->ses, tcon->treeName, |
215 | nls_codepage); | 223 | tcon, nls_codepage); |
216 | up(&tcon->ses->sesSem); | 224 | up(&tcon->ses->sesSem); |
217 | if(rc == 0) | 225 | if(rc == 0) |
218 | atomic_inc(&tconInfoReconnectCount); | 226 | atomic_inc(&tconInfoReconnectCount); |
219 | 227 | ||
220 | cFYI(1, ("reconnect tcon rc = %d", rc)); | 228 | cFYI(1, ("reconnect tcon rc = %d", rc)); |
221 | /* Removed call to reopen open files here - | 229 | /* Removed call to reopen open files here - |
222 | it is safer (and faster) to reopen files | 230 | it is safer (and faster) to reopen files |
223 | one at a time as needed in read and write */ | 231 | one at a time as needed in read and write */ |
224 | 232 | ||
225 | /* Check if handle based operation so we | 233 | /* Check if handle based operation so we |
226 | know whether we can continue or not without | 234 | know whether we can continue or not without |
227 | returning to caller to reset file handle */ | 235 | returning to caller to reset file handle */ |
228 | switch(smb_command) { | 236 | switch(smb_command) { |
229 | case SMB_COM_READ_ANDX: | 237 | case SMB_COM_READ_ANDX: |
230 | case SMB_COM_WRITE_ANDX: | 238 | case SMB_COM_WRITE_ANDX: |
@@ -286,7 +294,8 @@ static int validate_t2(struct smb_t2_rsp * pSMB) | |||
286 | if(total_size < 512) { | 294 | if(total_size < 512) { |
287 | total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount); | 295 | total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount); |
288 | /* BCC le converted in SendReceive */ | 296 | /* BCC le converted in SendReceive */ |
289 | pBCC = (pSMB->hdr.WordCount * 2) + sizeof(struct smb_hdr) + | 297 | pBCC = (pSMB->hdr.WordCount * 2) + |
298 | sizeof(struct smb_hdr) + | ||
290 | (char *)pSMB; | 299 | (char *)pSMB; |
291 | if((total_size <= (*(u16 *)pBCC)) && | 300 | if((total_size <= (*(u16 *)pBCC)) && |
292 | (total_size < | 301 | (total_size < |
@@ -337,8 +346,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) | |||
337 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 346 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
338 | if (rc == 0) { | 347 | if (rc == 0) { |
339 | server->secMode = pSMBr->SecurityMode; | 348 | server->secMode = pSMBr->SecurityMode; |
340 | server->secType = NTLM; /* BB override default for NTLMv2 or krb*/ | 349 | server->secType = NTLM; /* BB override default for |
341 | /* one byte - no need to convert this or EncryptionKeyLen from le,*/ | 350 | NTLMv2 or kerberos v5 */ |
351 | /* one byte - no need to convert this or EncryptionKeyLen | ||
352 | from little endian */ | ||
342 | server->maxReq = le16_to_cpu(pSMBr->MaxMpxCount); | 353 | server->maxReq = le16_to_cpu(pSMBr->MaxMpxCount); |
343 | /* probably no need to store and check maxvcs */ | 354 | /* probably no need to store and check maxvcs */ |
344 | server->maxBuf = | 355 | server->maxBuf = |
@@ -374,7 +385,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) | |||
374 | pSMBr->u.extended_response. | 385 | pSMBr->u.extended_response. |
375 | GUID, 16) != 0) { | 386 | GUID, 16) != 0) { |
376 | cFYI(1, | 387 | cFYI(1, |
377 | ("UID of server does not match previous connection to same ip address")); | 388 | ("UID of server does not match previous connection to same ip address")); |
378 | memcpy(server-> | 389 | memcpy(server-> |
379 | server_GUID, | 390 | server_GUID, |
380 | pSMBr->u. | 391 | pSMBr->u. |
@@ -454,17 +465,18 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon) | |||
454 | up(&tcon->tconSem); | 465 | up(&tcon->tconSem); |
455 | return -EIO; | 466 | return -EIO; |
456 | } | 467 | } |
457 | rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, (void **)&smb_buffer); | 468 | rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, |
469 | (void **)&smb_buffer); | ||
458 | if (rc) { | 470 | if (rc) { |
459 | up(&tcon->tconSem); | 471 | up(&tcon->tconSem); |
460 | return rc; | 472 | return rc; |
461 | } else { | 473 | } else { |
462 | smb_buffer_response = smb_buffer; /* BB removeme BB */ | 474 | smb_buffer_response = smb_buffer; /* BB removeme BB */ |
463 | } | 475 | } |
464 | rc = SendReceive(xid, tcon->ses, smb_buffer, smb_buffer_response, | 476 | rc = SendReceive(xid, tcon->ses, smb_buffer, smb_buffer_response, |
465 | &length, 0); | 477 | &length, 0); |
466 | if (rc) | 478 | if (rc) |
467 | cFYI(1, (" Tree disconnect failed %d", rc)); | 479 | cFYI(1, ("Tree disconnect failed %d", rc)); |
468 | 480 | ||
469 | if (smb_buffer) | 481 | if (smb_buffer) |
470 | cifs_small_buf_release(smb_buffer); | 482 | cifs_small_buf_release(smb_buffer); |
@@ -538,8 +550,8 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses) | |||
538 | } | 550 | } |
539 | 551 | ||
540 | int | 552 | int |
541 | CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, | 553 | CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName, |
542 | const char *fileName, const struct nls_table *nls_codepage) | 554 | const struct nls_table *nls_codepage, int remap) |
543 | { | 555 | { |
544 | DELETE_FILE_REQ *pSMB = NULL; | 556 | DELETE_FILE_REQ *pSMB = NULL; |
545 | DELETE_FILE_RSP *pSMBr = NULL; | 557 | DELETE_FILE_RSP *pSMBr = NULL; |
@@ -555,12 +567,11 @@ DelFileRetry: | |||
555 | 567 | ||
556 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 568 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
557 | name_len = | 569 | name_len = |
558 | cifs_strtoUCS((wchar_t *) pSMB->fileName, fileName, PATH_MAX | 570 | cifsConvertToUCS((__u16 *) pSMB->fileName, fileName, |
559 | /* find define for this maxpathcomponent */ | 571 | PATH_MAX, nls_codepage, remap); |
560 | , nls_codepage); | ||
561 | name_len++; /* trailing null */ | 572 | name_len++; /* trailing null */ |
562 | name_len *= 2; | 573 | name_len *= 2; |
563 | } else { /* BB improve the check for buffer overruns BB */ | 574 | } else { /* BB improve check for buffer overruns BB */ |
564 | name_len = strnlen(fileName, PATH_MAX); | 575 | name_len = strnlen(fileName, PATH_MAX); |
565 | name_len++; /* trailing null */ | 576 | name_len++; /* trailing null */ |
566 | strncpy(pSMB->fileName, fileName, name_len); | 577 | strncpy(pSMB->fileName, fileName, name_len); |
@@ -589,8 +600,8 @@ DelFileRetry: | |||
589 | } | 600 | } |
590 | 601 | ||
591 | int | 602 | int |
592 | CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, | 603 | CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, const char *dirName, |
593 | const char *dirName, const struct nls_table *nls_codepage) | 604 | const struct nls_table *nls_codepage, int remap) |
594 | { | 605 | { |
595 | DELETE_DIRECTORY_REQ *pSMB = NULL; | 606 | DELETE_DIRECTORY_REQ *pSMB = NULL; |
596 | DELETE_DIRECTORY_RSP *pSMBr = NULL; | 607 | DELETE_DIRECTORY_RSP *pSMBr = NULL; |
@@ -606,12 +617,11 @@ RmDirRetry: | |||
606 | return rc; | 617 | return rc; |
607 | 618 | ||
608 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 619 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
609 | name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, dirName, PATH_MAX | 620 | name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, dirName, |
610 | /* find define for this maxpathcomponent */ | 621 | PATH_MAX, nls_codepage, remap); |
611 | , nls_codepage); | ||
612 | name_len++; /* trailing null */ | 622 | name_len++; /* trailing null */ |
613 | name_len *= 2; | 623 | name_len *= 2; |
614 | } else { /* BB improve the check for buffer overruns BB */ | 624 | } else { /* BB improve check for buffer overruns BB */ |
615 | name_len = strnlen(dirName, PATH_MAX); | 625 | name_len = strnlen(dirName, PATH_MAX); |
616 | name_len++; /* trailing null */ | 626 | name_len++; /* trailing null */ |
617 | strncpy(pSMB->DirName, dirName, name_len); | 627 | strncpy(pSMB->DirName, dirName, name_len); |
@@ -639,7 +649,7 @@ RmDirRetry: | |||
639 | 649 | ||
640 | int | 650 | int |
641 | CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, | 651 | CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, |
642 | const char *name, const struct nls_table *nls_codepage) | 652 | const char *name, const struct nls_table *nls_codepage, int remap) |
643 | { | 653 | { |
644 | int rc = 0; | 654 | int rc = 0; |
645 | CREATE_DIRECTORY_REQ *pSMB = NULL; | 655 | CREATE_DIRECTORY_REQ *pSMB = NULL; |
@@ -655,12 +665,11 @@ MkDirRetry: | |||
655 | return rc; | 665 | return rc; |
656 | 666 | ||
657 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 667 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
658 | name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, name, PATH_MAX | 668 | name_len = cifsConvertToUCS((__u16 *) pSMB->DirName, name, |
659 | /* find define for this maxpathcomponent */ | 669 | PATH_MAX, nls_codepage, remap); |
660 | , nls_codepage); | ||
661 | name_len++; /* trailing null */ | 670 | name_len++; /* trailing null */ |
662 | name_len *= 2; | 671 | name_len *= 2; |
663 | } else { /* BB improve the check for buffer overruns BB */ | 672 | } else { /* BB improve check for buffer overruns BB */ |
664 | name_len = strnlen(name, PATH_MAX); | 673 | name_len = strnlen(name, PATH_MAX); |
665 | name_len++; /* trailing null */ | 674 | name_len++; /* trailing null */ |
666 | strncpy(pSMB->DirName, name, name_len); | 675 | strncpy(pSMB->DirName, name, name_len); |
@@ -690,7 +699,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, | |||
690 | const char *fileName, const int openDisposition, | 699 | const char *fileName, const int openDisposition, |
691 | const int access_flags, const int create_options, __u16 * netfid, | 700 | const int access_flags, const int create_options, __u16 * netfid, |
692 | int *pOplock, FILE_ALL_INFO * pfile_info, | 701 | int *pOplock, FILE_ALL_INFO * pfile_info, |
693 | const struct nls_table *nls_codepage) | 702 | const struct nls_table *nls_codepage, int remap) |
694 | { | 703 | { |
695 | int rc = -EACCES; | 704 | int rc = -EACCES; |
696 | OPEN_REQ *pSMB = NULL; | 705 | OPEN_REQ *pSMB = NULL; |
@@ -710,14 +719,12 @@ openRetry: | |||
710 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 719 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
711 | count = 1; /* account for one byte pad to word boundary */ | 720 | count = 1; /* account for one byte pad to word boundary */ |
712 | name_len = | 721 | name_len = |
713 | cifs_strtoUCS((wchar_t *) (pSMB->fileName + 1), | 722 | cifsConvertToUCS((__u16 *) (pSMB->fileName + 1), |
714 | fileName, PATH_MAX | 723 | fileName, PATH_MAX, nls_codepage, remap); |
715 | /* find define for this maxpathcomponent */ | ||
716 | , nls_codepage); | ||
717 | name_len++; /* trailing null */ | 724 | name_len++; /* trailing null */ |
718 | name_len *= 2; | 725 | name_len *= 2; |
719 | pSMB->NameLength = cpu_to_le16(name_len); | 726 | pSMB->NameLength = cpu_to_le16(name_len); |
720 | } else { /* BB improve the check for buffer overruns BB */ | 727 | } else { /* BB improve check for buffer overruns BB */ |
721 | count = 0; /* no pad */ | 728 | count = 0; /* no pad */ |
722 | name_len = strnlen(fileName, PATH_MAX); | 729 | name_len = strnlen(fileName, PATH_MAX); |
723 | name_len++; /* trailing null */ | 730 | name_len++; /* trailing null */ |
@@ -746,7 +753,8 @@ openRetry: | |||
746 | pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL); | 753 | pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL); |
747 | pSMB->CreateDisposition = cpu_to_le32(openDisposition); | 754 | pSMB->CreateDisposition = cpu_to_le32(openDisposition); |
748 | pSMB->CreateOptions = cpu_to_le32(create_options); | 755 | pSMB->CreateOptions = cpu_to_le32(create_options); |
749 | pSMB->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION); /* BB ??*/ | 756 | /* BB Expirement with various impersonation levels and verify */ |
757 | pSMB->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION); | ||
750 | pSMB->SecurityFlags = | 758 | pSMB->SecurityFlags = |
751 | SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY; | 759 | SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY; |
752 | 760 | ||
@@ -760,7 +768,7 @@ openRetry: | |||
760 | if (rc) { | 768 | if (rc) { |
761 | cFYI(1, ("Error in Open = %d", rc)); | 769 | cFYI(1, ("Error in Open = %d", rc)); |
762 | } else { | 770 | } else { |
763 | *pOplock = pSMBr->OplockLevel; /* one byte no need to le_to_cpu */ | 771 | *pOplock = pSMBr->OplockLevel; /* 1 byte no need to le_to_cpu */ |
764 | *netfid = pSMBr->Fid; /* cifs fid stays in le */ | 772 | *netfid = pSMBr->Fid; /* cifs fid stays in le */ |
765 | /* Let caller know file was created so we can set the mode. */ | 773 | /* Let caller know file was created so we can set the mode. */ |
766 | /* Do we care about the CreateAction in any other cases? */ | 774 | /* Do we care about the CreateAction in any other cases? */ |
@@ -1017,11 +1025,13 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, | |||
1017 | __u16 count; | 1025 | __u16 count; |
1018 | 1026 | ||
1019 | cFYI(1, ("In CIFSSMBLock - timeout %d numLock %d",waitFlag,numLock)); | 1027 | cFYI(1, ("In CIFSSMBLock - timeout %d numLock %d",waitFlag,numLock)); |
1020 | rc = smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB, | 1028 | rc = small_smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB); |
1021 | (void **) &pSMBr); | 1029 | |
1022 | if (rc) | 1030 | if (rc) |
1023 | return rc; | 1031 | return rc; |
1024 | 1032 | ||
1033 | pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */ | ||
1034 | |||
1025 | if(lockType == LOCKING_ANDX_OPLOCK_RELEASE) { | 1035 | if(lockType == LOCKING_ANDX_OPLOCK_RELEASE) { |
1026 | timeout = -1; /* no response expected */ | 1036 | timeout = -1; /* no response expected */ |
1027 | pSMB->Timeout = 0; | 1037 | pSMB->Timeout = 0; |
@@ -1059,7 +1069,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, | |||
1059 | if (rc) { | 1069 | if (rc) { |
1060 | cFYI(1, ("Send error in Lock = %d", rc)); | 1070 | cFYI(1, ("Send error in Lock = %d", rc)); |
1061 | } | 1071 | } |
1062 | cifs_buf_release(pSMB); | 1072 | cifs_small_buf_release(pSMB); |
1063 | 1073 | ||
1064 | /* Note: On -EAGAIN error only caller can retry on handle based calls | 1074 | /* Note: On -EAGAIN error only caller can retry on handle based calls |
1065 | since file handle passed in no longer valid */ | 1075 | since file handle passed in no longer valid */ |
@@ -1108,7 +1118,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id) | |||
1108 | int | 1118 | int |
1109 | CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, | 1119 | CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, |
1110 | const char *fromName, const char *toName, | 1120 | const char *fromName, const char *toName, |
1111 | const struct nls_table *nls_codepage) | 1121 | const struct nls_table *nls_codepage, int remap) |
1112 | { | 1122 | { |
1113 | int rc = 0; | 1123 | int rc = 0; |
1114 | RENAME_REQ *pSMB = NULL; | 1124 | RENAME_REQ *pSMB = NULL; |
@@ -1131,18 +1141,16 @@ renameRetry: | |||
1131 | 1141 | ||
1132 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1142 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1133 | name_len = | 1143 | name_len = |
1134 | cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, PATH_MAX | 1144 | cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName, |
1135 | /* find define for this maxpathcomponent */ | 1145 | PATH_MAX, nls_codepage, remap); |
1136 | , nls_codepage); | ||
1137 | name_len++; /* trailing null */ | 1146 | name_len++; /* trailing null */ |
1138 | name_len *= 2; | 1147 | name_len *= 2; |
1139 | pSMB->OldFileName[name_len] = 0x04; /* pad */ | 1148 | pSMB->OldFileName[name_len] = 0x04; /* pad */ |
1140 | /* protocol requires ASCII signature byte on Unicode string */ | 1149 | /* protocol requires ASCII signature byte on Unicode string */ |
1141 | pSMB->OldFileName[name_len + 1] = 0x00; | 1150 | pSMB->OldFileName[name_len + 1] = 0x00; |
1142 | name_len2 = | 1151 | name_len2 = |
1143 | cifs_strtoUCS((wchar_t *) & pSMB-> | 1152 | cifsConvertToUCS((__u16 *) &pSMB->OldFileName[name_len + 2], |
1144 | OldFileName[name_len + 2], toName, PATH_MAX, | 1153 | toName, PATH_MAX, nls_codepage, remap); |
1145 | nls_codepage); | ||
1146 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 1154 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
1147 | name_len2 *= 2; /* convert to bytes */ | 1155 | name_len2 *= 2; /* convert to bytes */ |
1148 | } else { /* BB improve the check for buffer overruns BB */ | 1156 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -1182,7 +1190,8 @@ renameRetry: | |||
1182 | } | 1190 | } |
1183 | 1191 | ||
1184 | int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, | 1192 | int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, |
1185 | int netfid, char * target_name, const struct nls_table * nls_codepage) | 1193 | int netfid, char * target_name, |
1194 | const struct nls_table * nls_codepage, int remap) | ||
1186 | { | 1195 | { |
1187 | struct smb_com_transaction2_sfi_req *pSMB = NULL; | 1196 | struct smb_com_transaction2_sfi_req *pSMB = NULL; |
1188 | struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; | 1197 | struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; |
@@ -1227,9 +1236,11 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, | |||
1227 | /* unicode only call */ | 1236 | /* unicode only call */ |
1228 | if(target_name == NULL) { | 1237 | if(target_name == NULL) { |
1229 | sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); | 1238 | sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); |
1230 | len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, dummy_string, 24, nls_codepage); | 1239 | len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name, |
1240 | dummy_string, 24, nls_codepage, remap); | ||
1231 | } else { | 1241 | } else { |
1232 | len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, target_name, PATH_MAX, nls_codepage); | 1242 | len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name, |
1243 | target_name, PATH_MAX, nls_codepage, remap); | ||
1233 | } | 1244 | } |
1234 | rename_info->target_name_len = cpu_to_le32(2 * len_of_str); | 1245 | rename_info->target_name_len = cpu_to_le32(2 * len_of_str); |
1235 | count = 12 /* sizeof(struct set_file_rename) */ + (2 * len_of_str) + 2; | 1246 | count = 12 /* sizeof(struct set_file_rename) */ + (2 * len_of_str) + 2; |
@@ -1263,7 +1274,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, | |||
1263 | int | 1274 | int |
1264 | CIFSSMBCopy(const int xid, struct cifsTconInfo *tcon, const char * fromName, | 1275 | CIFSSMBCopy(const int xid, struct cifsTconInfo *tcon, const char * fromName, |
1265 | const __u16 target_tid, const char *toName, const int flags, | 1276 | const __u16 target_tid, const char *toName, const int flags, |
1266 | const struct nls_table *nls_codepage) | 1277 | const struct nls_table *nls_codepage, int remap) |
1267 | { | 1278 | { |
1268 | int rc = 0; | 1279 | int rc = 0; |
1269 | COPY_REQ *pSMB = NULL; | 1280 | COPY_REQ *pSMB = NULL; |
@@ -1285,18 +1296,16 @@ copyRetry: | |||
1285 | pSMB->Flags = cpu_to_le16(flags & COPY_TREE); | 1296 | pSMB->Flags = cpu_to_le16(flags & COPY_TREE); |
1286 | 1297 | ||
1287 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1298 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1288 | name_len = cifs_strtoUCS((wchar_t *) pSMB->OldFileName, | 1299 | name_len = cifsConvertToUCS((__u16 *) pSMB->OldFileName, |
1289 | fromName, | 1300 | fromName, PATH_MAX, nls_codepage, |
1290 | PATH_MAX /* find define for this maxpathcomponent */, | 1301 | remap); |
1291 | nls_codepage); | ||
1292 | name_len++; /* trailing null */ | 1302 | name_len++; /* trailing null */ |
1293 | name_len *= 2; | 1303 | name_len *= 2; |
1294 | pSMB->OldFileName[name_len] = 0x04; /* pad */ | 1304 | pSMB->OldFileName[name_len] = 0x04; /* pad */ |
1295 | /* protocol requires ASCII signature byte on Unicode string */ | 1305 | /* protocol requires ASCII signature byte on Unicode string */ |
1296 | pSMB->OldFileName[name_len + 1] = 0x00; | 1306 | pSMB->OldFileName[name_len + 1] = 0x00; |
1297 | name_len2 = cifs_strtoUCS((wchar_t *) & pSMB-> | 1307 | name_len2 = cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2], |
1298 | OldFileName[name_len + 2], toName, PATH_MAX, | 1308 | toName, PATH_MAX, nls_codepage, remap); |
1299 | nls_codepage); | ||
1300 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 1309 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
1301 | name_len2 *= 2; /* convert to bytes */ | 1310 | name_len2 *= 2; /* convert to bytes */ |
1302 | } else { /* BB improve the check for buffer overruns BB */ | 1311 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -1425,7 +1434,7 @@ createSymLinkRetry: | |||
1425 | int | 1434 | int |
1426 | CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon, | 1435 | CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon, |
1427 | const char *fromName, const char *toName, | 1436 | const char *fromName, const char *toName, |
1428 | const struct nls_table *nls_codepage) | 1437 | const struct nls_table *nls_codepage, int remap) |
1429 | { | 1438 | { |
1430 | TRANSACTION2_SPI_REQ *pSMB = NULL; | 1439 | TRANSACTION2_SPI_REQ *pSMB = NULL; |
1431 | TRANSACTION2_SPI_RSP *pSMBr = NULL; | 1440 | TRANSACTION2_SPI_RSP *pSMBr = NULL; |
@@ -1444,9 +1453,8 @@ createHardLinkRetry: | |||
1444 | return rc; | 1453 | return rc; |
1445 | 1454 | ||
1446 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1455 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1447 | name_len = cifs_strtoUCS((wchar_t *) pSMB->FileName, toName, PATH_MAX | 1456 | name_len = cifsConvertToUCS((__u16 *) pSMB->FileName, toName, |
1448 | /* find define for this maxpathcomponent */ | 1457 | PATH_MAX, nls_codepage, remap); |
1449 | , nls_codepage); | ||
1450 | name_len++; /* trailing null */ | 1458 | name_len++; /* trailing null */ |
1451 | name_len *= 2; | 1459 | name_len *= 2; |
1452 | 1460 | ||
@@ -1468,9 +1476,8 @@ createHardLinkRetry: | |||
1468 | data_offset = (char *) (&pSMB->hdr.Protocol) + offset; | 1476 | data_offset = (char *) (&pSMB->hdr.Protocol) + offset; |
1469 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1477 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1470 | name_len_target = | 1478 | name_len_target = |
1471 | cifs_strtoUCS((wchar_t *) data_offset, fromName, PATH_MAX | 1479 | cifsConvertToUCS((__u16 *) data_offset, fromName, PATH_MAX, |
1472 | /* find define for this maxpathcomponent */ | 1480 | nls_codepage, remap); |
1473 | , nls_codepage); | ||
1474 | name_len_target++; /* trailing null */ | 1481 | name_len_target++; /* trailing null */ |
1475 | name_len_target *= 2; | 1482 | name_len_target *= 2; |
1476 | } else { /* BB improve the check for buffer overruns BB */ | 1483 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -1512,7 +1519,7 @@ createHardLinkRetry: | |||
1512 | int | 1519 | int |
1513 | CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, | 1520 | CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, |
1514 | const char *fromName, const char *toName, | 1521 | const char *fromName, const char *toName, |
1515 | const struct nls_table *nls_codepage) | 1522 | const struct nls_table *nls_codepage, int remap) |
1516 | { | 1523 | { |
1517 | int rc = 0; | 1524 | int rc = 0; |
1518 | NT_RENAME_REQ *pSMB = NULL; | 1525 | NT_RENAME_REQ *pSMB = NULL; |
@@ -1539,17 +1546,15 @@ winCreateHardLinkRetry: | |||
1539 | 1546 | ||
1540 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1547 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1541 | name_len = | 1548 | name_len = |
1542 | cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, PATH_MAX | 1549 | cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName, |
1543 | /* find define for this maxpathcomponent */ | 1550 | PATH_MAX, nls_codepage, remap); |
1544 | , nls_codepage); | ||
1545 | name_len++; /* trailing null */ | 1551 | name_len++; /* trailing null */ |
1546 | name_len *= 2; | 1552 | name_len *= 2; |
1547 | pSMB->OldFileName[name_len] = 0; /* pad */ | 1553 | pSMB->OldFileName[name_len] = 0; /* pad */ |
1548 | pSMB->OldFileName[name_len + 1] = 0x04; | 1554 | pSMB->OldFileName[name_len + 1] = 0x04; |
1549 | name_len2 = | 1555 | name_len2 = |
1550 | cifs_strtoUCS((wchar_t *) & pSMB-> | 1556 | cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2], |
1551 | OldFileName[name_len + 2], toName, PATH_MAX, | 1557 | toName, PATH_MAX, nls_codepage, remap); |
1552 | nls_codepage); | ||
1553 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 1558 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
1554 | name_len2 *= 2; /* convert to bytes */ | 1559 | name_len2 *= 2; /* convert to bytes */ |
1555 | } else { /* BB improve the check for buffer overruns BB */ | 1560 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -1659,6 +1664,7 @@ querySymLinkRetry: | |||
1659 | name_len = UniStrnlen((wchar_t *) ((char *) | 1664 | name_len = UniStrnlen((wchar_t *) ((char *) |
1660 | &pSMBr->hdr.Protocol +data_offset), | 1665 | &pSMBr->hdr.Protocol +data_offset), |
1661 | min_t(const int, buflen,count) / 2); | 1666 | min_t(const int, buflen,count) / 2); |
1667 | /* BB FIXME investigate remapping reserved chars here */ | ||
1662 | cifs_strfromUCS_le(symlinkinfo, | 1668 | cifs_strfromUCS_le(symlinkinfo, |
1663 | (wchar_t *) ((char *)&pSMBr->hdr.Protocol + | 1669 | (wchar_t *) ((char *)&pSMBr->hdr.Protocol + |
1664 | data_offset), | 1670 | data_offset), |
@@ -1793,7 +1799,8 @@ static void cifs_convert_ace(posix_acl_xattr_entry * ace, struct cifs_posix_ace | |||
1793 | } | 1799 | } |
1794 | 1800 | ||
1795 | /* Convert ACL from CIFS POSIX wire format to local Linux POSIX ACL xattr */ | 1801 | /* Convert ACL from CIFS POSIX wire format to local Linux POSIX ACL xattr */ |
1796 | static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,const int acl_type,const int size_of_data_area) | 1802 | static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen, |
1803 | const int acl_type,const int size_of_data_area) | ||
1797 | { | 1804 | { |
1798 | int size = 0; | 1805 | int size = 0; |
1799 | int i; | 1806 | int i; |
@@ -1912,7 +1919,7 @@ int | |||
1912 | CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, | 1919 | CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, |
1913 | const unsigned char *searchName, | 1920 | const unsigned char *searchName, |
1914 | char *acl_inf, const int buflen, const int acl_type, | 1921 | char *acl_inf, const int buflen, const int acl_type, |
1915 | const struct nls_table *nls_codepage) | 1922 | const struct nls_table *nls_codepage, int remap) |
1916 | { | 1923 | { |
1917 | /* SMB_QUERY_POSIX_ACL */ | 1924 | /* SMB_QUERY_POSIX_ACL */ |
1918 | TRANSACTION2_QPI_REQ *pSMB = NULL; | 1925 | TRANSACTION2_QPI_REQ *pSMB = NULL; |
@@ -1932,8 +1939,8 @@ queryAclRetry: | |||
1932 | 1939 | ||
1933 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1940 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1934 | name_len = | 1941 | name_len = |
1935 | cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX | 1942 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, |
1936 | , nls_codepage); | 1943 | PATH_MAX, nls_codepage, remap); |
1937 | name_len++; /* trailing null */ | 1944 | name_len++; /* trailing null */ |
1938 | name_len *= 2; | 1945 | name_len *= 2; |
1939 | pSMB->FileName[name_len] = 0; | 1946 | pSMB->FileName[name_len] = 0; |
@@ -1997,8 +2004,9 @@ queryAclRetry: | |||
1997 | int | 2004 | int |
1998 | CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, | 2005 | CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, |
1999 | const unsigned char *fileName, | 2006 | const unsigned char *fileName, |
2000 | const char *local_acl, const int buflen, const int acl_type, | 2007 | const char *local_acl, const int buflen, |
2001 | const struct nls_table *nls_codepage) | 2008 | const int acl_type, |
2009 | const struct nls_table *nls_codepage, int remap) | ||
2002 | { | 2010 | { |
2003 | struct smb_com_transaction2_spi_req *pSMB = NULL; | 2011 | struct smb_com_transaction2_spi_req *pSMB = NULL; |
2004 | struct smb_com_transaction2_spi_rsp *pSMBr = NULL; | 2012 | struct smb_com_transaction2_spi_rsp *pSMBr = NULL; |
@@ -2016,8 +2024,8 @@ setAclRetry: | |||
2016 | return rc; | 2024 | return rc; |
2017 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2025 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2018 | name_len = | 2026 | name_len = |
2019 | cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX | 2027 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, |
2020 | , nls_codepage); | 2028 | PATH_MAX, nls_codepage, remap); |
2021 | name_len++; /* trailing null */ | 2029 | name_len++; /* trailing null */ |
2022 | name_len *= 2; | 2030 | name_len *= 2; |
2023 | } else { /* BB improve the check for buffer overruns BB */ | 2031 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -2072,13 +2080,96 @@ setACLerrorExit: | |||
2072 | return rc; | 2080 | return rc; |
2073 | } | 2081 | } |
2074 | 2082 | ||
2075 | #endif | 2083 | /* BB fix tabs in this function FIXME BB */ |
2084 | int | ||
2085 | CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon, | ||
2086 | const int netfid, __u64 * pExtAttrBits, __u64 *pMask) | ||
2087 | { | ||
2088 | int rc = 0; | ||
2089 | struct smb_t2_qfi_req *pSMB = NULL; | ||
2090 | struct smb_t2_qfi_rsp *pSMBr = NULL; | ||
2091 | int bytes_returned; | ||
2092 | __u16 params, byte_count; | ||
2093 | |||
2094 | cFYI(1,("In GetExtAttr")); | ||
2095 | if(tcon == NULL) | ||
2096 | return -ENODEV; | ||
2097 | |||
2098 | GetExtAttrRetry: | ||
2099 | rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, | ||
2100 | (void **) &pSMBr); | ||
2101 | if (rc) | ||
2102 | return rc; | ||
2103 | |||
2104 | params = 2 /* level */ +2 /* fid */; | ||
2105 | pSMB->t2.TotalDataCount = 0; | ||
2106 | pSMB->t2.MaxParameterCount = cpu_to_le16(4); | ||
2107 | /* BB find exact max data count below from sess structure BB */ | ||
2108 | pSMB->t2.MaxDataCount = cpu_to_le16(4000); | ||
2109 | pSMB->t2.MaxSetupCount = 0; | ||
2110 | pSMB->t2.Reserved = 0; | ||
2111 | pSMB->t2.Flags = 0; | ||
2112 | pSMB->t2.Timeout = 0; | ||
2113 | pSMB->t2.Reserved2 = 0; | ||
2114 | pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req, | ||
2115 | Fid) - 4); | ||
2116 | pSMB->t2.DataCount = 0; | ||
2117 | pSMB->t2.DataOffset = 0; | ||
2118 | pSMB->t2.SetupCount = 1; | ||
2119 | pSMB->t2.Reserved3 = 0; | ||
2120 | pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION); | ||
2121 | byte_count = params + 1 /* pad */ ; | ||
2122 | pSMB->t2.TotalParameterCount = cpu_to_le16(params); | ||
2123 | pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount; | ||
2124 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_ATTR_FLAGS); | ||
2125 | pSMB->Pad = 0; | ||
2126 | pSMB->Fid = netfid; | ||
2127 | pSMB->hdr.smb_buf_length += byte_count; | ||
2128 | pSMB->t2.ByteCount = cpu_to_le16(byte_count); | ||
2129 | |||
2130 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | ||
2131 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | ||
2132 | if (rc) { | ||
2133 | cFYI(1, ("error %d in GetExtAttr", rc)); | ||
2134 | } else { | ||
2135 | /* decode response */ | ||
2136 | rc = validate_t2((struct smb_t2_rsp *)pSMBr); | ||
2137 | if (rc || (pSMBr->ByteCount < 2)) | ||
2138 | /* BB also check enough total bytes returned */ | ||
2139 | /* If rc should we check for EOPNOSUPP and | ||
2140 | disable the srvino flag? or in caller? */ | ||
2141 | rc = -EIO; /* bad smb */ | ||
2142 | else { | ||
2143 | __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); | ||
2144 | __u16 count = le16_to_cpu(pSMBr->t2.DataCount); | ||
2145 | struct file_chattr_info * pfinfo; | ||
2146 | /* BB Do we need a cast or hash here ? */ | ||
2147 | if(count != 16) { | ||
2148 | cFYI(1, ("Illegal size ret in GetExtAttr")); | ||
2149 | rc = -EIO; | ||
2150 | goto GetExtAttrOut; | ||
2151 | } | ||
2152 | pfinfo = (struct file_chattr_info *) | ||
2153 | (data_offset + (char *) &pSMBr->hdr.Protocol); | ||
2154 | *pExtAttrBits = le64_to_cpu(pfinfo->mode); | ||
2155 | *pMask = le64_to_cpu(pfinfo->mask); | ||
2156 | } | ||
2157 | } | ||
2158 | GetExtAttrOut: | ||
2159 | cifs_buf_release(pSMB); | ||
2160 | if (rc == -EAGAIN) | ||
2161 | goto GetExtAttrRetry; | ||
2162 | return rc; | ||
2163 | } | ||
2164 | |||
2165 | |||
2166 | #endif /* CONFIG_POSIX */ | ||
2076 | 2167 | ||
2077 | int | 2168 | int |
2078 | CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, | 2169 | CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, |
2079 | const unsigned char *searchName, | 2170 | const unsigned char *searchName, |
2080 | FILE_ALL_INFO * pFindData, | 2171 | FILE_ALL_INFO * pFindData, |
2081 | const struct nls_table *nls_codepage) | 2172 | const struct nls_table *nls_codepage, int remap) |
2082 | { | 2173 | { |
2083 | /* level 263 SMB_QUERY_FILE_ALL_INFO */ | 2174 | /* level 263 SMB_QUERY_FILE_ALL_INFO */ |
2084 | TRANSACTION2_QPI_REQ *pSMB = NULL; | 2175 | TRANSACTION2_QPI_REQ *pSMB = NULL; |
@@ -2097,9 +2188,8 @@ QPathInfoRetry: | |||
2097 | 2188 | ||
2098 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2189 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2099 | name_len = | 2190 | name_len = |
2100 | cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX | 2191 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, |
2101 | /* find define for this maxpathcomponent */ | 2192 | PATH_MAX, nls_codepage, remap); |
2102 | , nls_codepage); | ||
2103 | name_len++; /* trailing null */ | 2193 | name_len++; /* trailing null */ |
2104 | name_len *= 2; | 2194 | name_len *= 2; |
2105 | } else { /* BB improve the check for buffer overruns BB */ | 2195 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -2160,7 +2250,7 @@ int | |||
2160 | CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, | 2250 | CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, |
2161 | const unsigned char *searchName, | 2251 | const unsigned char *searchName, |
2162 | FILE_UNIX_BASIC_INFO * pFindData, | 2252 | FILE_UNIX_BASIC_INFO * pFindData, |
2163 | const struct nls_table *nls_codepage) | 2253 | const struct nls_table *nls_codepage, int remap) |
2164 | { | 2254 | { |
2165 | /* SMB_QUERY_FILE_UNIX_BASIC */ | 2255 | /* SMB_QUERY_FILE_UNIX_BASIC */ |
2166 | TRANSACTION2_QPI_REQ *pSMB = NULL; | 2256 | TRANSACTION2_QPI_REQ *pSMB = NULL; |
@@ -2179,9 +2269,8 @@ UnixQPathInfoRetry: | |||
2179 | 2269 | ||
2180 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2270 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2181 | name_len = | 2271 | name_len = |
2182 | cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX | 2272 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, |
2183 | /* find define for this maxpathcomponent */ | 2273 | PATH_MAX, nls_codepage, remap); |
2184 | , nls_codepage); | ||
2185 | name_len++; /* trailing null */ | 2274 | name_len++; /* trailing null */ |
2186 | name_len *= 2; | 2275 | name_len *= 2; |
2187 | } else { /* BB improve the check for buffer overruns BB */ | 2276 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -2261,7 +2350,7 @@ findUniqueRetry: | |||
2261 | 2350 | ||
2262 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2351 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2263 | name_len = | 2352 | name_len = |
2264 | cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX | 2353 | cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX |
2265 | /* find define for this maxpathcomponent */ | 2354 | /* find define for this maxpathcomponent */ |
2266 | , nls_codepage); | 2355 | , nls_codepage); |
2267 | name_len++; /* trailing null */ | 2356 | name_len++; /* trailing null */ |
@@ -2325,7 +2414,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, | |||
2325 | const char *searchName, | 2414 | const char *searchName, |
2326 | const struct nls_table *nls_codepage, | 2415 | const struct nls_table *nls_codepage, |
2327 | __u16 * pnetfid, | 2416 | __u16 * pnetfid, |
2328 | struct cifs_search_info * psrch_inf) | 2417 | struct cifs_search_info * psrch_inf, int remap) |
2329 | { | 2418 | { |
2330 | /* level 257 SMB_ */ | 2419 | /* level 257 SMB_ */ |
2331 | TRANSACTION2_FFIRST_REQ *pSMB = NULL; | 2420 | TRANSACTION2_FFIRST_REQ *pSMB = NULL; |
@@ -2336,7 +2425,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, | |||
2336 | int name_len; | 2425 | int name_len; |
2337 | __u16 params, byte_count; | 2426 | __u16 params, byte_count; |
2338 | 2427 | ||
2339 | cFYI(1, ("In FindFirst")); | 2428 | cFYI(1, ("In FindFirst for %s",searchName)); |
2340 | 2429 | ||
2341 | findFirstRetry: | 2430 | findFirstRetry: |
2342 | rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, | 2431 | rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, |
@@ -2346,20 +2435,30 @@ findFirstRetry: | |||
2346 | 2435 | ||
2347 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2436 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2348 | name_len = | 2437 | name_len = |
2349 | cifs_strtoUCS((wchar_t *) pSMB->FileName,searchName, | 2438 | cifsConvertToUCS((__u16 *) pSMB->FileName,searchName, |
2350 | PATH_MAX, nls_codepage); | 2439 | PATH_MAX, nls_codepage, remap); |
2351 | name_len++; /* trailing null */ | 2440 | /* We can not add the asterik earlier in case |
2441 | it got remapped to 0xF03A as if it were part of the | ||
2442 | directory name instead of a wildcard */ | ||
2352 | name_len *= 2; | 2443 | name_len *= 2; |
2444 | pSMB->FileName[name_len] = '\\'; | ||
2445 | pSMB->FileName[name_len+1] = 0; | ||
2446 | pSMB->FileName[name_len+2] = '*'; | ||
2447 | pSMB->FileName[name_len+3] = 0; | ||
2448 | name_len += 4; /* now the trailing null */ | ||
2353 | pSMB->FileName[name_len] = 0; /* null terminate just in case */ | 2449 | pSMB->FileName[name_len] = 0; /* null terminate just in case */ |
2354 | pSMB->FileName[name_len+1] = 0; | 2450 | pSMB->FileName[name_len+1] = 0; |
2451 | name_len += 2; | ||
2355 | } else { /* BB add check for overrun of SMB buf BB */ | 2452 | } else { /* BB add check for overrun of SMB buf BB */ |
2356 | name_len = strnlen(searchName, PATH_MAX); | 2453 | name_len = strnlen(searchName, PATH_MAX); |
2357 | name_len++; /* trailing null */ | ||
2358 | /* BB fix here and in unicode clause above ie | 2454 | /* BB fix here and in unicode clause above ie |
2359 | if(name_len > buffersize-header) | 2455 | if(name_len > buffersize-header) |
2360 | free buffer exit; BB */ | 2456 | free buffer exit; BB */ |
2361 | strncpy(pSMB->FileName, searchName, name_len); | 2457 | strncpy(pSMB->FileName, searchName, name_len); |
2362 | pSMB->FileName[name_len] = 0; /* just in case */ | 2458 | pSMB->FileName[name_len] = '\\'; |
2459 | pSMB->FileName[name_len+1] = '*'; | ||
2460 | pSMB->FileName[name_len+2] = 0; | ||
2461 | name_len += 3; | ||
2363 | } | 2462 | } |
2364 | 2463 | ||
2365 | params = 12 + name_len /* includes null */ ; | 2464 | params = 12 + name_len /* includes null */ ; |
@@ -2422,7 +2521,6 @@ findFirstRetry: | |||
2422 | psrch_inf->srch_entries_start = | 2521 | psrch_inf->srch_entries_start = |
2423 | (char *) &pSMBr->hdr.Protocol + | 2522 | (char *) &pSMBr->hdr.Protocol + |
2424 | le16_to_cpu(pSMBr->t2.DataOffset); | 2523 | le16_to_cpu(pSMBr->t2.DataOffset); |
2425 | |||
2426 | parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol + | 2524 | parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol + |
2427 | le16_to_cpu(pSMBr->t2.ParameterOffset)); | 2525 | le16_to_cpu(pSMBr->t2.ParameterOffset)); |
2428 | 2526 | ||
@@ -2434,7 +2532,6 @@ findFirstRetry: | |||
2434 | psrch_inf->entries_in_buffer = le16_to_cpu(parms->SearchCount); | 2532 | psrch_inf->entries_in_buffer = le16_to_cpu(parms->SearchCount); |
2435 | psrch_inf->index_of_last_entry = | 2533 | psrch_inf->index_of_last_entry = |
2436 | psrch_inf->entries_in_buffer; | 2534 | psrch_inf->entries_in_buffer; |
2437 | /*cFYI(1,("entries in buf %d index_of_last %d",psrch_inf->entries_in_buffer,psrch_inf->index_of_last_entry)); */ | ||
2438 | *pnetfid = parms->SearchHandle; | 2535 | *pnetfid = parms->SearchHandle; |
2439 | } else { | 2536 | } else { |
2440 | cifs_buf_release(pSMB); | 2537 | cifs_buf_release(pSMB); |
@@ -2608,7 +2705,7 @@ int | |||
2608 | CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, | 2705 | CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, |
2609 | const unsigned char *searchName, | 2706 | const unsigned char *searchName, |
2610 | __u64 * inode_number, | 2707 | __u64 * inode_number, |
2611 | const struct nls_table *nls_codepage) | 2708 | const struct nls_table *nls_codepage, int remap) |
2612 | { | 2709 | { |
2613 | int rc = 0; | 2710 | int rc = 0; |
2614 | TRANSACTION2_QPI_REQ *pSMB = NULL; | 2711 | TRANSACTION2_QPI_REQ *pSMB = NULL; |
@@ -2629,8 +2726,8 @@ GetInodeNumberRetry: | |||
2629 | 2726 | ||
2630 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2727 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2631 | name_len = | 2728 | name_len = |
2632 | cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, | 2729 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, |
2633 | PATH_MAX,nls_codepage); | 2730 | PATH_MAX,nls_codepage, remap); |
2634 | name_len++; /* trailing null */ | 2731 | name_len++; /* trailing null */ |
2635 | name_len *= 2; | 2732 | name_len *= 2; |
2636 | } else { /* BB improve the check for buffer overruns BB */ | 2733 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -2704,7 +2801,7 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, | |||
2704 | const unsigned char *searchName, | 2801 | const unsigned char *searchName, |
2705 | unsigned char **targetUNCs, | 2802 | unsigned char **targetUNCs, |
2706 | unsigned int *number_of_UNC_in_array, | 2803 | unsigned int *number_of_UNC_in_array, |
2707 | const struct nls_table *nls_codepage) | 2804 | const struct nls_table *nls_codepage, int remap) |
2708 | { | 2805 | { |
2709 | /* TRANS2_GET_DFS_REFERRAL */ | 2806 | /* TRANS2_GET_DFS_REFERRAL */ |
2710 | TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL; | 2807 | TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL; |
@@ -2740,10 +2837,8 @@ getDFSRetry: | |||
2740 | if (ses->capabilities & CAP_UNICODE) { | 2837 | if (ses->capabilities & CAP_UNICODE) { |
2741 | pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; | 2838 | pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; |
2742 | name_len = | 2839 | name_len = |
2743 | cifs_strtoUCS((wchar_t *) pSMB->RequestFileName, | 2840 | cifsConvertToUCS((__u16 *) pSMB->RequestFileName, |
2744 | searchName, PATH_MAX | 2841 | searchName, PATH_MAX, nls_codepage, remap); |
2745 | /* find define for this maxpathcomponent */ | ||
2746 | , nls_codepage); | ||
2747 | name_len++; /* trailing null */ | 2842 | name_len++; /* trailing null */ |
2748 | name_len *= 2; | 2843 | name_len *= 2; |
2749 | } else { /* BB improve the check for buffer overruns BB */ | 2844 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -2871,8 +2966,7 @@ GetDFSRefExit: | |||
2871 | } | 2966 | } |
2872 | 2967 | ||
2873 | int | 2968 | int |
2874 | CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, | 2969 | CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, struct kstatfs *FSData) |
2875 | struct kstatfs *FSData, const struct nls_table *nls_codepage) | ||
2876 | { | 2970 | { |
2877 | /* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */ | 2971 | /* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */ |
2878 | TRANSACTION2_QFSI_REQ *pSMB = NULL; | 2972 | TRANSACTION2_QFSI_REQ *pSMB = NULL; |
@@ -2955,8 +3049,7 @@ QFSInfoRetry: | |||
2955 | } | 3049 | } |
2956 | 3050 | ||
2957 | int | 3051 | int |
2958 | CIFSSMBQFSAttributeInfo(const int xid, struct cifsTconInfo *tcon, | 3052 | CIFSSMBQFSAttributeInfo(const int xid, struct cifsTconInfo *tcon) |
2959 | const struct nls_table *nls_codepage) | ||
2960 | { | 3053 | { |
2961 | /* level 0x105 SMB_QUERY_FILE_SYSTEM_INFO */ | 3054 | /* level 0x105 SMB_QUERY_FILE_SYSTEM_INFO */ |
2962 | TRANSACTION2_QFSI_REQ *pSMB = NULL; | 3055 | TRANSACTION2_QFSI_REQ *pSMB = NULL; |
@@ -3024,8 +3117,7 @@ QFSAttributeRetry: | |||
3024 | } | 3117 | } |
3025 | 3118 | ||
3026 | int | 3119 | int |
3027 | CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon, | 3120 | CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon) |
3028 | const struct nls_table *nls_codepage) | ||
3029 | { | 3121 | { |
3030 | /* level 0x104 SMB_QUERY_FILE_SYSTEM_INFO */ | 3122 | /* level 0x104 SMB_QUERY_FILE_SYSTEM_INFO */ |
3031 | TRANSACTION2_QFSI_REQ *pSMB = NULL; | 3123 | TRANSACTION2_QFSI_REQ *pSMB = NULL; |
@@ -3078,8 +3170,8 @@ QFSDeviceRetry: | |||
3078 | else { | 3170 | else { |
3079 | __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); | 3171 | __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); |
3080 | response_data = | 3172 | response_data = |
3081 | (FILE_SYSTEM_DEVICE_INFO | 3173 | (FILE_SYSTEM_DEVICE_INFO *) |
3082 | *) (((char *) &pSMBr->hdr.Protocol) + | 3174 | (((char *) &pSMBr->hdr.Protocol) + |
3083 | data_offset); | 3175 | data_offset); |
3084 | memcpy(&tcon->fsDevInfo, response_data, | 3176 | memcpy(&tcon->fsDevInfo, response_data, |
3085 | sizeof (FILE_SYSTEM_DEVICE_INFO)); | 3177 | sizeof (FILE_SYSTEM_DEVICE_INFO)); |
@@ -3094,8 +3186,7 @@ QFSDeviceRetry: | |||
3094 | } | 3186 | } |
3095 | 3187 | ||
3096 | int | 3188 | int |
3097 | CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon, | 3189 | CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon) |
3098 | const struct nls_table *nls_codepage) | ||
3099 | { | 3190 | { |
3100 | /* level 0x200 SMB_QUERY_CIFS_UNIX_INFO */ | 3191 | /* level 0x200 SMB_QUERY_CIFS_UNIX_INFO */ |
3101 | TRANSACTION2_QFSI_REQ *pSMB = NULL; | 3192 | TRANSACTION2_QFSI_REQ *pSMB = NULL; |
@@ -3166,7 +3257,7 @@ QFSUnixRetry: | |||
3166 | 3257 | ||
3167 | int | 3258 | int |
3168 | CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, | 3259 | CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, |
3169 | struct kstatfs *FSData, const struct nls_table *nls_codepage) | 3260 | struct kstatfs *FSData) |
3170 | { | 3261 | { |
3171 | /* level 0x201 SMB_QUERY_CIFS_POSIX_INFO */ | 3262 | /* level 0x201 SMB_QUERY_CIFS_POSIX_INFO */ |
3172 | TRANSACTION2_QFSI_REQ *pSMB = NULL; | 3263 | TRANSACTION2_QFSI_REQ *pSMB = NULL; |
@@ -3258,7 +3349,8 @@ QFSPosixRetry: | |||
3258 | 3349 | ||
3259 | int | 3350 | int |
3260 | CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName, | 3351 | CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName, |
3261 | __u64 size, int SetAllocation, const struct nls_table *nls_codepage) | 3352 | __u64 size, int SetAllocation, |
3353 | const struct nls_table *nls_codepage, int remap) | ||
3262 | { | 3354 | { |
3263 | struct smb_com_transaction2_spi_req *pSMB = NULL; | 3355 | struct smb_com_transaction2_spi_req *pSMB = NULL; |
3264 | struct smb_com_transaction2_spi_rsp *pSMBr = NULL; | 3356 | struct smb_com_transaction2_spi_rsp *pSMBr = NULL; |
@@ -3277,9 +3369,8 @@ SetEOFRetry: | |||
3277 | 3369 | ||
3278 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3370 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3279 | name_len = | 3371 | name_len = |
3280 | cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX | 3372 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, |
3281 | /* find define for this maxpathcomponent */ | 3373 | PATH_MAX, nls_codepage, remap); |
3282 | , nls_codepage); | ||
3283 | name_len++; /* trailing null */ | 3374 | name_len++; /* trailing null */ |
3284 | name_len *= 2; | 3375 | name_len *= 2; |
3285 | } else { /* BB improve the check for buffer overruns BB */ | 3376 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -3360,11 +3451,13 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, | |||
3360 | 3451 | ||
3361 | cFYI(1, ("SetFileSize (via SetFileInfo) %lld", | 3452 | cFYI(1, ("SetFileSize (via SetFileInfo) %lld", |
3362 | (long long)size)); | 3453 | (long long)size)); |
3363 | rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, | 3454 | rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); |
3364 | (void **) &pSMBr); | 3455 | |
3365 | if (rc) | 3456 | if (rc) |
3366 | return rc; | 3457 | return rc; |
3367 | 3458 | ||
3459 | pSMBr = (struct smb_com_transaction2_sfi_rsp *)pSMB; | ||
3460 | |||
3368 | pSMB->hdr.Pid = cpu_to_le16((__u16)pid_of_opener); | 3461 | pSMB->hdr.Pid = cpu_to_le16((__u16)pid_of_opener); |
3369 | pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid_of_opener >> 16)); | 3462 | pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid_of_opener >> 16)); |
3370 | 3463 | ||
@@ -3424,7 +3517,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, | |||
3424 | } | 3517 | } |
3425 | 3518 | ||
3426 | if (pSMB) | 3519 | if (pSMB) |
3427 | cifs_buf_release(pSMB); | 3520 | cifs_small_buf_release(pSMB); |
3428 | 3521 | ||
3429 | /* Note: On -EAGAIN error only caller can retry on handle based calls | 3522 | /* Note: On -EAGAIN error only caller can retry on handle based calls |
3430 | since file handle passed in no longer valid */ | 3523 | since file handle passed in no longer valid */ |
@@ -3450,11 +3543,13 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, const FILE_BASIC_I | |||
3450 | __u16 params, param_offset, offset, byte_count, count; | 3543 | __u16 params, param_offset, offset, byte_count, count; |
3451 | 3544 | ||
3452 | cFYI(1, ("Set Times (via SetFileInfo)")); | 3545 | cFYI(1, ("Set Times (via SetFileInfo)")); |
3453 | rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, | 3546 | rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); |
3454 | (void **) &pSMBr); | 3547 | |
3455 | if (rc) | 3548 | if (rc) |
3456 | return rc; | 3549 | return rc; |
3457 | 3550 | ||
3551 | pSMBr = (struct smb_com_transaction2_sfi_rsp *)pSMB; | ||
3552 | |||
3458 | /* At this point there is no need to override the current pid | 3553 | /* At this point there is no need to override the current pid |
3459 | with the pid of the opener, but that could change if we someday | 3554 | with the pid of the opener, but that could change if we someday |
3460 | use an existing handle (rather than opening one on the fly) */ | 3555 | use an existing handle (rather than opening one on the fly) */ |
@@ -3500,7 +3595,7 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, const FILE_BASIC_I | |||
3500 | cFYI(1,("Send error in Set Time (SetFileInfo) = %d",rc)); | 3595 | cFYI(1,("Send error in Set Time (SetFileInfo) = %d",rc)); |
3501 | } | 3596 | } |
3502 | 3597 | ||
3503 | cifs_buf_release(pSMB); | 3598 | cifs_small_buf_release(pSMB); |
3504 | 3599 | ||
3505 | /* Note: On -EAGAIN error only caller can retry on handle based calls | 3600 | /* Note: On -EAGAIN error only caller can retry on handle based calls |
3506 | since file handle passed in no longer valid */ | 3601 | since file handle passed in no longer valid */ |
@@ -3512,7 +3607,7 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, const FILE_BASIC_I | |||
3512 | int | 3607 | int |
3513 | CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon, const char *fileName, | 3608 | CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon, const char *fileName, |
3514 | const FILE_BASIC_INFO * data, | 3609 | const FILE_BASIC_INFO * data, |
3515 | const struct nls_table *nls_codepage) | 3610 | const struct nls_table *nls_codepage, int remap) |
3516 | { | 3611 | { |
3517 | TRANSACTION2_SPI_REQ *pSMB = NULL; | 3612 | TRANSACTION2_SPI_REQ *pSMB = NULL; |
3518 | TRANSACTION2_SPI_RSP *pSMBr = NULL; | 3613 | TRANSACTION2_SPI_RSP *pSMBr = NULL; |
@@ -3532,9 +3627,8 @@ SetTimesRetry: | |||
3532 | 3627 | ||
3533 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3628 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3534 | name_len = | 3629 | name_len = |
3535 | cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX | 3630 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, |
3536 | /* find define for this maxpathcomponent */ | 3631 | PATH_MAX, nls_codepage, remap); |
3537 | , nls_codepage); | ||
3538 | name_len++; /* trailing null */ | 3632 | name_len++; /* trailing null */ |
3539 | name_len *= 2; | 3633 | name_len *= 2; |
3540 | } else { /* BB improve the check for buffer overruns BB */ | 3634 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -3614,7 +3708,7 @@ SetAttrLgcyRetry: | |||
3614 | 3708 | ||
3615 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3709 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3616 | name_len = | 3710 | name_len = |
3617 | cifs_strtoUCS((wchar_t *) pSMB->fileName, fileName, | 3711 | ConvertToUCS((wchar_t *) pSMB->fileName, fileName, |
3618 | PATH_MAX, nls_codepage); | 3712 | PATH_MAX, nls_codepage); |
3619 | name_len++; /* trailing null */ | 3713 | name_len++; /* trailing null */ |
3620 | name_len *= 2; | 3714 | name_len *= 2; |
@@ -3644,8 +3738,9 @@ SetAttrLgcyRetry: | |||
3644 | 3738 | ||
3645 | int | 3739 | int |
3646 | CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon, | 3740 | CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon, |
3647 | char *fileName, __u64 mode, __u64 uid, __u64 gid, | 3741 | char *fileName, __u64 mode, __u64 uid, __u64 gid, |
3648 | dev_t device, const struct nls_table *nls_codepage) | 3742 | dev_t device, const struct nls_table *nls_codepage, |
3743 | int remap) | ||
3649 | { | 3744 | { |
3650 | TRANSACTION2_SPI_REQ *pSMB = NULL; | 3745 | TRANSACTION2_SPI_REQ *pSMB = NULL; |
3651 | TRANSACTION2_SPI_RSP *pSMBr = NULL; | 3746 | TRANSACTION2_SPI_RSP *pSMBr = NULL; |
@@ -3664,9 +3759,8 @@ setPermsRetry: | |||
3664 | 3759 | ||
3665 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3760 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3666 | name_len = | 3761 | name_len = |
3667 | cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX | 3762 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, |
3668 | /* find define for this maxpathcomponent */ | 3763 | PATH_MAX, nls_codepage, remap); |
3669 | , nls_codepage); | ||
3670 | name_len++; /* trailing null */ | 3764 | name_len++; /* trailing null */ |
3671 | name_len *= 2; | 3765 | name_len *= 2; |
3672 | } else { /* BB improve the check for buffer overruns BB */ | 3766 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -3789,7 +3883,7 @@ ssize_t | |||
3789 | CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, | 3883 | CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, |
3790 | const unsigned char *searchName, | 3884 | const unsigned char *searchName, |
3791 | char * EAData, size_t buf_size, | 3885 | char * EAData, size_t buf_size, |
3792 | const struct nls_table *nls_codepage) | 3886 | const struct nls_table *nls_codepage, int remap) |
3793 | { | 3887 | { |
3794 | /* BB assumes one setup word */ | 3888 | /* BB assumes one setup word */ |
3795 | TRANSACTION2_QPI_REQ *pSMB = NULL; | 3889 | TRANSACTION2_QPI_REQ *pSMB = NULL; |
@@ -3810,9 +3904,8 @@ QAllEAsRetry: | |||
3810 | 3904 | ||
3811 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3905 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3812 | name_len = | 3906 | name_len = |
3813 | cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX | 3907 | cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, |
3814 | /* find define for this maxpathcomponent */ | 3908 | PATH_MAX, nls_codepage, remap); |
3815 | , nls_codepage); | ||
3816 | name_len++; /* trailing null */ | 3909 | name_len++; /* trailing null */ |
3817 | name_len *= 2; | 3910 | name_len *= 2; |
3818 | } else { /* BB improve the check for buffer overruns BB */ | 3911 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -3934,7 +4027,7 @@ QAllEAsRetry: | |||
3934 | ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon, | 4027 | ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon, |
3935 | const unsigned char * searchName,const unsigned char * ea_name, | 4028 | const unsigned char * searchName,const unsigned char * ea_name, |
3936 | unsigned char * ea_value, size_t buf_size, | 4029 | unsigned char * ea_value, size_t buf_size, |
3937 | const struct nls_table *nls_codepage) | 4030 | const struct nls_table *nls_codepage, int remap) |
3938 | { | 4031 | { |
3939 | TRANSACTION2_QPI_REQ *pSMB = NULL; | 4032 | TRANSACTION2_QPI_REQ *pSMB = NULL; |
3940 | TRANSACTION2_QPI_RSP *pSMBr = NULL; | 4033 | TRANSACTION2_QPI_RSP *pSMBr = NULL; |
@@ -3954,9 +4047,8 @@ QEARetry: | |||
3954 | 4047 | ||
3955 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 4048 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3956 | name_len = | 4049 | name_len = |
3957 | cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX | 4050 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, |
3958 | /* find define for this maxpathcomponent */ | 4051 | PATH_MAX, nls_codepage, remap); |
3959 | , nls_codepage); | ||
3960 | name_len++; /* trailing null */ | 4052 | name_len++; /* trailing null */ |
3961 | name_len *= 2; | 4053 | name_len *= 2; |
3962 | } else { /* BB improve the check for buffer overruns BB */ | 4054 | } else { /* BB improve the check for buffer overruns BB */ |
@@ -4082,7 +4174,8 @@ QEARetry: | |||
4082 | int | 4174 | int |
4083 | CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName, | 4175 | CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName, |
4084 | const char * ea_name, const void * ea_value, | 4176 | const char * ea_name, const void * ea_value, |
4085 | const __u16 ea_value_len, const struct nls_table *nls_codepage) | 4177 | const __u16 ea_value_len, const struct nls_table *nls_codepage, |
4178 | int remap) | ||
4086 | { | 4179 | { |
4087 | struct smb_com_transaction2_spi_req *pSMB = NULL; | 4180 | struct smb_com_transaction2_spi_req *pSMB = NULL; |
4088 | struct smb_com_transaction2_spi_rsp *pSMBr = NULL; | 4181 | struct smb_com_transaction2_spi_rsp *pSMBr = NULL; |
@@ -4101,9 +4194,8 @@ SetEARetry: | |||
4101 | 4194 | ||
4102 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 4195 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
4103 | name_len = | 4196 | name_len = |
4104 | cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX | 4197 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, |
4105 | /* find define for this maxpathcomponent */ | 4198 | PATH_MAX, nls_codepage, remap); |
4106 | , nls_codepage); | ||
4107 | name_len++; /* trailing null */ | 4199 | name_len++; /* trailing null */ |
4108 | name_len *= 2; | 4200 | name_len *= 2; |
4109 | } else { /* BB improve the check for buffer overruns BB */ | 4201 | } else { /* BB improve the check for buffer overruns BB */ |