Commit f50a21f7 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] cifs: annotate TRANSACTION2_SFI_{REQ,RESP}

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 60e1981a
...@@ -1174,49 +1174,49 @@ typedef struct smb_com_transaction2_spi_rsp { ...@@ -1174,49 +1174,49 @@ typedef struct smb_com_transaction2_spi_rsp {
} TRANSACTION2_SPI_RSP; } TRANSACTION2_SPI_RSP;
struct set_file_rename { struct set_file_rename {
__u32 overwrite; /* 1 = overwrite dest */ __le32 overwrite; /* 1 = overwrite dest */
__u32 root_fid; /* zero */ __u32 root_fid; /* zero */
__u32 target_name_len; __le32 target_name_len;
char target_name[0]; /* Must be unicode */ char target_name[0]; /* Must be unicode */
}; };
struct smb_com_transaction2_sfi_req { struct smb_com_transaction2_sfi_req {
struct smb_hdr hdr; /* wct = 15 */ struct smb_hdr hdr; /* wct = 15 */
__u16 TotalParameterCount; __le16 TotalParameterCount;
__u16 TotalDataCount; __le16 TotalDataCount;
__u16 MaxParameterCount; __le16 MaxParameterCount;
__u16 MaxDataCount; __le16 MaxDataCount;
__u8 MaxSetupCount; __u8 MaxSetupCount;
__u8 Reserved; __u8 Reserved;
__u16 Flags; __le16 Flags;
__u32 Timeout; __le32 Timeout;
__u16 Reserved2; __u16 Reserved2;
__u16 ParameterCount; __le16 ParameterCount;
__u16 ParameterOffset; __le16 ParameterOffset;
__u16 DataCount; __le16 DataCount;
__u16 DataOffset; __le16 DataOffset;
__u8 SetupCount; __u8 SetupCount;
__u8 Reserved3; __u8 Reserved3;
__u16 SubCommand; /* one setup word */ __le16 SubCommand; /* one setup word */
__u16 ByteCount; __le16 ByteCount;
__u8 Pad; __u8 Pad;
__u16 Pad1; __u16 Pad1;
__u16 Fid; __u16 Fid;
__u16 InformationLevel; __le16 InformationLevel;
__u16 Reserved4; __u16 Reserved4;
}; };
struct smb_com_transaction2_sfi_rsp { struct smb_com_transaction2_sfi_rsp {
struct smb_hdr hdr; /* wct = 10 + SetupCount */ struct smb_hdr hdr; /* wct = 10 + SetupCount */
__u16 TotalParameterCount; __le16 TotalParameterCount;
__u16 TotalDataCount; __le16 TotalDataCount;
__u16 Reserved; __u16 Reserved;
__u16 ParameterCount; __le16 ParameterCount;
__u16 ParameterOffset; __le16 ParameterOffset;
__u16 ParameterDisplacement; __le16 ParameterDisplacement;
__u16 DataCount; __le16 DataCount;
__u16 DataOffset; __le16 DataOffset;
__u16 DataDisplacement; __le16 DataDisplacement;
__u8 SetupCount; __u8 SetupCount;
__u8 Reserved1; /* should be zero setup words following */ __u8 Reserved1; /* should be zero setup words following */
__u16 ByteCount; __u16 ByteCount;
......
...@@ -977,6 +977,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, ...@@ -977,6 +977,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
int rc = 0; int rc = 0;
int bytes_returned = 0; int bytes_returned = 0;
int len_of_str; int len_of_str;
__u16 params, param_offset, offset, count, byte_count;
cFYI(1, ("Rename to File by handle")); cFYI(1, ("Rename to File by handle"));
rc = smb_init(SMB_COM_TRANSACTION2, 15, pTcon, (void **) &pSMB, rc = smb_init(SMB_COM_TRANSACTION2, 15, pTcon, (void **) &pSMB,
...@@ -984,28 +985,27 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, ...@@ -984,28 +985,27 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
if (rc) if (rc)
return rc; return rc;
pSMB->ParameterCount = 6; params = 6;
pSMB->MaxSetupCount = 0; pSMB->MaxSetupCount = 0;
pSMB->Reserved = 0; pSMB->Reserved = 0;
pSMB->Flags = 0; pSMB->Flags = 0;
pSMB->Timeout = 0; pSMB->Timeout = 0;
pSMB->Reserved2 = 0; pSMB->Reserved2 = 0;
pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_sfi_req, param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
Fid) - 4; offset = param_offset + params;
pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount;
data_offset = (char *) (&pSMB->hdr.Protocol) + pSMB->DataOffset; data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
rename_info = (struct set_file_rename *) data_offset; rename_info = (struct set_file_rename *) data_offset;
pSMB->MaxParameterCount = cpu_to_le16(2); pSMB->MaxParameterCount = cpu_to_le16(2);
pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */
pSMB->SetupCount = 1; pSMB->SetupCount = 1;
pSMB->Reserved3 = 0; pSMB->Reserved3 = 0;
pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount; byte_count = 3 /* pad */ + params;
pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); pSMB->ParameterCount = cpu_to_le16(params);
pSMB->TotalParameterCount = pSMB->ParameterCount; pSMB->TotalParameterCount = pSMB->ParameterCount;
pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); pSMB->ParameterOffset = cpu_to_le16(param_offset);
pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); pSMB->DataOffset = cpu_to_le16(offset);
/* construct random name ".cifs_tmp<inodenum><mid>" */ /* construct random name ".cifs_tmp<inodenum><mid>" */
rename_info->overwrite = cpu_to_le32(1); rename_info->overwrite = cpu_to_le32(1);
rename_info->root_fid = 0; rename_info->root_fid = 0;
...@@ -1017,16 +1017,16 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, ...@@ -1017,16 +1017,16 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, target_name, 530, nls_codepage); len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, target_name, 530, nls_codepage);
} }
rename_info->target_name_len = cpu_to_le32(2 * len_of_str); rename_info->target_name_len = cpu_to_le32(2 * len_of_str);
pSMB->DataCount = 12 /* sizeof(struct set_file_rename) */ + (2 * len_of_str) + 2; count = 12 /* sizeof(struct set_file_rename) */ + (2 * len_of_str) + 2;
pSMB->ByteCount += pSMB->DataCount; byte_count += count;
pSMB->DataCount = cpu_to_le16(pSMB->DataCount); pSMB->DataCount = cpu_to_le16(count);
pSMB->TotalDataCount = pSMB->DataCount; pSMB->TotalDataCount = pSMB->DataCount;
pSMB->Fid = netfid; pSMB->Fid = netfid;
pSMB->InformationLevel = pSMB->InformationLevel =
cpu_to_le16(SMB_SET_FILE_RENAME_INFORMATION); cpu_to_le16(SMB_SET_FILE_RENAME_INFORMATION);
pSMB->Reserved4 = 0; pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += pSMB->ByteCount; pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) { if (rc) {
...@@ -2620,6 +2620,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, ...@@ -2620,6 +2620,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
int rc = 0; int rc = 0;
int bytes_returned = 0; int bytes_returned = 0;
__u32 tmp; __u32 tmp;
__u16 params, param_offset, offset, byte_count, count;
cFYI(1, ("SetFileSize (via SetFileInfo) %lld", cFYI(1, ("SetFileSize (via SetFileInfo) %lld",
(long long)size)); (long long)size));
...@@ -2634,34 +2635,33 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, ...@@ -2634,34 +2635,33 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
tmp >>= 16; tmp >>= 16;
pSMB->hdr.PidHigh = tmp & 0xFFFF; pSMB->hdr.PidHigh = tmp & 0xFFFF;
pSMB->ParameterCount = 6; params = 6;
pSMB->MaxSetupCount = 0; pSMB->MaxSetupCount = 0;
pSMB->Reserved = 0; pSMB->Reserved = 0;
pSMB->Flags = 0; pSMB->Flags = 0;
pSMB->Timeout = 0; pSMB->Timeout = 0;
pSMB->Reserved2 = 0; pSMB->Reserved2 = 0;
pSMB->ParameterOffset = offsetof(struct smb_com_transaction2_sfi_req, param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
Fid) - 4; offset = param_offset + params;
pSMB->DataOffset = pSMB->ParameterOffset + pSMB->ParameterCount;
data_offset = (char *) (&pSMB->hdr.Protocol) + pSMB->DataOffset; data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
pSMB->DataCount = sizeof(struct file_end_of_file_info); count = sizeof(struct file_end_of_file_info);
pSMB->MaxParameterCount = cpu_to_le16(2); pSMB->MaxParameterCount = cpu_to_le16(2);
pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */
pSMB->SetupCount = 1; pSMB->SetupCount = 1;
pSMB->Reserved3 = 0; pSMB->Reserved3 = 0;
pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
pSMB->ByteCount = 3 /* pad */ + pSMB->ParameterCount + pSMB->DataCount; byte_count = 3 /* pad */ + params + count;
pSMB->DataCount = cpu_to_le16(pSMB->DataCount); pSMB->DataCount = cpu_to_le16(count);
pSMB->ParameterCount = cpu_to_le16(pSMB->ParameterCount); pSMB->ParameterCount = cpu_to_le16(params);
pSMB->TotalDataCount = pSMB->DataCount; pSMB->TotalDataCount = pSMB->DataCount;
pSMB->TotalParameterCount = pSMB->ParameterCount; pSMB->TotalParameterCount = pSMB->ParameterCount;
pSMB->ParameterOffset = cpu_to_le16(pSMB->ParameterOffset); pSMB->ParameterOffset = cpu_to_le16(param_offset);
parm_data = parm_data =
(struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol) + (struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol) +
pSMB->DataOffset); offset);
pSMB->DataOffset = cpu_to_le16(pSMB->DataOffset); /* now safe to change to le */ pSMB->DataOffset = cpu_to_le16(offset);
parm_data->FileSize = cpu_to_le64(size); parm_data->FileSize = cpu_to_le64(size);
pSMB->Fid = fid; pSMB->Fid = fid;
if(SetAllocation) { if(SetAllocation) {
...@@ -2680,8 +2680,8 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, ...@@ -2680,8 +2680,8 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO); cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO);
} }
pSMB->Reserved4 = 0; pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += pSMB->ByteCount; pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) { if (rc) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment