aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifssmb.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r--fs/cifs/cifssmb.c218
1 files changed, 63 insertions, 155 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 9409524e4bf8..30bbe448e260 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/cifssmb.c 2 * fs/cifs/cifssmb.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2007 4 * Copyright (C) International Business Machines Corp., 2002,2008
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * Contains the routines for constructing the SMB PDUs themselves 7 * Contains the routines for constructing the SMB PDUs themselves
@@ -102,10 +102,12 @@ static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
102 to this tcon */ 102 to this tcon */
103} 103}
104 104
105/* If the return code is zero, this function must fill in request_buf pointer */ 105/* Allocate and return pointer to an SMB request buffer, and set basic
106 SMB information in the SMB header. If the return code is zero, this
107 function must have filled in request_buf pointer */
106static int 108static int
107small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, 109small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
108 void **request_buf /* returned */) 110 void **request_buf)
109{ 111{
110 int rc = 0; 112 int rc = 0;
111 113
@@ -363,7 +365,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
363 *response_buf = *request_buf; 365 *response_buf = *request_buf;
364 366
365 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon, 367 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,
366 wct /*wct */ ); 368 wct);
367 369
368 if (tcon != NULL) 370 if (tcon != NULL)
369 cifs_stats_inc(&tcon->num_smbs_sent); 371 cifs_stats_inc(&tcon->num_smbs_sent);
@@ -523,7 +525,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
523 if (remain >= (MIN_TZ_ADJ / 2)) 525 if (remain >= (MIN_TZ_ADJ / 2))
524 result += MIN_TZ_ADJ; 526 result += MIN_TZ_ADJ;
525 if (val < 0) 527 if (val < 0)
526 result = - result; 528 result = -result;
527 server->timeAdj = result; 529 server->timeAdj = result;
528 } else { 530 } else {
529 server->timeAdj = (int)tmp; 531 server->timeAdj = (int)tmp;
@@ -600,7 +602,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
600 server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize), 602 server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize),
601 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); 603 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
602 server->maxRw = le32_to_cpu(pSMBr->MaxRawSize); 604 server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
603 cFYI(0, ("Max buf = %d", ses->server->maxBuf)); 605 cFYI(DBG2, ("Max buf = %d", ses->server->maxBuf));
604 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey); 606 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
605 server->capabilities = le32_to_cpu(pSMBr->Capabilities); 607 server->capabilities = le32_to_cpu(pSMBr->Capabilities);
606 server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone); 608 server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);
@@ -868,9 +870,8 @@ PsxDelete:
868 pSMB->ByteCount = cpu_to_le16(byte_count); 870 pSMB->ByteCount = cpu_to_le16(byte_count);
869 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 871 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
870 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 872 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
871 if (rc) { 873 if (rc)
872 cFYI(1, ("Posix delete returned %d", rc)); 874 cFYI(1, ("Posix delete returned %d", rc));
873 }
874 cifs_buf_release(pSMB); 875 cifs_buf_release(pSMB);
875 876
876 cifs_stats_inc(&tcon->num_deletes); 877 cifs_stats_inc(&tcon->num_deletes);
@@ -916,9 +917,8 @@ DelFileRetry:
916 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 917 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
917 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 918 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
918 cifs_stats_inc(&tcon->num_deletes); 919 cifs_stats_inc(&tcon->num_deletes);
919 if (rc) { 920 if (rc)
920 cFYI(1, ("Error in RMFile = %d", rc)); 921 cFYI(1, ("Error in RMFile = %d", rc));
921 }
922 922
923 cifs_buf_release(pSMB); 923 cifs_buf_release(pSMB);
924 if (rc == -EAGAIN) 924 if (rc == -EAGAIN)
@@ -961,9 +961,8 @@ RmDirRetry:
961 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 961 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
962 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 962 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
963 cifs_stats_inc(&tcon->num_rmdirs); 963 cifs_stats_inc(&tcon->num_rmdirs);
964 if (rc) { 964 if (rc)
965 cFYI(1, ("Error in RMDir = %d", rc)); 965 cFYI(1, ("Error in RMDir = %d", rc));
966 }
967 966
968 cifs_buf_release(pSMB); 967 cifs_buf_release(pSMB);
969 if (rc == -EAGAIN) 968 if (rc == -EAGAIN)
@@ -1005,9 +1004,8 @@ MkDirRetry:
1005 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1004 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1006 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1005 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1007 cifs_stats_inc(&tcon->num_mkdirs); 1006 cifs_stats_inc(&tcon->num_mkdirs);
1008 if (rc) { 1007 if (rc)
1009 cFYI(1, ("Error in Mkdir = %d", rc)); 1008 cFYI(1, ("Error in Mkdir = %d", rc));
1010 }
1011 1009
1012 cifs_buf_release(pSMB); 1010 cifs_buf_release(pSMB);
1013 if (rc == -EAGAIN) 1011 if (rc == -EAGAIN)
@@ -1017,7 +1015,7 @@ MkDirRetry:
1017 1015
1018int 1016int
1019CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags, 1017CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
1020 __u64 mode, __u16 * netfid, FILE_UNIX_BASIC_INFO *pRetData, 1018 __u64 mode, __u16 *netfid, FILE_UNIX_BASIC_INFO *pRetData,
1021 __u32 *pOplock, const char *name, 1019 __u32 *pOplock, const char *name,
1022 const struct nls_table *nls_codepage, int remap) 1020 const struct nls_table *nls_codepage, int remap)
1023{ 1021{
@@ -1027,8 +1025,8 @@ CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
1027 int rc = 0; 1025 int rc = 0;
1028 int bytes_returned = 0; 1026 int bytes_returned = 0;
1029 __u16 params, param_offset, offset, byte_count, count; 1027 __u16 params, param_offset, offset, byte_count, count;
1030 OPEN_PSX_REQ * pdata; 1028 OPEN_PSX_REQ *pdata;
1031 OPEN_PSX_RSP * psx_rsp; 1029 OPEN_PSX_RSP *psx_rsp;
1032 1030
1033 cFYI(1, ("In POSIX Create")); 1031 cFYI(1, ("In POSIX Create"));
1034PsxCreat: 1032PsxCreat:
@@ -1110,9 +1108,7 @@ PsxCreat:
1110 /* check to make sure response data is there */ 1108 /* check to make sure response data is there */
1111 if (psx_rsp->ReturnedLevel != cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC)) { 1109 if (psx_rsp->ReturnedLevel != cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC)) {
1112 pRetData->Type = cpu_to_le32(-1); /* unknown */ 1110 pRetData->Type = cpu_to_le32(-1); /* unknown */
1113#ifdef CONFIG_CIFS_DEBUG2 1111 cFYI(DBG2, ("unknown type"));
1114 cFYI(1, ("unknown type"));
1115#endif
1116 } else { 1112 } else {
1117 if (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP) 1113 if (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP)
1118 + sizeof(FILE_UNIX_BASIC_INFO)) { 1114 + sizeof(FILE_UNIX_BASIC_INFO)) {
@@ -1169,8 +1165,8 @@ static __u16 convert_disposition(int disposition)
1169int 1165int
1170SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, 1166SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
1171 const char *fileName, const int openDisposition, 1167 const char *fileName, const int openDisposition,
1172 const int access_flags, const int create_options, __u16 * netfid, 1168 const int access_flags, const int create_options, __u16 *netfid,
1173 int *pOplock, FILE_ALL_INFO * pfile_info, 1169 int *pOplock, FILE_ALL_INFO *pfile_info,
1174 const struct nls_table *nls_codepage, int remap) 1170 const struct nls_table *nls_codepage, int remap)
1175{ 1171{
1176 int rc = -EACCES; 1172 int rc = -EACCES;
@@ -1221,8 +1217,8 @@ OldOpenRetry:
1221 1217
1222 if (create_options & CREATE_OPTION_SPECIAL) 1218 if (create_options & CREATE_OPTION_SPECIAL)
1223 pSMB->FileAttributes = cpu_to_le16(ATTR_SYSTEM); 1219 pSMB->FileAttributes = cpu_to_le16(ATTR_SYSTEM);
1224 else 1220 else /* BB FIXME BB */
1225 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); /* BB FIXME */ 1221 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/);
1226 1222
1227 /* if ((omode & S_IWUGO) == 0) 1223 /* if ((omode & S_IWUGO) == 0)
1228 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/ 1224 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/
@@ -1284,8 +1280,8 @@ OldOpenRetry:
1284int 1280int
1285CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, 1281CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
1286 const char *fileName, const int openDisposition, 1282 const char *fileName, const int openDisposition,
1287 const int access_flags, const int create_options, __u16 * netfid, 1283 const int access_flags, const int create_options, __u16 *netfid,
1288 int *pOplock, FILE_ALL_INFO * pfile_info, 1284 int *pOplock, FILE_ALL_INFO *pfile_info,
1289 const struct nls_table *nls_codepage, int remap) 1285 const struct nls_table *nls_codepage, int remap)
1290{ 1286{
1291 int rc = -EACCES; 1287 int rc = -EACCES;
@@ -1556,9 +1552,9 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1556 } /* else setting file size with write of zero bytes */ 1552 } /* else setting file size with write of zero bytes */
1557 if (wct == 14) 1553 if (wct == 14)
1558 byte_count = bytes_sent + 1; /* pad */ 1554 byte_count = bytes_sent + 1; /* pad */
1559 else /* wct == 12 */ { 1555 else /* wct == 12 */
1560 byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */ 1556 byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */
1561 } 1557
1562 pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF); 1558 pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF);
1563 pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16); 1559 pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16);
1564 pSMB->hdr.smb_buf_length += byte_count; 1560 pSMB->hdr.smb_buf_length += byte_count;
@@ -1663,7 +1659,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1663 rc = -EIO; 1659 rc = -EIO;
1664 *nbytes = 0; 1660 *nbytes = 0;
1665 } else { 1661 } else {
1666 WRITE_RSP * pSMBr = (WRITE_RSP *)iov[0].iov_base; 1662 WRITE_RSP *pSMBr = (WRITE_RSP *)iov[0].iov_base;
1667 *nbytes = le16_to_cpu(pSMBr->CountHigh); 1663 *nbytes = le16_to_cpu(pSMBr->CountHigh);
1668 *nbytes = (*nbytes) << 16; 1664 *nbytes = (*nbytes) << 16;
1669 *nbytes += le16_to_cpu(pSMBr->Count); 1665 *nbytes += le16_to_cpu(pSMBr->Count);
@@ -1744,9 +1740,8 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1744 /* SMB buffer freed by function above */ 1740 /* SMB buffer freed by function above */
1745 } 1741 }
1746 cifs_stats_inc(&tcon->num_locks); 1742 cifs_stats_inc(&tcon->num_locks);
1747 if (rc) { 1743 if (rc)
1748 cFYI(1, ("Send error in Lock = %d", rc)); 1744 cFYI(1, ("Send error in Lock = %d", rc));
1749 }
1750 1745
1751 /* Note: On -EAGAIN error only caller can retry on handle based calls 1746 /* Note: On -EAGAIN error only caller can retry on handle based calls
1752 since file handle passed in no longer valid */ 1747 since file handle passed in no longer valid */
@@ -1791,7 +1786,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1791 1786
1792 count = sizeof(struct cifs_posix_lock); 1787 count = sizeof(struct cifs_posix_lock);
1793 pSMB->MaxParameterCount = cpu_to_le16(2); 1788 pSMB->MaxParameterCount = cpu_to_le16(2);
1794 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 1789 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */
1795 pSMB->SetupCount = 1; 1790 pSMB->SetupCount = 1;
1796 pSMB->Reserved3 = 0; 1791 pSMB->Reserved3 = 0;
1797 if (get_flag) 1792 if (get_flag)
@@ -1972,9 +1967,8 @@ renameRetry:
1972 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1967 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1973 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1968 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1974 cifs_stats_inc(&tcon->num_renames); 1969 cifs_stats_inc(&tcon->num_renames);
1975 if (rc) { 1970 if (rc)
1976 cFYI(1, ("Send error in rename = %d", rc)); 1971 cFYI(1, ("Send error in rename = %d", rc));
1977 }
1978 1972
1979 cifs_buf_release(pSMB); 1973 cifs_buf_release(pSMB);
1980 1974
@@ -2016,7 +2010,7 @@ int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon,
2016 data_offset = (char *) (&pSMB->hdr.Protocol) + offset; 2010 data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
2017 rename_info = (struct set_file_rename *) data_offset; 2011 rename_info = (struct set_file_rename *) data_offset;
2018 pSMB->MaxParameterCount = cpu_to_le16(2); 2012 pSMB->MaxParameterCount = cpu_to_le16(2);
2019 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 2013 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */
2020 pSMB->SetupCount = 1; 2014 pSMB->SetupCount = 1;
2021 pSMB->Reserved3 = 0; 2015 pSMB->Reserved3 = 0;
2022 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); 2016 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
@@ -2052,9 +2046,8 @@ int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon,
2052 rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB, 2046 rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB,
2053 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2047 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2054 cifs_stats_inc(&pTcon->num_t2renames); 2048 cifs_stats_inc(&pTcon->num_t2renames);
2055 if (rc) { 2049 if (rc)
2056 cFYI(1, ("Send error in Rename (by file handle) = %d", rc)); 2050 cFYI(1, ("Send error in Rename (by file handle) = %d", rc));
2057 }
2058 2051
2059 cifs_buf_release(pSMB); 2052 cifs_buf_release(pSMB);
2060 2053
@@ -2211,9 +2204,8 @@ createSymLinkRetry:
2211 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2204 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2212 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2205 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2213 cifs_stats_inc(&tcon->num_symlinks); 2206 cifs_stats_inc(&tcon->num_symlinks);
2214 if (rc) { 2207 if (rc)
2215 cFYI(1, ("Send error in SetPathInfo create symlink = %d", rc)); 2208 cFYI(1, ("Send error in SetPathInfo create symlink = %d", rc));
2216 }
2217 2209
2218 if (pSMB) 2210 if (pSMB)
2219 cifs_buf_release(pSMB); 2211 cifs_buf_release(pSMB);
@@ -2299,9 +2291,8 @@ createHardLinkRetry:
2299 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2291 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2300 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2292 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2301 cifs_stats_inc(&tcon->num_hardlinks); 2293 cifs_stats_inc(&tcon->num_hardlinks);
2302 if (rc) { 2294 if (rc)
2303 cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc)); 2295 cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc));
2304 }
2305 2296
2306 cifs_buf_release(pSMB); 2297 cifs_buf_release(pSMB);
2307 if (rc == -EAGAIN) 2298 if (rc == -EAGAIN)
@@ -2370,9 +2361,9 @@ winCreateHardLinkRetry:
2370 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2361 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2371 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2362 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2372 cifs_stats_inc(&tcon->num_hardlinks); 2363 cifs_stats_inc(&tcon->num_hardlinks);
2373 if (rc) { 2364 if (rc)
2374 cFYI(1, ("Send error in hard link (NT rename) = %d", rc)); 2365 cFYI(1, ("Send error in hard link (NT rename) = %d", rc));
2375 } 2366
2376 cifs_buf_release(pSMB); 2367 cifs_buf_release(pSMB);
2377 if (rc == -EAGAIN) 2368 if (rc == -EAGAIN)
2378 goto winCreateHardLinkRetry; 2369 goto winCreateHardLinkRetry;
@@ -2968,9 +2959,8 @@ setAclRetry:
2968 pSMB->ByteCount = cpu_to_le16(byte_count); 2959 pSMB->ByteCount = cpu_to_le16(byte_count);
2969 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2960 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2970 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2961 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2971 if (rc) { 2962 if (rc)
2972 cFYI(1, ("Set POSIX ACL returned %d", rc)); 2963 cFYI(1, ("Set POSIX ACL returned %d", rc));
2973 }
2974 2964
2975setACLerrorExit: 2965setACLerrorExit:
2976 cifs_buf_release(pSMB); 2966 cifs_buf_release(pSMB);
@@ -2982,7 +2972,7 @@ setACLerrorExit:
2982/* BB fix tabs in this function FIXME BB */ 2972/* BB fix tabs in this function FIXME BB */
2983int 2973int
2984CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon, 2974CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
2985 const int netfid, __u64 * pExtAttrBits, __u64 *pMask) 2975 const int netfid, __u64 *pExtAttrBits, __u64 *pMask)
2986{ 2976{
2987 int rc = 0; 2977 int rc = 0;
2988 struct smb_t2_qfi_req *pSMB = NULL; 2978 struct smb_t2_qfi_req *pSMB = NULL;
@@ -3000,7 +2990,7 @@ GetExtAttrRetry:
3000 if (rc) 2990 if (rc)
3001 return rc; 2991 return rc;
3002 2992
3003 params = 2 /* level */ +2 /* fid */; 2993 params = 2 /* level */ + 2 /* fid */;
3004 pSMB->t2.TotalDataCount = 0; 2994 pSMB->t2.TotalDataCount = 0;
3005 pSMB->t2.MaxParameterCount = cpu_to_le16(4); 2995 pSMB->t2.MaxParameterCount = cpu_to_le16(4);
3006 /* BB find exact max data count below from sess structure BB */ 2996 /* BB find exact max data count below from sess structure BB */
@@ -3071,7 +3061,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3071{ 3061{
3072 int rc = 0; 3062 int rc = 0;
3073 int buf_type = 0; 3063 int buf_type = 0;
3074 QUERY_SEC_DESC_REQ * pSMB; 3064 QUERY_SEC_DESC_REQ *pSMB;
3075 struct kvec iov[1]; 3065 struct kvec iov[1];
3076 3066
3077 cFYI(1, ("GetCifsACL")); 3067 cFYI(1, ("GetCifsACL"));
@@ -3101,7 +3091,7 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
3101 if (rc) { 3091 if (rc) {
3102 cFYI(1, ("Send error in QuerySecDesc = %d", rc)); 3092 cFYI(1, ("Send error in QuerySecDesc = %d", rc));
3103 } else { /* decode response */ 3093 } else { /* decode response */
3104 __le32 * parm; 3094 __le32 *parm;
3105 __u32 parm_len; 3095 __u32 parm_len;
3106 __u32 acl_len; 3096 __u32 acl_len;
3107 struct smb_com_ntransact_rsp *pSMBr; 3097 struct smb_com_ntransact_rsp *pSMBr;
@@ -3230,8 +3220,8 @@ int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon,
3230 FILE_ALL_INFO *pFinfo, 3220 FILE_ALL_INFO *pFinfo,
3231 const struct nls_table *nls_codepage, int remap) 3221 const struct nls_table *nls_codepage, int remap)
3232{ 3222{
3233 QUERY_INFORMATION_REQ * pSMB; 3223 QUERY_INFORMATION_REQ *pSMB;
3234 QUERY_INFORMATION_RSP * pSMBr; 3224 QUERY_INFORMATION_RSP *pSMBr;
3235 int rc = 0; 3225 int rc = 0;
3236 int bytes_returned; 3226 int bytes_returned;
3237 int name_len; 3227 int name_len;
@@ -3263,9 +3253,11 @@ QInfRetry:
3263 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 3253 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
3264 if (rc) { 3254 if (rc) {
3265 cFYI(1, ("Send error in QueryInfo = %d", rc)); 3255 cFYI(1, ("Send error in QueryInfo = %d", rc));
3266 } else if (pFinfo) { /* decode response */ 3256 } else if (pFinfo) {
3267 struct timespec ts; 3257 struct timespec ts;
3268 __u32 time = le32_to_cpu(pSMBr->last_write_time); 3258 __u32 time = le32_to_cpu(pSMBr->last_write_time);
3259
3260 /* decode response */
3269 /* BB FIXME - add time zone adjustment BB */ 3261 /* BB FIXME - add time zone adjustment BB */
3270 memset(pFinfo, 0, sizeof(FILE_ALL_INFO)); 3262 memset(pFinfo, 0, sizeof(FILE_ALL_INFO));
3271 ts.tv_nsec = 0; 3263 ts.tv_nsec = 0;
@@ -3296,7 +3288,7 @@ QInfRetry:
3296int 3288int
3297CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 3289CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
3298 const unsigned char *searchName, 3290 const unsigned char *searchName,
3299 FILE_ALL_INFO * pFindData, 3291 FILE_ALL_INFO *pFindData,
3300 int legacy /* old style infolevel */, 3292 int legacy /* old style infolevel */,
3301 const struct nls_table *nls_codepage, int remap) 3293 const struct nls_table *nls_codepage, int remap)
3302{ 3294{
@@ -3371,10 +3363,12 @@ QPathInfoRetry:
3371 else if (pFindData) { 3363 else if (pFindData) {
3372 int size; 3364 int size;
3373 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3365 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
3374 if (legacy) /* we do not read the last field, EAsize, 3366
3375 fortunately since it varies by subdialect 3367 /* On legacy responses we do not read the last field,
3376 and on Set vs. Get, is two bytes or 4 3368 EAsize, fortunately since it varies by subdialect and
3377 bytes depending but we don't care here */ 3369 also note it differs on Set vs. Get, ie two bytes or 4
3370 bytes depending but we don't care here */
3371 if (legacy)
3378 size = sizeof(FILE_INFO_STANDARD); 3372 size = sizeof(FILE_INFO_STANDARD);
3379 else 3373 else
3380 size = sizeof(FILE_ALL_INFO); 3374 size = sizeof(FILE_ALL_INFO);
@@ -3476,85 +3470,6 @@ UnixQPathInfoRetry:
3476 return rc; 3470 return rc;
3477} 3471}
3478 3472
3479#if 0 /* function unused at present */
3480int CIFSFindSingle(const int xid, struct cifsTconInfo *tcon,
3481 const char *searchName, FILE_ALL_INFO * findData,
3482 const struct nls_table *nls_codepage)
3483{
3484/* level 257 SMB_ */
3485 TRANSACTION2_FFIRST_REQ *pSMB = NULL;
3486 TRANSACTION2_FFIRST_RSP *pSMBr = NULL;
3487 int rc = 0;
3488 int bytes_returned;
3489 int name_len;
3490 __u16 params, byte_count;
3491
3492 cFYI(1, ("In FindUnique"));
3493findUniqueRetry:
3494 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
3495 (void **) &pSMBr);
3496 if (rc)
3497 return rc;
3498
3499 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3500 name_len =
3501 cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
3502 PATH_MAX, nls_codepage);
3503 name_len++; /* trailing null */
3504 name_len *= 2;
3505 } else { /* BB improve the check for buffer overruns BB */
3506 name_len = strnlen(searchName, PATH_MAX);
3507 name_len++; /* trailing null */
3508 strncpy(pSMB->FileName, searchName, name_len);
3509 }
3510
3511 params = 12 + name_len /* includes null */ ;
3512 pSMB->TotalDataCount = 0; /* no EAs */
3513 pSMB->MaxParameterCount = cpu_to_le16(2);
3514 pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */
3515 pSMB->MaxSetupCount = 0;
3516 pSMB->Reserved = 0;
3517 pSMB->Flags = 0;
3518 pSMB->Timeout = 0;
3519 pSMB->Reserved2 = 0;
3520 pSMB->ParameterOffset = cpu_to_le16(
3521 offsetof(struct smb_com_transaction2_ffirst_req, InformationLevel)-4);
3522 pSMB->DataCount = 0;
3523 pSMB->DataOffset = 0;
3524 pSMB->SetupCount = 1; /* one byte, no need to le convert */
3525 pSMB->Reserved3 = 0;
3526 pSMB->SubCommand = cpu_to_le16(TRANS2_FIND_FIRST);
3527 byte_count = params + 1 /* pad */ ;
3528 pSMB->TotalParameterCount = cpu_to_le16(params);
3529 pSMB->ParameterCount = pSMB->TotalParameterCount;
3530 pSMB->SearchAttributes =
3531 cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM |
3532 ATTR_DIRECTORY);
3533 pSMB->SearchCount = cpu_to_le16(16); /* BB increase */
3534 pSMB->SearchFlags = cpu_to_le16(1);
3535 pSMB->InformationLevel = cpu_to_le16(SMB_FIND_FILE_DIRECTORY_INFO);
3536 pSMB->SearchStorageType = 0; /* BB what should we set this to? BB */
3537 pSMB->hdr.smb_buf_length += byte_count;
3538 pSMB->ByteCount = cpu_to_le16(byte_count);
3539
3540 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
3541 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
3542
3543 if (rc) {
3544 cFYI(1, ("Send error in FindFileDirInfo = %d", rc));
3545 } else { /* decode response */
3546 cifs_stats_inc(&tcon->num_ffirst);
3547 /* BB fill in */
3548 }
3549
3550 cifs_buf_release(pSMB);
3551 if (rc == -EAGAIN)
3552 goto findUniqueRetry;
3553
3554 return rc;
3555}
3556#endif /* end unused (temporarily) function */
3557
3558/* xid, tcon, searchName and codepage are input parms, rest are returned */ 3473/* xid, tcon, searchName and codepage are input parms, rest are returned */
3559int 3474int
3560CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, 3475CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
@@ -3566,7 +3481,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
3566/* level 257 SMB_ */ 3481/* level 257 SMB_ */
3567 TRANSACTION2_FFIRST_REQ *pSMB = NULL; 3482 TRANSACTION2_FFIRST_REQ *pSMB = NULL;
3568 TRANSACTION2_FFIRST_RSP *pSMBr = NULL; 3483 TRANSACTION2_FFIRST_RSP *pSMBr = NULL;
3569 T2_FFIRST_RSP_PARMS * parms; 3484 T2_FFIRST_RSP_PARMS *parms;
3570 int rc = 0; 3485 int rc = 0;
3571 int bytes_returned = 0; 3486 int bytes_returned = 0;
3572 int name_len; 3487 int name_len;
@@ -3697,7 +3612,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3697{ 3612{
3698 TRANSACTION2_FNEXT_REQ *pSMB = NULL; 3613 TRANSACTION2_FNEXT_REQ *pSMB = NULL;
3699 TRANSACTION2_FNEXT_RSP *pSMBr = NULL; 3614 TRANSACTION2_FNEXT_RSP *pSMBr = NULL;
3700 T2_FNEXT_RSP_PARMS * parms; 3615 T2_FNEXT_RSP_PARMS *parms;
3701 char *response_data; 3616 char *response_data;
3702 int rc = 0; 3617 int rc = 0;
3703 int bytes_returned, name_len; 3618 int bytes_returned, name_len;
@@ -3836,9 +3751,9 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon,
3836 pSMB->FileID = searchHandle; 3751 pSMB->FileID = searchHandle;
3837 pSMB->ByteCount = 0; 3752 pSMB->ByteCount = 0;
3838 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); 3753 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0);
3839 if (rc) { 3754 if (rc)
3840 cERROR(1, ("Send error in FindClose = %d", rc)); 3755 cERROR(1, ("Send error in FindClose = %d", rc));
3841 } 3756
3842 cifs_stats_inc(&tcon->num_fclose); 3757 cifs_stats_inc(&tcon->num_fclose);
3843 3758
3844 /* Since session is dead, search handle closed on server already */ 3759 /* Since session is dead, search handle closed on server already */
@@ -3851,7 +3766,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon,
3851int 3766int
3852CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, 3767CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
3853 const unsigned char *searchName, 3768 const unsigned char *searchName,
3854 __u64 * inode_number, 3769 __u64 *inode_number,
3855 const struct nls_table *nls_codepage, int remap) 3770 const struct nls_table *nls_codepage, int remap)
3856{ 3771{
3857 int rc = 0; 3772 int rc = 0;
@@ -4560,9 +4475,8 @@ SETFSUnixRetry:
4560 cERROR(1, ("Send error in SETFSUnixInfo = %d", rc)); 4475 cERROR(1, ("Send error in SETFSUnixInfo = %d", rc));
4561 } else { /* decode response */ 4476 } else { /* decode response */
4562 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 4477 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
4563 if (rc) { 4478 if (rc)
4564 rc = -EIO; /* bad smb */ 4479 rc = -EIO; /* bad smb */
4565 }
4566 } 4480 }
4567 cifs_buf_release(pSMB); 4481 cifs_buf_release(pSMB);
4568 4482
@@ -4744,9 +4658,8 @@ SetEOFRetry:
4744 pSMB->ByteCount = cpu_to_le16(byte_count); 4658 pSMB->ByteCount = cpu_to_le16(byte_count);
4745 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 4659 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
4746 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 4660 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
4747 if (rc) { 4661 if (rc)
4748 cFYI(1, ("SetPathInfo (file size) returned %d", rc)); 4662 cFYI(1, ("SetPathInfo (file size) returned %d", rc));
4749 }
4750 4663
4751 cifs_buf_release(pSMB); 4664 cifs_buf_release(pSMB);
4752 4665
@@ -4897,9 +4810,8 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon,
4897 pSMB->ByteCount = cpu_to_le16(byte_count); 4810 pSMB->ByteCount = cpu_to_le16(byte_count);
4898 memcpy(data_offset, data, sizeof(FILE_BASIC_INFO)); 4811 memcpy(data_offset, data, sizeof(FILE_BASIC_INFO));
4899 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); 4812 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0);
4900 if (rc) { 4813 if (rc)
4901 cFYI(1, ("Send error in Set Time (SetFileInfo) = %d", rc)); 4814 cFYI(1, ("Send error in Set Time (SetFileInfo) = %d", rc));
4902 }
4903 4815
4904 /* Note: On -EAGAIN error only caller can retry on handle based calls 4816 /* Note: On -EAGAIN error only caller can retry on handle based calls
4905 since file handle passed in no longer valid */ 4817 since file handle passed in no longer valid */
@@ -4975,9 +4887,8 @@ SetTimesRetry:
4975 pSMB->ByteCount = cpu_to_le16(byte_count); 4887 pSMB->ByteCount = cpu_to_le16(byte_count);
4976 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 4888 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
4977 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 4889 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
4978 if (rc) { 4890 if (rc)
4979 cFYI(1, ("SetPathInfo (times) returned %d", rc)); 4891 cFYI(1, ("SetPathInfo (times) returned %d", rc));
4980 }
4981 4892
4982 cifs_buf_release(pSMB); 4893 cifs_buf_release(pSMB);
4983 4894
@@ -5027,9 +4938,8 @@ SetAttrLgcyRetry:
5027 pSMB->ByteCount = cpu_to_le16(name_len + 1); 4938 pSMB->ByteCount = cpu_to_le16(name_len + 1);
5028 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 4939 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
5029 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 4940 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
5030 if (rc) { 4941 if (rc)
5031 cFYI(1, ("Error in LegacySetAttr = %d", rc)); 4942 cFYI(1, ("Error in LegacySetAttr = %d", rc));
5032 }
5033 4943
5034 cifs_buf_release(pSMB); 4944 cifs_buf_release(pSMB);
5035 4945
@@ -5138,9 +5048,8 @@ setPermsRetry:
5138 pSMB->ByteCount = cpu_to_le16(byte_count); 5048 pSMB->ByteCount = cpu_to_le16(byte_count);
5139 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 5049 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
5140 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 5050 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
5141 if (rc) { 5051 if (rc)
5142 cFYI(1, ("SetPathInfo (perms) returned %d", rc)); 5052 cFYI(1, ("SetPathInfo (perms) returned %d", rc));
5143 }
5144 5053
5145 if (pSMB) 5054 if (pSMB)
5146 cifs_buf_release(pSMB); 5055 cifs_buf_release(pSMB);
@@ -5615,9 +5524,8 @@ SetEARetry:
5615 pSMB->ByteCount = cpu_to_le16(byte_count); 5524 pSMB->ByteCount = cpu_to_le16(byte_count);
5616 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 5525 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
5617 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 5526 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
5618 if (rc) { 5527 if (rc)
5619 cFYI(1, ("SetPathInfo (EA) returned %d", rc)); 5528 cFYI(1, ("SetPathInfo (EA) returned %d", rc));
5620 }
5621 5529
5622 cifs_buf_release(pSMB); 5530 cifs_buf_release(pSMB);
5623 5531