31 #include <linux/kernel.h>
33 #include <linux/slab.h>
38 #include <asm/uaccess.h>
47 #ifdef CONFIG_CIFS_POSIX
52 #ifdef CONFIG_CIFS_WEAK_PW_HASH
53 {LANMAN_PROT,
"\2LM1.2X002"},
54 {LANMAN2_PROT,
"\2LANMAN2.1"},
65 #ifdef CONFIG_CIFS_WEAK_PW_HASH
66 {LANMAN_PROT,
"\2LM1.2X002"},
67 {LANMAN2_PROT,
"\2LANMAN2.1"},
75 #ifdef CONFIG_CIFS_POSIX
76 #ifdef CONFIG_CIFS_WEAK_PW_HASH
77 #define CIFS_NUM_PROT 4
79 #define CIFS_NUM_PROT 2
82 #ifdef CONFIG_CIFS_WEAK_PW_HASH
83 #define CIFS_NUM_PROT 3
85 #define CIFS_NUM_PROT 1
116 cifs_reconnect_tcon(
struct cifs_tcon *tcon,
int smb_command)
142 cFYI(1,
"can not send cmd %d while umounting",
166 cFYI(1,
"gave up waiting on reconnect in smb_init");
194 cFYI(1,
"reconnect tcon rc = %d", rc);
221 switch (smb_command) {
238 small_smb_init(
int smb_command,
int wct,
struct cifs_tcon *tcon,
243 rc = cifs_reconnect_tcon(tcon, smb_command);
248 if (*request_buf ==
NULL) {
264 struct cifs_ses *ses,
void **request_buf)
269 rc = small_smb_init(smb_command, wct,
NULL, request_buf);
273 buffer = (
struct smb_hdr *)*request_buf;
290 __smb_init(
int smb_command,
int wct,
struct cifs_tcon *tcon,
291 void **request_buf,
void **response_buf)
294 if (*request_buf ==
NULL) {
303 *response_buf = *request_buf;
316 smb_init(
int smb_command,
int wct,
struct cifs_tcon *tcon,
317 void **request_buf,
void **response_buf)
321 rc = cifs_reconnect_tcon(tcon, smb_command);
325 return __smb_init(smb_command, wct, tcon, request_buf, response_buf);
329 smb_init_no_reconnect(
int smb_command,
int wct,
struct cifs_tcon *tcon,
330 void **request_buf,
void **response_buf)
335 return __smb_init(smb_command, wct, tcon, request_buf, response_buf);
338 static int validate_t2(
struct smb_t2_rsp *pSMB)
343 if (pSMB->
hdr.WordCount < 10)
347 if (get_unaligned_le16(&pSMB->
t2_rsp.ParameterOffset) > 1024 ||
348 get_unaligned_le16(&pSMB->
t2_rsp.DataOffset) > 1024)
351 total_size = get_unaligned_le16(&pSMB->
t2_rsp.ParameterCount);
352 if (total_size >= 512)
358 total_size += get_unaligned_le16(&pSMB->
t2_rsp.DataCount);
359 if (total_size > get_bcc(&pSMB->
hdr) ||
374 NEGOTIATE_RSP *pSMBr;
380 unsigned int secFlags;
389 (
void **) &pSMB, (
void **) &pSMBr);
399 cFYI(1,
"secFlags 0x%x", secFlags);
401 pSMB->hdr.Mid = get_next_mid(server);
407 cFYI(1,
"Kerberos only mechanism, enable extended security");
412 cFYI(1,
"NTLMSSP only mechanism, enable extended security");
418 strncpy(pSMB->DialectsArray+count, protocols[i].name, 16);
422 inc_rfc1001_len(pSMB, count);
426 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
439 #ifdef CONFIG_CIFS_WEAK_PW_HASH
440 }
else if ((pSMBr->hdr.WordCount == 13)
441 && ((server->
dialect == LANMAN_PROT)
442 || (server->
dialect == LANMAN2_PROT))) {
450 cERROR(1,
"mount failed weak security disabled"
451 " in /proc/fs/cifs/SecurityFlags");
459 set_credits(server, server->
maxReq);
484 rsp->SrvTime.
Time, 0);
485 cFYI(1,
"SrvTime %d sec since 1970 (utc: %d) diff: %d",
486 (
int)ts.
tv_sec, (
int)utc.tv_sec,
487 (
int)(utc.tv_sec - ts.
tv_sec));
501 cFYI(1,
"server->timeAdj: %d seconds", server->
timeAdj);
516 cFYI(1,
"LANMAN negotiated");
521 }
else if (pSMBr->hdr.WordCount == 13) {
522 cERROR(1,
"mount failed, cifs module not built "
523 "with CIFS_WEAK_PW_HASH support");
527 }
else if (pSMBr->hdr.WordCount != 17) {
533 server->
sec_mode = pSMBr->SecurityMode;
535 cFYI(1,
"share mode security");
538 #ifdef CONFIG_CIFS_WEAK_PW_HASH
541 cERROR(1,
"Server requests plain text password"
542 " but client support disabled");
558 cERROR(1,
"Invalid security type");
567 set_credits(server, server->
maxReq);
580 (pSMBr->EncryptionKeyLength == 0)) {
582 count = get_bcc(&pSMBr->hdr);
591 pSMBr->u.extended_response.
593 cFYI(1,
"server UID changed");
595 pSMBr->u.extended_response.GUID,
601 pSMBr->u.extended_response.GUID, 16);
630 #ifdef CONFIG_CIFS_WEAK_PW_HASH
636 cFYI(1,
"Signing disabled");
638 cERROR(1,
"Server requires "
639 "packet signing to be enabled in "
640 "/proc/fs/cifs/SecurityFlags.");
647 cFYI(1,
"Must sign - secFlags 0x%x", secFlags);
650 cERROR(1,
"signing required but server lacks support");
664 cFYI(1,
"negprot rc %d", rc);
674 cFYI(1,
"In tree disconnect");
690 (
void **)&smb_buffer);
696 cFYI(1,
"Tree disconnect failed %d", rc);
731 cFYI(1,
"In echo request");
738 smb->hdr.Tid = 0xffff;
739 smb->hdr.WordCount = 1;
740 put_unaligned_le16(1, &smb->EchoCount);
741 put_bcc(1, &smb->hdr);
743 inc_rfc1001_len(smb, 3);
750 cFYI(1,
"Echo request failed: %d", rc);
760 LOGOFF_ANDX_REQ *pSMB;
763 cFYI(1,
"In SMBLogoff for session disconnect");
775 goto session_already_dead;
783 pSMB->hdr.Mid = get_next_mid(ses->
server);
785 if (ses->
server->sec_mode &
789 pSMB->hdr.Uid = ses->
Suid;
791 pSMB->AndXCommand = 0xFF;
793 session_already_dead:
807 const struct nls_table *nls_codepage,
int remap)
809 TRANSACTION2_SPI_REQ *pSMB =
NULL;
810 TRANSACTION2_SPI_RSP *pSMBr =
NULL;
814 int bytes_returned = 0;
817 cFYI(1,
"In POSIX delete");
833 strncpy(pSMB->FileName, fileName, name_len);
838 pSMB->MaxDataCount = 0;
839 pSMB->MaxSetupCount = 0;
846 offset = param_offset +
params;
853 pSMB->SetupCount = 1;
861 pSMB->TotalParameterCount = pSMB->ParameterCount;
864 inc_rfc1001_len(pSMB, byte_count);
867 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
869 cFYI(1,
"Posix delete returned %d", rc);
884 DELETE_FILE_REQ *pSMB =
NULL;
885 DELETE_FILE_RSP *pSMBr =
NULL;
906 strncpy(pSMB->fileName, name, name_len);
908 pSMB->SearchAttributes =
910 pSMB->BufferFormat = 0x04;
911 inc_rfc1001_len(pSMB, name_len + 1);
914 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
917 cFYI(1,
"Error in RMFile = %d", rc);
930 DELETE_DIRECTORY_REQ *pSMB =
NULL;
931 DELETE_DIRECTORY_RSP *pSMBr =
NULL;
937 cFYI(1,
"In CIFSSMBRmDir");
953 strncpy(pSMB->DirName, name, name_len);
956 pSMB->BufferFormat = 0x04;
957 inc_rfc1001_len(pSMB, name_len + 1);
960 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
963 cFYI(1,
"Error in RMDir = %d", rc);
976 CREATE_DIRECTORY_REQ *pSMB =
NULL;
977 CREATE_DIRECTORY_RSP *pSMBr =
NULL;
982 cFYI(1,
"In CIFSSMBMkDir");
998 strncpy(pSMB->DirName, name, name_len);
1001 pSMB->BufferFormat = 0x04;
1002 inc_rfc1001_len(pSMB, name_len + 1);
1005 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
1008 cFYI(1,
"Error in Mkdir = %d", rc);
1019 FILE_UNIX_BASIC_INFO *pRetData,
__u32 *pOplock,
1023 TRANSACTION2_SPI_REQ *pSMB =
NULL;
1024 TRANSACTION2_SPI_RSP *pSMBr =
NULL;
1027 int bytes_returned = 0;
1029 OPEN_PSX_REQ *
pdata;
1030 OPEN_PSX_RSP *psx_rsp;
1032 cFYI(1,
"In POSIX Create");
1048 strncpy(pSMB->FileName, name, name_len);
1052 count =
sizeof(OPEN_PSX_REQ);
1055 pSMB->MaxSetupCount = 0;
1059 pSMB->Reserved2 = 0;
1062 offset = param_offset +
params;
1063 pdata = (OPEN_PSX_REQ *)(((
char *)&pSMB->hdr.Protocol) +
offset);
1068 pSMB->ParameterOffset =
cpu_to_le16(param_offset);
1070 pSMB->SetupCount = 1;
1071 pSMB->Reserved3 = 0;
1073 byte_count = 3 + params +
count;
1077 pSMB->TotalDataCount = pSMB->DataCount;
1078 pSMB->TotalParameterCount = pSMB->ParameterCount;
1080 pSMB->Reserved4 = 0;
1081 inc_rfc1001_len(pSMB, byte_count);
1084 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
1086 cFYI(1,
"Posix create returned %d", rc);
1087 goto psx_create_err;
1090 cFYI(1,
"copying inode info");
1091 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
1093 if (rc || get_bcc(&pSMBr->hdr) <
sizeof(OPEN_PSX_RSP)) {
1095 goto psx_create_err;
1099 psx_rsp = (OPEN_PSX_RSP *)((
char *) &pSMBr->hdr.Protocol
1104 *netfid = psx_rsp->Fid;
1114 if (get_bcc(&pSMBr->hdr) <
sizeof(OPEN_PSX_RSP)
1115 +
sizeof(FILE_UNIX_BASIC_INFO)) {
1116 cERROR(1,
"Open response data too small");
1118 goto psx_create_err;
1120 memcpy((
char *) pRetData,
1121 (
char *)psx_rsp +
sizeof(OPEN_PSX_RSP),
1122 sizeof(FILE_UNIX_BASIC_INFO));
1139 static __u16 convert_disposition(
int disposition)
1143 switch (disposition) {
1163 cFYI(1,
"unknown disposition %d", disposition);
1170 access_flags_to_smbopen_mode(
const int access_flags)
1185 const char *
fileName,
const int openDisposition,
1186 const int access_flags,
const int create_options,
__u16 *netfid,
1187 int *pOplock, FILE_ALL_INFO *pfile_info,
1188 const struct nls_table *nls_codepage,
int remap)
1191 OPENX_REQ *pSMB =
NULL;
1192 OPENX_RSP *pSMBr =
NULL;
1203 pSMB->AndXCommand = 0xFF;
1209 fileName,
PATH_MAX, nls_codepage, remap);
1216 strncpy(pSMB->fileName, fileName, name_len);
1224 pSMB->Mode =
cpu_to_le16(access_flags_to_smbopen_mode(access_flags));
1244 pSMB->OpenFunction =
cpu_to_le16(convert_disposition(openDisposition));
1246 inc_rfc1001_len(pSMB, count);
1251 (
struct smb_hdr *)pSMBr, &bytes_returned, 0);
1254 cFYI(1,
"Error in Open = %d", rc);
1260 *netfid = pSMBr->Fid;
1269 pfile_info->CreationTime = 0;
1270 pfile_info->LastAccessTime = 0;
1271 pfile_info->LastWriteTime = 0;
1272 pfile_info->ChangeTime = 0;
1273 pfile_info->Attributes =
1276 pfile_info->AllocationSize =
1278 pfile_info->EndOfFile = pfile_info->AllocationSize;
1280 pfile_info->DeletePending = 0;
1292 const char *
fileName,
const int openDisposition,
1293 const int access_flags,
const int create_options,
__u16 *netfid,
1294 int *pOplock, FILE_ALL_INFO *pfile_info,
1295 const struct nls_table *nls_codepage,
int remap)
1298 OPEN_REQ *pSMB =
NULL;
1299 OPEN_RSP *pSMBr =
NULL;
1310 pSMB->AndXCommand = 0xFF;
1316 fileName,
PATH_MAX, nls_codepage, remap);
1325 strncpy(pSMB->fileName, fileName, name_len);
1332 pSMB->AllocationSize = 0;
1351 pSMB->CreateDisposition =
cpu_to_le32(openDisposition);
1355 pSMB->SecurityFlags =
1359 inc_rfc1001_len(pSMB, count);
1364 (
struct smb_hdr *)pSMBr, &bytes_returned, 0);
1367 cFYI(1,
"Error in Open = %d", rc);
1369 *pOplock = pSMBr->OplockLevel;
1370 *netfid = pSMBr->Fid;
1376 memcpy((
char *)pfile_info, (
char *)&pSMBr->CreationTime,
1379 pfile_info->AllocationSize = pSMBr->AllocationSize;
1380 pfile_info->EndOfFile = pSMBr->EndOfFile;
1382 pfile_info->DeletePending = 0;
1399 unsigned int rfclen = get_rfc1002_length(server->
smallbuf);
1400 int remaining = rfclen + 4 - server->
total_read;
1403 while (remaining > 0) {
1407 min_t(
unsigned int, remaining,
1426 unsigned int buflen = get_rfc1002_length(buf) + 4;
1428 cFYI(1,
"%s: mid=%llu offset=%llu bytes=%u", __func__,
1436 len =
min_t(
unsigned int, buflen, server->
vals->read_rsp_size) -
1440 rdata->
iov.iov_len = len;
1448 rdata->
result = server->
ops->map_error(buf,
false);
1449 if (rdata->
result != 0) {
1450 cFYI(1,
"%s: server returned error %d", __func__,
1452 return cifs_readv_discard(server, mid);
1457 cFYI(1,
"%s: server returned short header. got=%u expected=%zu",
1459 server->
vals->read_rsp_size);
1461 return cifs_readv_discard(server, mid);
1464 data_offset = server->
ops->read_data_offset(buf) + 4;
1465 if (data_offset < server->total_read) {
1471 cFYI(1,
"%s: data offset (%u) inside read response header",
1472 __func__, data_offset);
1476 cFYI(1,
"%s: data offset (%u) beyond end of smallbuf",
1477 __func__, data_offset);
1479 return cifs_readv_discard(server, mid);
1482 cFYI(1,
"%s: total_read=%u data_offset=%u", __func__,
1489 rdata->
iov.iov_len = len;
1497 rdata->
iov.iov_base =
buf;
1499 cFYI(1,
"0: iov_base=%p iov_len=%zu",
1500 rdata->
iov.iov_base, rdata->
iov.iov_len);
1503 data_len = server->
ops->read_data_length(buf);
1504 if (data_offset + data_len > buflen) {
1507 return cifs_readv_discard(server, mid);
1517 cFYI(1,
"total_read=%u buflen=%u remaining=%u", server->
total_read,
1522 return cifs_readv_discard(server, mid);
1536 .rq_pages = rdata->
pages,
1538 .rq_pagesz = rdata->
pagesz,
1539 .rq_tailsz = rdata->
tailsz };
1541 cFYI(1,
"%s: mid=%llu state=%d result=%d bytes=%u", __func__,
1554 cERROR(1,
"SMB signature verification returned "
1558 task_io_account_read(rdata->
bytes);
1571 add_credits(server, 1, 0);
1585 cFYI(1,
"%s: offset=%llu bytes=%u", __func__,
1592 if ((rdata->
offset >> 32) > 0) {
1605 smb->AndXCommand = 0xFF;
1606 smb->Fid = rdata->
cfile->fid.netfid;
1623 rdata->
iov.iov_base = smb;
1628 cifs_readv_callback, rdata, 0);
1641 unsigned int *
nbytes,
char **
buf,
int *pbuf_type)
1645 READ_RSP *pSMBr =
NULL;
1646 char *pReadData =
NULL;
1648 int resp_buf_type = 0;
1656 cFYI(1,
"Reading %d bytes on fid %d", count, netfid);
1661 if ((offset >> 32) > 0) {
1676 if (tcon->
ses->server ==
NULL)
1679 pSMB->AndXCommand = 0xFF;
1681 pSMB->OffsetLow =
cpu_to_le32(offset & 0xFFFFFFFF);
1685 pSMB->Remaining = 0;
1689 pSMB->ByteCount = 0;
1702 pSMBr = (READ_RSP *)iov[0].iov_base;
1704 cERROR(1,
"Send error in read = %d", rc);
1707 data_length = data_length << 16;
1713 || (data_length > count)) {
1714 cFYI(1,
"bad length %d for count %d",
1715 data_length, count);
1719 pReadData = (
char *) (&pSMBr->hdr.Protocol) +
1726 memcpy(*buf, pReadData, data_length);
1754 const char __user *ubuf,
const int long_op)
1757 WRITE_REQ *pSMB =
NULL;
1758 WRITE_RSP *pSMBr =
NULL;
1759 int bytes_returned, wct;
1778 if ((offset >> 32) > 0) {
1793 if (tcon->
ses->server ==
NULL)
1796 pSMB->AndXCommand = 0xFF;
1798 pSMB->OffsetLow =
cpu_to_le32(offset & 0xFFFFFFFF);
1802 pSMB->Reserved = 0xFFFFFFFF;
1803 pSMB->WriteMode = 0;
1804 pSMB->Remaining = 0;
1817 if (bytes_sent > count)
1822 memcpy(pSMB->Data, buf, bytes_sent);
1828 }
else if (count != 0) {
1834 byte_count = bytes_sent + 1;
1836 byte_count = bytes_sent + 5;
1838 pSMB->DataLengthLow =
cpu_to_le16(bytes_sent & 0xFFFF);
1839 pSMB->DataLengthHigh =
cpu_to_le16(bytes_sent >> 16);
1840 inc_rfc1001_len(pSMB, byte_count);
1852 (
struct smb_hdr *) pSMBr, &bytes_returned, long_op);
1855 cFYI(1,
"Send error in write = %d", rc);
1858 *nbytes = (*nbytes) << 16;
1866 if (*nbytes > count)
1901 for (i = 0; i < wdata->
nr_pages; i++) {
1902 lock_page(wdata->
pages[i]);
1907 server = tlink_tcon(wdata->
cfile->tlink)->ses->server;
1908 rc = server->
ops->async_writev(wdata);
1911 for (i = 0; i < wdata->
nr_pages; i++) {
1913 SetPageError(wdata->
pages[i]);
1917 mapping_set_error(inode->
i_mapping, rc);
1926 struct inode *inode = wdata->
cfile->dentry->d_inode;
1929 if (wdata->
result == 0) {
1930 spin_lock(&inode->
i_lock);
1932 spin_unlock(&inode->
i_lock);
1936 return cifs_writev_requeue(wdata);
1938 for (i = 0; i < wdata->
nr_pages; i++) {
1942 else if (wdata->
result < 0)
1958 if (nr_pages == 0) {
1959 cERROR(1,
"%s: called with nr_pages == 0!", __func__);
1964 wdata = kzalloc(
sizeof(*wdata) +
1966 if (wdata !=
NULL) {
1968 INIT_LIST_HEAD(&wdata->
list);
1969 init_completion(&wdata->
done);
1984 unsigned int written;
1985 WRITE_RSP *smb = (WRITE_RSP *)mid->
resp_buf;
2002 if (written > wdata->
bytes)
2005 if (written < wdata->
bytes)
2008 wdata->
bytes = written;
2021 add_credits(tcon->
ses->server, 1, 0);
2029 WRITE_REQ *smb =
NULL;
2039 if (wdata->
offset >> 32 > 0) {
2047 goto async_writev_out;
2052 smb->AndXCommand = 0xFF;
2053 smb->Fid = wdata->
cfile->fid.netfid;
2057 smb->Reserved = 0xFFFFFFFF;
2081 inc_rfc1001_len(&smb->hdr, wdata->
bytes + 1);
2082 put_bcc(wdata->
bytes + 1, &smb->hdr);
2087 inc_rfc1001_len(&smbw->
hdr, wdata->
bytes + 5);
2088 put_bcc(wdata->
bytes + 5, &smbw->
hdr);
2094 cifs_writev_callback, wdata, 0);
2108 unsigned int *
nbytes,
struct kvec *iov,
int n_vec)
2111 WRITE_REQ *pSMB =
NULL;
2114 int resp_buf_type = 0;
2123 cFYI(1,
"write2 at %lld %d bytes", (
long long)offset, count);
2129 if ((offset >> 32) > 0) {
2142 if (tcon->
ses->server ==
NULL)
2145 pSMB->AndXCommand = 0xFF;
2147 pSMB->OffsetLow =
cpu_to_le32(offset & 0xFFFFFFFF);
2150 pSMB->Reserved = 0xFFFFFFFF;
2151 pSMB->WriteMode = 0;
2152 pSMB->Remaining = 0;
2157 pSMB->DataLengthLow =
cpu_to_le16(count & 0xFFFF);
2160 smb_hdr_len =
be32_to_cpu(pSMB->hdr.smb_buf_length) + 1;
2162 inc_rfc1001_len(pSMB, count + 1);
2164 inc_rfc1001_len(pSMB, count + 5);
2174 iov[0].
iov_len = smb_hdr_len + 4;
2176 iov[0].
iov_len = smb_hdr_len + 8;
2182 cFYI(1,
"Send error Write2 = %d", rc);
2183 }
else if (resp_buf_type == 0) {
2187 WRITE_RSP *pSMBr = (WRITE_RSP *)iov[0].iov_base;
2189 *nbytes = (*nbytes) << 16;
2197 if (*nbytes > count)
2215 const __u32 num_lock, LOCKING_ANDX_RANGE *
buf)
2218 LOCK_REQ *pSMB =
NULL;
2223 cFYI(1,
"cifs_lockv num lock %d num unlock %d", num_lock, num_unlock);
2233 pSMB->AndXCommand = 0xFF;
2236 count = (num_unlock + num_lock) *
sizeof(LOCKING_ANDX_RANGE);
2237 inc_rfc1001_len(pSMB, count);
2242 (num_unlock + num_lock) *
sizeof(LOCKING_ANDX_RANGE);
2244 iov[1].
iov_len = (num_unlock + num_lock) *
sizeof(LOCKING_ANDX_RANGE);
2249 cFYI(1,
"Send error in cifs_lockv = %d", rc);
2258 const __u32 numLock,
const __u8 lockType,
2259 const bool waitFlag,
const __u8 oplock_level)
2262 LOCK_REQ *pSMB =
NULL;
2268 cFYI(1,
"CIFSSMBLock timeout %d numLock %d", (
int)waitFlag, numLock);
2278 }
else if (waitFlag) {
2287 pSMB->LockType = lockType;
2288 pSMB->OplockLevel = oplock_level;
2289 pSMB->AndXCommand = 0xFF;
2290 pSMB->Fid = smb_file_id;
2292 if ((numLock != 0) || (numUnlock != 0)) {
2299 count =
sizeof(LOCKING_ANDX_RANGE);
2304 inc_rfc1001_len(pSMB, count);
2309 (
struct smb_hdr *) pSMB, &bytes_returned);
2317 cFYI(1,
"Send error in Lock = %d", rc);
2329 const bool waitFlag)
2336 int bytes_returned = 0;
2337 int resp_buf_type = 0;
2341 cFYI(1,
"Posix Lock");
2356 offset = param_offset +
params;
2367 byte_count = 3 + params +
count;
2374 (((
char *) &pSMB->
hdr.Protocol) +
offset);
2389 pSMB->
Fid = smb_file_id;
2392 inc_rfc1001_len(pSMB, byte_count);
2396 (
struct smb_hdr *) pSMBr, &bytes_returned);
2401 &resp_buf_type, timeout);
2408 cFYI(1,
"Send error in Posix Lock = %d", rc);
2409 }
else if (pLockData) {
2413 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
2415 if (rc || get_bcc(&pSMBr->
hdr) <
sizeof(*parm_data)) {
2464 CLOSE_REQ *pSMB =
NULL;
2465 cFYI(1,
"In CIFSSMBClose");
2468 rc = small_smb_init(
SMB_COM_CLOSE, 3, tcon, (
void **) &pSMB);
2474 pSMB->FileID = (
__u16) smb_file_id;
2475 pSMB->LastWriteTime = 0xFFFFFFFF;
2476 pSMB->ByteCount = 0;
2482 cERROR(1,
"Send error in Close = %d", rc);
2497 FLUSH_REQ *pSMB =
NULL;
2498 cFYI(1,
"In CIFSSMBFlush");
2500 rc = small_smb_init(
SMB_COM_FLUSH, 1, tcon, (
void **) &pSMB);
2504 pSMB->FileID = (
__u16) smb_file_id;
2505 pSMB->ByteCount = 0;
2509 cERROR(1,
"Send error in Flush = %d", rc);
2516 const char *from_name,
const char *to_name,
2520 RENAME_REQ *pSMB =
NULL;
2521 RENAME_RSP *pSMBr =
NULL;
2527 cFYI(1,
"In CIFSSMBRename");
2534 pSMB->BufferFormat = 0x04;
2535 pSMB->SearchAttributes =
2545 pSMB->OldFileName[
name_len] = 0x04;
2547 pSMB->OldFileName[name_len + 1] = 0x00;
2552 name_len2 += 1 + 1 ;
2557 strncpy(pSMB->OldFileName, from_name, name_len);
2560 pSMB->OldFileName[
name_len] = 0x04;
2561 strncpy(&pSMB->OldFileName[name_len + 1], to_name, name_len2);
2566 count = 1 + name_len + name_len2;
2567 inc_rfc1001_len(pSMB, count);
2571 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
2574 cFYI(1,
"Send error in rename = %d", rc);
2586 const struct nls_table *nls_codepage,
int remap)
2592 char dummy_string[30];
2594 int bytes_returned = 0;
2598 cFYI(1,
"Rename to File by handle");
2611 offset = param_offset +
params;
2613 data_offset = (
char *) (&pSMB->
hdr.Protocol) +
offset;
2629 if (target_name ==
NULL) {
2630 sprintf(dummy_string,
"cifs%x", pSMB->
hdr.Mid);
2633 dummy_string, 24, nls_codepage, remap);
2637 target_name,
PATH_MAX, nls_codepage,
2641 count = 12 + (2 * len_of_str);
2642 byte_count +=
count;
2649 inc_rfc1001_len(pSMB, byte_count);
2652 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
2655 cFYI(1,
"Send error in Rename (by file handle) = %d", rc);
2667 const char *fromName,
const __u16 target_tid,
const char *toName,
2668 const int flags,
const struct nls_table *nls_codepage,
int remap)
2671 COPY_REQ *pSMB =
NULL;
2672 COPY_RSP *pSMBr =
NULL;
2677 cFYI(1,
"In CIFSSMBCopy");
2684 pSMB->BufferFormat = 0x04;
2685 pSMB->Tid2 = target_tid;
2695 pSMB->OldFileName[
name_len] = 0x04;
2697 pSMB->OldFileName[name_len + 1] = 0x00;
2700 toName,
PATH_MAX, nls_codepage, remap);
2701 name_len2 += 1 + 1 ;
2706 strncpy(pSMB->OldFileName, fromName, name_len);
2709 pSMB->OldFileName[
name_len] = 0x04;
2710 strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2);
2715 count = 1 + name_len + name_len2;
2716 inc_rfc1001_len(pSMB, count);
2720 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
2722 cFYI(1,
"Send error in copy = %d with %d files copied",
2735 const char *fromName,
const char *toName,
2738 TRANSACTION2_SPI_REQ *pSMB =
NULL;
2739 TRANSACTION2_SPI_RSP *pSMBr =
NULL;
2742 int name_len_target;
2744 int bytes_returned = 0;
2747 cFYI(1,
"In Symlink Unix style");
2765 strncpy(pSMB->FileName, fromName, name_len);
2768 pSMB->MaxSetupCount = 0;
2772 pSMB->Reserved2 = 0;
2775 offset = param_offset +
params;
2777 data_offset = (
char *) (&pSMB->hdr.Protocol) +
offset;
2784 name_len_target *= 2;
2788 strncpy(data_offset, toName, name_len_target);
2794 pSMB->SetupCount = 1;
2795 pSMB->Reserved3 = 0;
2797 byte_count = 3 + params + name_len_target;
2800 pSMB->TotalDataCount = pSMB->DataCount;
2801 pSMB->TotalParameterCount = pSMB->ParameterCount;
2802 pSMB->ParameterOffset =
cpu_to_le16(param_offset);
2805 pSMB->Reserved4 = 0;
2806 inc_rfc1001_len(pSMB, byte_count);
2809 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
2812 cFYI(1,
"Send error in SetPathInfo create symlink = %d", rc);
2817 goto createSymLinkRetry;
2824 const char *fromName,
const char *toName,
2825 const struct nls_table *nls_codepage,
int remap)
2827 TRANSACTION2_SPI_REQ *pSMB =
NULL;
2828 TRANSACTION2_SPI_RSP *pSMBr =
NULL;
2831 int name_len_target;
2833 int bytes_returned = 0;
2836 cFYI(1,
"In Create Hard link Unix style");
2837 createHardLinkRetry:
2852 strncpy(pSMB->FileName, toName, name_len);
2855 pSMB->MaxSetupCount = 0;
2859 pSMB->Reserved2 = 0;
2862 offset = param_offset +
params;
2864 data_offset = (
char *) (&pSMB->hdr.Protocol) +
offset;
2870 name_len_target *= 2;
2874 strncpy(data_offset, fromName, name_len_target);
2880 pSMB->SetupCount = 1;
2881 pSMB->Reserved3 = 0;
2883 byte_count = 3 + params + name_len_target;
2885 pSMB->TotalParameterCount = pSMB->ParameterCount;
2887 pSMB->TotalDataCount = pSMB->DataCount;
2888 pSMB->ParameterOffset =
cpu_to_le16(param_offset);
2891 pSMB->Reserved4 = 0;
2892 inc_rfc1001_len(pSMB, byte_count);
2895 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
2898 cFYI(1,
"Send error in SetPathInfo (hard link) = %d", rc);
2902 goto createHardLinkRetry;
2909 const char *from_name,
const char *to_name,
2913 NT_RENAME_REQ *pSMB =
NULL;
2914 RENAME_RSP *pSMBr =
NULL;
2920 cFYI(1,
"In CIFSCreateHardLink");
2921 winCreateHardLinkRetry:
2928 pSMB->SearchAttributes =
2932 pSMB->ClusterCount = 0;
2934 pSMB->BufferFormat = 0x04;
2944 pSMB->OldFileName[
name_len] = 0x04;
2945 pSMB->OldFileName[name_len + 1] = 0x00;
2950 name_len2 += 1 + 1 ;
2955 strncpy(pSMB->OldFileName, from_name, name_len);
2958 pSMB->OldFileName[
name_len] = 0x04;
2959 strncpy(&pSMB->OldFileName[name_len + 1], to_name, name_len2);
2964 count = 1 + name_len + name_len2;
2965 inc_rfc1001_len(pSMB, count);
2969 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
2972 cFYI(1,
"Send error in hard link (NT rename) = %d", rc);
2976 goto winCreateHardLinkRetry;
2983 const unsigned char *searchName,
char **symlinkinfo,
2987 TRANSACTION2_QPI_REQ *pSMB =
NULL;
2988 TRANSACTION2_QPI_RSP *pSMBr =
NULL;
2995 cFYI(1,
"In QPathSymLinkInfo (Unix) for path %s", searchName);
3012 strncpy(pSMB->FileName, searchName, name_len);
3015 params = 2 + 4 + name_len ;
3016 pSMB->TotalDataCount = 0;
3019 pSMB->MaxSetupCount = 0;
3023 pSMB->Reserved2 = 0;
3026 pSMB->DataCount = 0;
3027 pSMB->DataOffset = 0;
3028 pSMB->SetupCount = 1;
3029 pSMB->Reserved3 = 0;
3031 byte_count = params + 1 ;
3033 pSMB->ParameterCount = pSMB->TotalParameterCount;
3035 pSMB->Reserved4 = 0;
3036 inc_rfc1001_len(pSMB, byte_count);
3040 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
3042 cFYI(1,
"Send error in QuerySymLinkInfo = %d", rc);
3046 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
3048 if (rc || get_bcc(&pSMBr->hdr) < 2)
3054 data_start = ((
char *) &pSMBr->hdr.Protocol) +
3064 count, is_unicode, nls_codepage);
3071 goto querySymLinkRetry;
3075 #ifdef CONFIG_CIFS_SYMLINK_EXPERIMENTAL
3087 CIFSSMBQueryReparseLinkInfo(
const unsigned int xid,
struct cifs_tcon *tcon,
3088 const unsigned char *searchName,
3097 cFYI(1,
"In Windows reparse style QueryLink for path %s", searchName);
3123 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
3125 cFYI(1,
"Send error in QueryReparseLinkInfo = %d", rc);
3129 if (get_bcc(&pSMBr->
hdr) < 2 || data_offset > 512) {
3134 if (data_count && (data_count < 2048)) {
3135 char *end_of_smb = 2 +
3140 ((
char *)&pSMBr->
hdr.Protocol
3142 if ((
char *)reparse_buf >= end_of_smb) {
3146 if ((reparse_buf->LinkNamesBuf +
3147 reparse_buf->TargetNameOffset +
3148 reparse_buf->TargetNameLen) > end_of_smb) {
3149 cFYI(1,
"reparse buf beyond SMB");
3155 cifs_from_ucs2(symlinkinfo, (
__le16 *)
3156 (reparse_buf->LinkNamesBuf +
3157 reparse_buf->TargetNameOffset),
3159 reparse_buf->TargetNameLen,
3163 reparse_buf->LinkNamesBuf +
3164 reparse_buf->TargetNameOffset,
3165 min_t(
const int, buflen,
3166 reparse_buf->TargetNameLen));
3170 cFYI(1,
"Invalid return data count on "
3171 "get reparse info ioctl");
3175 cFYI(1,
"readlink result - %s", symlinkinfo);
3188 #ifdef CONFIG_CIFS_POSIX
3204 static int cifs_copy_posix_acl(
char *trgt,
char *
src,
const int buflen,
3205 const int acl_type,
const int size_of_data_area)
3223 if (size_of_data_area < size) {
3224 cFYI(1,
"bad CIFS POSIX ACL size %d vs. %d",
3225 size_of_data_area, size);
3237 if (size_of_data_area < size)
3244 size = posix_acl_xattr_size(count);
3245 if ((buflen == 0) || (local_acl ==
NULL)) {
3247 }
else if (size > buflen) {
3251 for (i = 0; i <
count ; i++) {
3252 cifs_convert_ace(&local_acl->
a_entries[i], pACE);
3277 static __u16 ACL_to_cifs_posix(
char *parm_data,
const char *pACL,
3278 const int buflen,
const int acl_type)
3286 if ((buflen == 0) || (pACL ==
NULL) || (cifs_acl ==
NULL))
3289 count = posix_acl_xattr_count((
size_t)buflen);
3290 cFYI(1,
"setting acl with %d entries from buf of length %d and "
3294 cFYI(1,
"unknown POSIX ACL version %d",
3299 if (acl_type == ACL_TYPE_ACCESS)
3301 else if (acl_type == ACL_TYPE_DEFAULT)
3304 cFYI(1,
"unknown ACL type %d", acl_type);
3307 for (i = 0; i <
count; i++) {
3308 rc = convert_ace_to_cifs_ace(&cifs_acl->
ace_array[i],
3325 const unsigned char *searchName,
3326 char *acl_inf,
const int buflen,
const int acl_type,
3327 const struct nls_table *nls_codepage,
int remap)
3330 TRANSACTION2_QPI_REQ *pSMB =
NULL;
3331 TRANSACTION2_QPI_RSP *pSMBr =
NULL;
3337 cFYI(1,
"In GetPosixACL (Unix) for path %s", searchName);
3348 searchName,
PATH_MAX, nls_codepage,
3353 pSMB->FileName[name_len+1] = 0;
3357 strncpy(pSMB->FileName, searchName, name_len);
3360 params = 2 + 4 + name_len ;
3361 pSMB->TotalDataCount = 0;
3365 pSMB->MaxSetupCount = 0;
3369 pSMB->Reserved2 = 0;
3373 pSMB->DataCount = 0;
3374 pSMB->DataOffset = 0;
3375 pSMB->SetupCount = 1;
3376 pSMB->Reserved3 = 0;
3378 byte_count = params + 1 ;
3380 pSMB->ParameterCount = pSMB->TotalParameterCount;
3382 pSMB->Reserved4 = 0;
3383 inc_rfc1001_len(pSMB, byte_count);
3387 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
3390 cFYI(1,
"Send error in Query POSIX ACL = %d", rc);
3394 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
3396 if (rc || get_bcc(&pSMBr->hdr) < 2)
3401 rc = cifs_copy_posix_acl(acl_inf,
3402 (
char *)&pSMBr->hdr.Protocol+data_offset,
3403 buflen, acl_type, count);
3415 const char *local_acl,
const int buflen,
3417 const struct nls_table *nls_codepage,
int remap)
3424 int bytes_returned = 0;
3427 cFYI(1,
"In SetPosixACL (Unix) for path %s", fileName);
3455 offset = param_offset +
params;
3456 parm_data = ((
char *) &pSMB->
hdr.Protocol) +
offset;
3460 data_count = ACL_to_cifs_posix(parm_data, local_acl, buflen, acl_type);
3462 if (data_count == 0) {
3464 goto setACLerrorExit;
3477 inc_rfc1001_len(pSMB, byte_count);
3480 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
3482 cFYI(1,
"Set POSIX ACL returned %d", rc);
3494 const int netfid,
__u64 *pExtAttrBits,
__u64 *pMask)
3502 cFYI(1,
"In GetExtAttr");
3513 pSMB->
t2.TotalDataCount = 0;
3517 pSMB->
t2.MaxSetupCount = 0;
3518 pSMB->
t2.Reserved = 0;
3520 pSMB->
t2.Timeout = 0;
3521 pSMB->
t2.Reserved2 = 0;
3524 pSMB->
t2.DataCount = 0;
3525 pSMB->
t2.DataOffset = 0;
3526 pSMB->
t2.SetupCount = 1;
3527 pSMB->
t2.Reserved3 = 0;
3529 byte_count = params + 1 ;
3531 pSMB->
t2.ParameterCount = pSMB->
t2.TotalParameterCount;
3535 inc_rfc1001_len(pSMB, byte_count);
3539 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
3541 cFYI(1,
"error %d in GetExtAttr", rc);
3544 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
3546 if (rc || get_bcc(&pSMBr->
hdr) < 2)
3553 struct file_chattr_info *pfinfo;
3556 cFYI(1,
"Illegal size ret in GetExtAttr");
3560 pfinfo = (
struct file_chattr_info *)
3561 (data_offset + (
char *) &pSMBr->
hdr.Protocol);
3569 goto GetExtAttrRetry;
3575 #ifdef CONFIG_CIFS_ACL
3585 smb_init_nttransact(
const __u16 sub_command,
const int setup_count,
3586 const int parm_len,
struct cifs_tcon *tcon,
3597 *ret_buf = (
void *)pSMB;
3605 (setup_count * 2) - 4 ;
3614 validate_ntransact(
char *
buf,
char **ppparm,
char **
ppdata,
3630 bcc = get_bcc(&pSMBr->
hdr);
3631 end_of_smb = 2 + bcc +
3639 *ppparm = (
char *)&pSMBr->
hdr.Protocol + parm_offset;
3643 if (*ppparm > end_of_smb) {
3644 cFYI(1,
"parms start after end of smb");
3646 }
else if (parm_count + *ppparm > end_of_smb) {
3647 cFYI(1,
"parm end after end of smb");
3649 }
else if (*ppdata > end_of_smb) {
3650 cFYI(1,
"data starts after end of smb");
3652 }
else if (data_count + *ppdata > end_of_smb) {
3653 cFYI(1,
"data %p + count %d (%p) past smb end %p start %p",
3654 *ppdata, data_count, (data_count + *ppdata),
3657 }
else if (parm_count + data_count > bcc) {
3658 cFYI(1,
"parm count and data count larger than SMB");
3662 *pparmlen = parm_count;
3673 QUERY_SEC_DESC_REQ *pSMB;
3676 cFYI(1,
"GetCifsACL");
3682 8 , tcon, (
void **) &pSMB);
3688 pSMB->MaxSetupCount = 0;
3693 inc_rfc1001_len(pSMB, 11);
3694 iov[0].iov_base = (
char *)pSMB;
3695 iov[0].iov_len =
be32_to_cpu(pSMB->hdr.smb_buf_length) + 4;
3701 cFYI(1,
"Send error in QuerySecDesc = %d", rc);
3710 rc = validate_ntransact(iov[0].iov_base, (
char **)&parm,
3711 &pdata, &parm_len, pbuflen);
3716 cFYI(1,
"smb %p parm %p data %p", pSMBr, parm, *acl_inf);
3727 if (acl_len != *pbuflen) {
3728 cERROR(1,
"acl length %d does not match %d",
3730 if (*pbuflen > acl_len)
3736 if ((*pbuflen <
sizeof(
struct cifs_ntsd) + 8) ||
3737 (*pbuflen >= 64 * 1024)) {
3738 cERROR(1,
"bad acl length %d", *pbuflen);
3743 if (*acl_inf ==
NULL) {
3747 memcpy(*acl_inf, pdata, *pbuflen);
3765 int bytes_returned = 0;
3766 SET_SEC_DESC_REQ *pSMB =
NULL;
3774 pSMB->MaxSetupCount = 0;
3779 data_count = acllen;
3784 pSMB->TotalDataCount = pSMB->DataCount;
3788 pSMB->ParameterOffset =
cpu_to_le32(param_offset);
3789 pSMB->TotalParameterCount = pSMB->ParameterCount;
3791 pSMB->SetupCount = 0;
3793 pSMB->ByteCount =
cpu_to_le16(byte_count+data_count);
3796 pSMB->Reserved2 = 0;
3799 if (pntsd && acllen) {
3801 data_offset, pntsd, acllen);
3802 inc_rfc1001_len(pSMB, byte_count + data_count);
3804 inc_rfc1001_len(pSMB, byte_count);
3807 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
3809 cFYI(1,
"SetCIFSACL bytes_returned: %d, rc: %d", bytes_returned, rc);
3811 cFYI(1,
"Set CIFS ACL returned %d", rc);
3815 goto setCifsAclRetry;
3826 const char *search_name, FILE_ALL_INFO *
data,
3827 const struct nls_table *nls_codepage,
int remap)
3829 QUERY_INFORMATION_REQ *pSMB;
3830 QUERY_INFORMATION_RSP *pSMBr;
3835 cFYI(1,
"In SMBQPath path %s", search_name);
3845 search_name,
PATH_MAX, nls_codepage,
3852 strncpy(pSMB->FileName, search_name, name_len);
3854 pSMB->BufferFormat = 0x04;
3856 inc_rfc1001_len(pSMB, (
__u16)name_len);
3860 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
3862 cFYI(1,
"Send error in QueryInfo = %d", rc);
3869 memset(data, 0,
sizeof(FILE_ALL_INFO));
3874 data->LastWriteTime = data->ChangeTime;
3875 data->LastAccessTime = 0;
3876 data->AllocationSize =
3878 data->EndOfFile = data->AllocationSize;
3894 u16 netfid, FILE_ALL_INFO *pFindData)
3909 pSMB->
t2.TotalDataCount = 0;
3913 pSMB->
t2.MaxSetupCount = 0;
3914 pSMB->
t2.Reserved = 0;
3916 pSMB->
t2.Timeout = 0;
3917 pSMB->
t2.Reserved2 = 0;
3920 pSMB->
t2.DataCount = 0;
3921 pSMB->
t2.DataOffset = 0;
3922 pSMB->
t2.SetupCount = 1;
3923 pSMB->
t2.Reserved3 = 0;
3925 byte_count = params + 1 ;
3927 pSMB->
t2.ParameterCount = pSMB->
t2.TotalParameterCount;
3931 inc_rfc1001_len(pSMB, byte_count);
3934 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
3936 cFYI(1,
"Send error in QPathInfo = %d", rc);
3938 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
3942 else if (get_bcc(&pSMBr->
hdr) < 40)
3944 else if (pFindData) {
3946 memcpy((
char *) pFindData,
3947 (
char *) &pSMBr->
hdr.Protocol +
3948 data_offset,
sizeof(FILE_ALL_INFO));
3954 goto QFileInfoRetry;
3961 const char *search_name, FILE_ALL_INFO *
data,
3963 const struct nls_table *nls_codepage,
int remap)
3966 TRANSACTION2_QPI_REQ *pSMB =
NULL;
3967 TRANSACTION2_QPI_RSP *pSMBr =
NULL;
3989 strncpy(pSMB->FileName, search_name, name_len);
3992 params = 2 + 4 + name_len ;
3993 pSMB->TotalDataCount = 0;
3997 pSMB->MaxSetupCount = 0;
4001 pSMB->Reserved2 = 0;
4004 pSMB->DataCount = 0;
4005 pSMB->DataOffset = 0;
4006 pSMB->SetupCount = 1;
4007 pSMB->Reserved3 = 0;
4009 byte_count = params + 1 ;
4011 pSMB->ParameterCount = pSMB->TotalParameterCount;
4016 pSMB->Reserved4 = 0;
4017 inc_rfc1001_len(pSMB, byte_count);
4021 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4023 cFYI(1,
"Send error in QPathInfo = %d", rc);
4025 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4029 else if (!legacy && get_bcc(&pSMBr->hdr) < 40)
4031 else if (legacy && get_bcc(&pSMBr->hdr) < 24)
4045 size =
sizeof(FILE_INFO_STANDARD);
4047 size =
sizeof(FILE_ALL_INFO);
4048 memcpy((
char *) data, (
char *) &pSMBr->hdr.Protocol +
4055 goto QPathInfoRetry;
4062 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData)
4077 pSMB->
t2.TotalDataCount = 0;
4081 pSMB->
t2.MaxSetupCount = 0;
4082 pSMB->
t2.Reserved = 0;
4084 pSMB->
t2.Timeout = 0;
4085 pSMB->
t2.Reserved2 = 0;
4088 pSMB->
t2.DataCount = 0;
4089 pSMB->
t2.DataOffset = 0;
4090 pSMB->
t2.SetupCount = 1;
4091 pSMB->
t2.Reserved3 = 0;
4093 byte_count = params + 1 ;
4095 pSMB->
t2.ParameterCount = pSMB->
t2.TotalParameterCount;
4099 inc_rfc1001_len(pSMB, byte_count);
4102 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4104 cFYI(1,
"Send error in QPathInfo = %d", rc);
4106 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4108 if (rc || get_bcc(&pSMBr->
hdr) <
sizeof(FILE_UNIX_BASIC_INFO)) {
4109 cERROR(1,
"Malformed FILE_UNIX_BASIC_INFO response. "
4110 "Unix Extensions can be disabled on mount "
4111 "by specifying the nosfu mount option.");
4115 memcpy((
char *) pFindData,
4116 (
char *) &pSMBr->
hdr.Protocol +
4118 sizeof(FILE_UNIX_BASIC_INFO));
4124 goto UnixQFileInfoRetry;
4131 const unsigned char *searchName,
4132 FILE_UNIX_BASIC_INFO *pFindData,
4133 const struct nls_table *nls_codepage,
int remap)
4136 TRANSACTION2_QPI_REQ *pSMB =
NULL;
4137 TRANSACTION2_QPI_RSP *pSMBr =
NULL;
4139 int bytes_returned = 0;
4143 cFYI(1,
"In QPathInfo (Unix) the path %s", searchName);
4159 strncpy(pSMB->FileName, searchName, name_len);
4162 params = 2 + 4 + name_len ;
4163 pSMB->TotalDataCount = 0;
4167 pSMB->MaxSetupCount = 0;
4171 pSMB->Reserved2 = 0;
4174 pSMB->DataCount = 0;
4175 pSMB->DataOffset = 0;
4176 pSMB->SetupCount = 1;
4177 pSMB->Reserved3 = 0;
4179 byte_count = params + 1 ;
4181 pSMB->ParameterCount = pSMB->TotalParameterCount;
4183 pSMB->Reserved4 = 0;
4184 inc_rfc1001_len(pSMB, byte_count);
4188 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4190 cFYI(1,
"Send error in QPathInfo = %d", rc);
4192 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4194 if (rc || get_bcc(&pSMBr->hdr) <
sizeof(FILE_UNIX_BASIC_INFO)) {
4195 cERROR(1,
"Malformed FILE_UNIX_BASIC_INFO response. "
4196 "Unix Extensions can be disabled on mount "
4197 "by specifying the nosfu mount option.");
4201 memcpy((
char *) pFindData,
4202 (
char *) &pSMBr->hdr.Protocol +
4204 sizeof(FILE_UNIX_BASIC_INFO));
4209 goto UnixQPathInfoRetry;
4222 TRANSACTION2_FFIRST_REQ *pSMB =
NULL;
4223 TRANSACTION2_FFIRST_RSP *pSMBr =
NULL;
4224 T2_FFIRST_RSP_PARMS *
parms;
4226 int bytes_returned = 0;
4231 cFYI(1,
"In FindFirst for %s", searchName);
4251 pSMB->FileName[
name_len] = CIFS_DIR_SEP(cifs_sb);
4252 pSMB->FileName[name_len+1] = 0;
4253 pSMB->FileName[name_len+2] =
'*';
4254 pSMB->FileName[name_len+3] = 0;
4258 pSMB->FileName[name_len+1] = 0;
4266 strncpy(pSMB->FileName, searchName, name_len);
4268 pSMB->FileName[
name_len] = CIFS_DIR_SEP(cifs_sb);
4269 pSMB->FileName[name_len+1] =
'*';
4270 pSMB->FileName[name_len+2] = 0;
4275 params = 12 + name_len ;
4276 pSMB->TotalDataCount = 0;
4279 pSMB->MaxSetupCount = 0;
4283 pSMB->Reserved2 = 0;
4284 byte_count = params + 1 ;
4286 pSMB->ParameterCount = pSMB->TotalParameterCount;
4290 pSMB->DataCount = 0;
4291 pSMB->DataOffset = 0;
4292 pSMB->SetupCount = 1;
4293 pSMB->Reserved3 = 0;
4295 pSMB->SearchAttributes =
4303 pSMB->SearchStorageType = 0;
4304 inc_rfc1001_len(pSMB, byte_count);
4308 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4314 cFYI(1,
"Error in FindFirst = %d", rc);
4321 goto findFirstRetry;
4324 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4336 (
char *) &pSMBr->hdr.Protocol +
4338 parms = (T2_FFIRST_RSP_PARMS *)((
char *) &pSMBr->hdr.Protocol +
4341 if (parms->EndofSearch)
4352 cERROR(1,
"ignoring corrupt resume name");
4361 *pnetfid = parms->SearchHandle;
4374 TRANSACTION2_FNEXT_REQ *pSMB =
NULL;
4375 TRANSACTION2_FNEXT_RSP *pSMBr =
NULL;
4376 T2_FNEXT_RSP_PARMS *
parms;
4377 char *response_data;
4383 cFYI(1,
"In FindNext");
4395 pSMB->TotalDataCount = 0;
4398 pSMB->MaxSetupCount = 0;
4402 pSMB->Reserved2 = 0;
4405 pSMB->DataCount = 0;
4406 pSMB->DataOffset = 0;
4407 pSMB->SetupCount = 1;
4408 pSMB->Reserved3 = 0;
4410 pSMB->SearchHandle = searchHandle;
4423 pSMB->ResumeFileName[
name_len] = 0;
4424 pSMB->ResumeFileName[name_len+1] = 0;
4427 goto FNext2_err_exit;
4429 byte_count = params + 1 ;
4431 pSMB->ParameterCount = pSMB->TotalParameterCount;
4432 inc_rfc1001_len(pSMB, byte_count);
4436 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4444 cFYI(1,
"FindNext returned = %d", rc);
4446 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4456 response_data = (
char *) &pSMBr->hdr.Protocol +
4458 parms = (T2_FNEXT_RSP_PARMS *)response_data;
4459 response_data = (
char *)&pSMBr->hdr.Protocol +
4469 if (parms->EndofSearch)
4479 cERROR(1,
"ignoring corrupt resume name");
4507 const __u16 searchHandle)
4510 FINDCLOSE_REQ *pSMB =
NULL;
4512 cFYI(1,
"In CIFSSMBFindClose");
4522 pSMB->FileID = searchHandle;
4523 pSMB->ByteCount = 0;
4526 cERROR(1,
"Send error in FindClose = %d", rc);
4539 const char *search_name,
__u64 *inode_number,
4540 const struct nls_table *nls_codepage,
int remap)
4543 TRANSACTION2_QPI_REQ *pSMB =
NULL;
4544 TRANSACTION2_QPI_RSP *pSMBr =
NULL;
4548 cFYI(1,
"In GetSrvInodeNum for %s", search_name);
4552 GetInodeNumberRetry:
4561 search_name,
PATH_MAX, nls_codepage,
4568 strncpy(pSMB->FileName, search_name, name_len);
4571 params = 2 + 4 + name_len ;
4572 pSMB->TotalDataCount = 0;
4576 pSMB->MaxSetupCount = 0;
4580 pSMB->Reserved2 = 0;
4583 pSMB->DataCount = 0;
4584 pSMB->DataOffset = 0;
4585 pSMB->SetupCount = 1;
4586 pSMB->Reserved3 = 0;
4588 byte_count = params + 1 ;
4590 pSMB->ParameterCount = pSMB->TotalParameterCount;
4592 pSMB->Reserved4 = 0;
4593 inc_rfc1001_len(pSMB, byte_count);
4597 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4599 cFYI(1,
"error %d in QueryInternalInfo", rc);
4602 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4604 if (rc || get_bcc(&pSMBr->hdr) < 2)
4614 cFYI(1,
"Illegal size ret in QryIntrnlInf");
4616 goto GetInodeNumOut;
4619 (data_offset + (
char *) &pSMBr->hdr.Protocol);
4626 goto GetInodeNumberRetry;
4637 parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
4638 unsigned int *num_of_nodes,
4640 const struct nls_table *nls_codepage,
int remap,
4641 const char *searchName)
4652 *num_of_nodes =
le16_to_cpu(pSMBr->NumberOfReferrals);
4654 if (*num_of_nodes < 1) {
4655 cERROR(1,
"num_referrals: must be at least > 0,"
4656 "but we get num_referrals = %d", *num_of_nodes);
4658 goto parse_DFS_referrals_exit;
4663 cERROR(1,
"Referrals of V%d version are not supported,"
4666 goto parse_DFS_referrals_exit;
4670 data_end = (
char *)(&(pSMBr->PathConsumed)) +
4673 cFYI(1,
"num_referrals: %d dfs flags: 0x%x ...",
4679 if (*target_nodes ==
NULL) {
4680 cERROR(1,
"Failed to allocate buffer for target_nodes");
4682 goto parse_DFS_referrals_exit;
4686 for (i = 0; i < *num_of_nodes; i++) {
4697 goto parse_DFS_referrals_exit;
4713 max_len = data_end -
temp;
4715 is_unicode, nls_codepage);
4718 goto parse_DFS_referrals_exit;
4723 max_len = data_end -
temp;
4725 is_unicode, nls_codepage);
4728 goto parse_DFS_referrals_exit;
4734 parse_DFS_referrals_exit:
4736 free_dfs_info_array(*target_nodes, *num_of_nodes);
4737 *target_nodes =
NULL;
4746 unsigned int *num_of_nodes,
4747 const struct nls_table *nls_codepage,
int remap)
4750 TRANSACTION2_GET_DFS_REFER_REQ *pSMB =
NULL;
4751 TRANSACTION2_GET_DFS_REFER_RSP *pSMBr =
NULL;
4757 *target_nodes =
NULL;
4759 cFYI(1,
"In GetDFSRefer the path %s", search_name);
4770 pSMB->hdr.Mid = get_next_mid(ses->
server);
4772 pSMB->hdr.Uid = ses->
Suid;
4782 search_name,
PATH_MAX, nls_codepage,
4789 strncpy(pSMB->RequestFileName, search_name, name_len);
4793 if (ses->
server->sec_mode &
4798 pSMB->hdr.Uid = ses->
Suid;
4800 params = 2 + name_len ;
4801 pSMB->TotalDataCount = 0;
4802 pSMB->DataCount = 0;
4803 pSMB->DataOffset = 0;
4804 pSMB->MaxParameterCount = 0;
4807 pSMB->MaxSetupCount = 0;
4811 pSMB->Reserved2 = 0;
4814 pSMB->SetupCount = 1;
4815 pSMB->Reserved3 = 0;
4817 byte_count = params + 3 ;
4819 pSMB->TotalParameterCount = pSMB->ParameterCount;
4821 inc_rfc1001_len(pSMB, byte_count);
4825 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4827 cFYI(1,
"Send error in GetDFSRefer = %d", rc);
4830 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4833 if (rc || get_bcc(&pSMBr->hdr) < 17) {
4838 cFYI(1,
"Decoding GetDFSRefer response BCC: %d Offset %d",
4839 get_bcc(&pSMBr->hdr),
4843 rc = parse_DFS_referrals(pSMBr, num_of_nodes,
4844 target_nodes, nls_codepage, remap,
4862 TRANSACTION2_QFSI_REQ *pSMB =
NULL;
4863 TRANSACTION2_QFSI_RSP *pSMBr =
NULL;
4864 FILE_SYSTEM_ALLOC_INFO *response_data;
4866 int bytes_returned = 0;
4869 cFYI(1,
"OldQFSInfo");
4877 pSMB->TotalDataCount = 0;
4880 pSMB->MaxSetupCount = 0;
4884 pSMB->Reserved2 = 0;
4885 byte_count = params + 1 ;
4887 pSMB->ParameterCount = pSMB->TotalParameterCount;
4890 pSMB->DataCount = 0;
4891 pSMB->DataOffset = 0;
4892 pSMB->SetupCount = 1;
4893 pSMB->Reserved3 = 0;
4896 inc_rfc1001_len(pSMB, byte_count);
4900 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4902 cFYI(1,
"Send error in QFSInfo = %d", rc);
4904 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4906 if (rc || get_bcc(&pSMBr->hdr) < 18)
4910 cFYI(1,
"qfsinf resp BCC: %d Offset %d",
4911 get_bcc(&pSMBr->hdr), data_offset);
4913 response_data = (FILE_SYSTEM_ALLOC_INFO *)
4918 SectorsPerAllocationUnit);
4923 cFYI(1,
"Blocks: %lld Free: %lld Block size %ld",
4924 (
unsigned long long)FSData->
f_blocks,
4925 (
unsigned long long)FSData->
f_bfree,
4932 goto oldQFSInfoRetry;
4942 TRANSACTION2_QFSI_REQ *pSMB =
NULL;
4943 TRANSACTION2_QFSI_RSP *pSMBr =
NULL;
4944 FILE_SYSTEM_INFO *response_data;
4946 int bytes_returned = 0;
4949 cFYI(1,
"In QFSInfo");
4957 pSMB->TotalDataCount = 0;
4960 pSMB->MaxSetupCount = 0;
4964 pSMB->Reserved2 = 0;
4965 byte_count = params + 1 ;
4967 pSMB->ParameterCount = pSMB->TotalParameterCount;
4970 pSMB->DataCount = 0;
4971 pSMB->DataOffset = 0;
4972 pSMB->SetupCount = 1;
4973 pSMB->Reserved3 = 0;
4976 inc_rfc1001_len(pSMB, byte_count);
4980 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
4982 cFYI(1,
"Send error in QFSInfo = %d", rc);
4984 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
4986 if (rc || get_bcc(&pSMBr->hdr) < 24)
4993 *) (((
char *) &pSMBr->hdr.Protocol) +
4998 SectorsPerAllocationUnit);
5003 cFYI(1,
"Blocks: %lld Free: %lld Block size %ld",
5004 (
unsigned long long)FSData->
f_blocks,
5005 (
unsigned long long)FSData->
f_bfree,
5021 TRANSACTION2_QFSI_REQ *pSMB =
NULL;
5022 TRANSACTION2_QFSI_RSP *pSMBr =
NULL;
5023 FILE_SYSTEM_ATTRIBUTE_INFO *response_data;
5025 int bytes_returned = 0;
5028 cFYI(1,
"In QFSAttributeInfo");
5036 pSMB->TotalDataCount = 0;
5040 pSMB->MaxSetupCount = 0;
5044 pSMB->Reserved2 = 0;
5045 byte_count = params + 1 ;
5047 pSMB->ParameterCount = pSMB->TotalParameterCount;
5050 pSMB->DataCount = 0;
5051 pSMB->DataOffset = 0;
5052 pSMB->SetupCount = 1;
5053 pSMB->Reserved3 = 0;
5056 inc_rfc1001_len(pSMB, byte_count);
5060 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5062 cERROR(1,
"Send error in QFSAttributeInfo = %d", rc);
5064 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
5066 if (rc || get_bcc(&pSMBr->hdr) < 13) {
5072 (FILE_SYSTEM_ATTRIBUTE_INFO
5073 *) (((
char *) &pSMBr->hdr.Protocol) +
5076 sizeof(FILE_SYSTEM_ATTRIBUTE_INFO));
5082 goto QFSAttributeRetry;
5091 TRANSACTION2_QFSI_REQ *pSMB =
NULL;
5092 TRANSACTION2_QFSI_RSP *pSMBr =
NULL;
5093 FILE_SYSTEM_DEVICE_INFO *response_data;
5095 int bytes_returned = 0;
5098 cFYI(1,
"In QFSDeviceInfo");
5106 pSMB->TotalDataCount = 0;
5110 pSMB->MaxSetupCount = 0;
5114 pSMB->Reserved2 = 0;
5115 byte_count = params + 1 ;
5117 pSMB->ParameterCount = pSMB->TotalParameterCount;
5121 pSMB->DataCount = 0;
5122 pSMB->DataOffset = 0;
5123 pSMB->SetupCount = 1;
5124 pSMB->Reserved3 = 0;
5127 inc_rfc1001_len(pSMB, byte_count);
5131 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5133 cFYI(1,
"Send error in QFSDeviceInfo = %d", rc);
5135 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
5137 if (rc || get_bcc(&pSMBr->hdr) <
5138 sizeof(FILE_SYSTEM_DEVICE_INFO))
5143 (FILE_SYSTEM_DEVICE_INFO *)
5144 (((
char *) &pSMBr->hdr.Protocol) +
5147 sizeof(FILE_SYSTEM_DEVICE_INFO));
5153 goto QFSDeviceRetry;
5162 TRANSACTION2_QFSI_REQ *pSMB =
NULL;
5163 TRANSACTION2_QFSI_RSP *pSMBr =
NULL;
5164 FILE_SYSTEM_UNIX_INFO *response_data;
5166 int bytes_returned = 0;
5169 cFYI(1,
"In QFSUnixInfo");
5172 (
void **) &pSMB, (
void **) &pSMBr);
5177 pSMB->TotalDataCount = 0;
5178 pSMB->DataCount = 0;
5179 pSMB->DataOffset = 0;
5183 pSMB->MaxSetupCount = 0;
5187 pSMB->Reserved2 = 0;
5188 byte_count = params + 1 ;
5190 pSMB->TotalParameterCount = pSMB->ParameterCount;
5193 pSMB->SetupCount = 1;
5194 pSMB->Reserved3 = 0;
5197 inc_rfc1001_len(pSMB, byte_count);
5201 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5203 cERROR(1,
"Send error in QFSUnixInfo = %d", rc);
5205 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
5207 if (rc || get_bcc(&pSMBr->hdr) < 13) {
5212 (FILE_SYSTEM_UNIX_INFO
5213 *) (((
char *) &pSMBr->hdr.Protocol) +
5216 sizeof(FILE_SYSTEM_UNIX_INFO));
5232 TRANSACTION2_SETFSI_REQ *pSMB =
NULL;
5233 TRANSACTION2_SETFSI_RSP *pSMBr =
NULL;
5235 int bytes_returned = 0;
5238 cFYI(1,
"In SETFSUnixInfo");
5242 (
void **) &pSMB, (
void **) &pSMBr);
5247 pSMB->MaxSetupCount = 0;
5251 pSMB->Reserved2 = 0;
5254 offset = param_offset +
params;
5259 pSMB->SetupCount = 1;
5260 pSMB->Reserved3 = 0;
5262 byte_count = 1 + params + 12;
5266 pSMB->TotalDataCount = pSMB->DataCount;
5267 pSMB->TotalParameterCount = pSMB->ParameterCount;
5268 pSMB->ParameterOffset =
cpu_to_le16(param_offset);
5280 inc_rfc1001_len(pSMB, byte_count);
5284 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5286 cERROR(1,
"Send error in SETFSUnixInfo = %d", rc);
5288 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
5295 goto SETFSUnixRetry;
5307 TRANSACTION2_QFSI_REQ *pSMB =
NULL;
5308 TRANSACTION2_QFSI_RSP *pSMBr =
NULL;
5309 FILE_SYSTEM_POSIX_INFO *response_data;
5311 int bytes_returned = 0;
5314 cFYI(1,
"In QFSPosixInfo");
5322 pSMB->TotalDataCount = 0;
5323 pSMB->DataCount = 0;
5324 pSMB->DataOffset = 0;
5328 pSMB->MaxSetupCount = 0;
5332 pSMB->Reserved2 = 0;
5333 byte_count = params + 1 ;
5335 pSMB->TotalParameterCount = pSMB->ParameterCount;
5338 pSMB->SetupCount = 1;
5339 pSMB->Reserved3 = 0;
5342 inc_rfc1001_len(pSMB, byte_count);
5346 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5348 cFYI(1,
"Send error in QFSUnixInfo = %d", rc);
5350 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
5352 if (rc || get_bcc(&pSMBr->hdr) < 13) {
5357 (FILE_SYSTEM_POSIX_INFO
5358 *) (((
char *) &pSMBr->hdr.Protocol) +
5366 if (response_data->UserBlocksAvail ==
cpu_to_le64(-1)) {
5372 if (response_data->TotalFileNodes !=
cpu_to_le64(-1))
5375 if (response_data->FreeFileNodes !=
cpu_to_le64(-1))
5398 bool set_allocation)
5405 int bytes_returned = 0;
5410 cFYI(1,
"In SetEOF");
5439 offset = param_offset +
params;
5440 if (set_allocation) {
5470 inc_rfc1001_len(pSMB, byte_count);
5474 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5476 cFYI(1,
"SetPathInfo (file size) returned %d", rc);
5495 cFYI(1,
"SetFileSize (via SetFileInfo) %lld",
5512 offset = param_offset +
params;
5521 byte_count = 3 + params +
count;
5532 pSMB->
Fid = cfile->
fid.netfid;
5533 if (set_allocation) {
5549 inc_rfc1001_len(pSMB, byte_count);
5553 cFYI(1,
"Send error in SetFileInfo (SetFileSize) = %d", rc);
5577 cFYI(1,
"Set Times (via SetFileInfo)");
5593 offset = param_offset +
params;
5595 data_offset = (
char *)pSMB +
5598 count =
sizeof(FILE_BASIC_INFO);
5605 byte_count = 3 + params +
count;
5618 inc_rfc1001_len(pSMB, byte_count);
5620 memcpy(data_offset, data,
sizeof(FILE_BASIC_INFO));
5623 cFYI(1,
"Send error in Set Time (SetFileInfo) = %d", rc);
5633 bool delete_file,
__u16 fid,
__u32 pid_of_opener)
5640 cFYI(1,
"Set File Disposition (via SetFileInfo)");
5656 offset = param_offset +
params;
5658 data_offset = (
char *) (&pSMB->
hdr.Protocol) +
offset;
5667 byte_count = 3 + params +
count;
5677 inc_rfc1001_len(pSMB, byte_count);
5679 *data_offset = delete_file ? 1 : 0;
5682 cFYI(1,
"Send error in SetFileDisposition = %d", rc);
5689 const char *fileName,
const FILE_BASIC_INFO *
data,
5690 const struct nls_table *nls_codepage,
int remap)
5692 TRANSACTION2_SPI_REQ *pSMB =
NULL;
5693 TRANSACTION2_SPI_RSP *pSMBr =
NULL;
5696 int bytes_returned = 0;
5700 cFYI(1,
"In SetTimes");
5717 strncpy(pSMB->FileName, fileName, name_len);
5721 count =
sizeof(FILE_BASIC_INFO);
5725 pSMB->MaxSetupCount = 0;
5729 pSMB->Reserved2 = 0;
5732 offset = param_offset +
params;
5733 data_offset = (
char *) (&pSMB->hdr.Protocol) +
offset;
5734 pSMB->ParameterOffset =
cpu_to_le16(param_offset);
5736 pSMB->SetupCount = 1;
5737 pSMB->Reserved3 = 0;
5739 byte_count = 3 + params +
count;
5743 pSMB->TotalDataCount = pSMB->DataCount;
5744 pSMB->TotalParameterCount = pSMB->ParameterCount;
5749 pSMB->Reserved4 = 0;
5750 inc_rfc1001_len(pSMB, byte_count);
5751 memcpy(data_offset, data,
sizeof(FILE_BASIC_INFO));
5754 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5756 cFYI(1,
"SetPathInfo (times) returned %d", rc);
5772 CIFSSMBSetAttrLegacy(
unsigned int xid,
struct cifs_tcon *tcon,
char *fileName,
5775 SETATTR_REQ *pSMB =
NULL;
5776 SETATTR_RSP *pSMBr =
NULL;
5781 cFYI(1,
"In SetAttrLegacy");
5791 ConvertToUTF16((
__le16 *) pSMB->fileName, fileName,
5798 strncpy(pSMB->fileName, fileName, name_len);
5801 pSMB->BufferFormat = 0x04;
5802 inc_rfc1001_len(pSMB, name_len + 1);
5805 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5807 cFYI(1,
"Error in LegacySetAttr = %d", rc);
5812 goto SetAttrLgcyRetry;
5819 cifs_fill_unix_set_info(FILE_UNIX_BASIC_INFO *data_offset,
5862 u16 fid,
u32 pid_of_opener)
5869 cFYI(1,
"Set Unix Info (via SetFileInfo)");
5885 offset = param_offset +
params;
5887 data_offset = (
char *)pSMB +
5890 count =
sizeof(FILE_UNIX_BASIC_INFO);
5898 byte_count = 3 + params +
count;
5908 inc_rfc1001_len(pSMB, byte_count);
5911 cifs_fill_unix_set_info((FILE_UNIX_BASIC_INFO *)data_offset, args);
5915 cFYI(1,
"Send error in Set Time (SetFileInfo) = %d", rc);
5927 const struct nls_table *nls_codepage,
int remap)
5929 TRANSACTION2_SPI_REQ *pSMB =
NULL;
5930 TRANSACTION2_SPI_RSP *pSMBr =
NULL;
5933 int bytes_returned = 0;
5937 cFYI(1,
"In SetUID/GID/Mode");
5953 strncpy(pSMB->FileName, file_name, name_len);
5957 count =
sizeof(FILE_UNIX_BASIC_INFO);
5961 pSMB->MaxSetupCount = 0;
5965 pSMB->Reserved2 = 0;
5968 offset = param_offset +
params;
5970 (FILE_UNIX_BASIC_INFO *) ((
char *) &pSMB->hdr.Protocol +
5972 memset(data_offset, 0, count);
5974 pSMB->ParameterOffset =
cpu_to_le16(param_offset);
5975 pSMB->SetupCount = 1;
5976 pSMB->Reserved3 = 0;
5978 byte_count = 3 + params +
count;
5981 pSMB->TotalParameterCount = pSMB->ParameterCount;
5982 pSMB->TotalDataCount = pSMB->DataCount;
5984 pSMB->Reserved4 = 0;
5985 inc_rfc1001_len(pSMB, byte_count);
5987 cifs_fill_unix_set_info(data_offset, args);
5991 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
5993 cFYI(1,
"SetPathInfo (perms) returned %d", rc);
6001 #ifdef CONFIG_CIFS_XATTR
6013 const unsigned char *searchName,
const unsigned char *ea_name,
6015 const struct nls_table *nls_codepage,
int remap)
6018 TRANSACTION2_QPI_REQ *pSMB =
NULL;
6019 TRANSACTION2_QPI_RSP *pSMBr =
NULL;
6023 struct fealist *ea_response_data;
6024 struct fea *temp_fea;
6028 unsigned int ea_name_len = ea_name ?
strlen(ea_name) : 0;
6030 cFYI(1,
"In Query All EAs path %s", searchName);
6046 strncpy(pSMB->FileName, searchName, list_len);
6049 params = 2 + 4 + list_len ;
6050 pSMB->TotalDataCount = 0;
6054 pSMB->MaxSetupCount = 0;
6058 pSMB->Reserved2 = 0;
6061 pSMB->DataCount = 0;
6062 pSMB->DataOffset = 0;
6063 pSMB->SetupCount = 1;
6064 pSMB->Reserved3 = 0;
6066 byte_count = params + 1 ;
6068 pSMB->ParameterCount = pSMB->TotalParameterCount;
6070 pSMB->Reserved4 = 0;
6071 inc_rfc1001_len(pSMB, byte_count);
6075 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
6077 cFYI(1,
"Send error in QueryAllEAs = %d", rc);
6086 rc = validate_t2((
struct smb_t2_rsp *)pSMBr);
6087 if (rc || get_bcc(&pSMBr->hdr) < 4) {
6101 ea_response_data = (
struct fealist *)
6105 cFYI(1,
"ea length %d", list_len);
6106 if (list_len <= 8) {
6107 cFYI(1,
"empty EA list returned from server");
6112 end_of_smb = (
char *)
pByteArea(&pSMBr->hdr) + get_bcc(&pSMBr->hdr);
6113 if ((
char *)ea_response_data + list_len > end_of_smb) {
6114 cFYI(1,
"EA list appears to go beyond SMB");
6121 temp_fea = ea_response_data->
list;
6122 temp_ptr = (
char *)temp_fea;
6123 while (list_len > 0) {
6131 cFYI(1,
"EA entry goes beyond length of list");
6140 cFYI(1,
"EA entry goes beyond length of list");
6146 if (ea_name_len == name_len &&
6147 memcmp(ea_name, temp_ptr, name_len) == 0) {
6148 temp_ptr += name_len + 1;
6152 if ((
size_t)value_len > buf_size) {
6156 memcpy(EAData, temp_ptr, value_len);
6163 memcpy(EAData,
"user.", 5);
6165 memcpy(EAData, temp_ptr, name_len);
6170 }
else if (buf_size == 0) {
6179 temp_fea = (
struct fea *)temp_ptr;
6196 const char *fileName,
const char *ea_name,
const void *ea_value,
6205 int bytes_returned = 0;
6208 cFYI(1,
"In SetEA");
6232 if (ea_name ==
NULL)
6235 name_len =
strnlen(ea_name, 255);
6237 count =
sizeof(*parm_data) + ea_value_len +
name_len;
6248 offset = param_offset +
params;
6253 (
struct fealist *) (((
char *) &pSMB->
hdr.Protocol) +
6260 byte_count = 3 + params +
count;
6263 parm_data->
list[0].EA_flags = 0;
6265 parm_data->
list[0].name_len = (
__u8)name_len;
6268 strncpy(parm_data->
list[0].name, ea_name, name_len);
6279 ea_value, ea_value_len);
6285 inc_rfc1001_len(pSMB, byte_count);
6288 (
struct smb_hdr *) pSMBr, &bytes_returned, 0);
6290 cFYI(1,
"SetPathInfo (EA) returned %d", rc);
6301 #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL
6322 int CIFSSMBNotify(
const unsigned int xid,
struct cifs_tcon *tcon,
6323 const int notify_subdirs,
const __u16 netfid,
6329 struct smb_com_ntransaction_change_notify_rsp *pSMBr =
NULL;
6333 cFYI(1,
"In CIFSSMBNotify for file handle %d", (
int)netfid);
6359 (
struct smb_hdr *)pSMBr, &bytes_returned,
6362 cFYI(1,
"Error in Notify = %d", rc);
6370 dnotify_req->
Pid = pSMB->
hdr.Pid;
6372 dnotify_req->
Mid = pSMB->
hdr.Mid;
6373 dnotify_req->
Tid = pSMB->
hdr.Tid;
6374 dnotify_req->
Uid = pSMB->
hdr.Uid;
6381 &GlobalDnotifyReqList);