CIFS: Clarify SMB1 code for POSIX Create
[linux-2.6-microblaze.git] / fs / cifs / cifssmb.c
index 58ebec4..d4144c1 100644 (file)
@@ -1081,7 +1081,8 @@ PsxCreat:
        param_offset = offsetof(struct smb_com_transaction2_spi_req,
                                InformationLevel) - 4;
        offset = param_offset + params;
-       pdata = (OPEN_PSX_REQ *)(((char *)&pSMB->hdr.Protocol) + offset);
+       /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
+       pdata = (OPEN_PSX_REQ *)((char *)(pSMB) + offset + 4);
        pdata->Level = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC);
        pdata->Permissions = cpu_to_le64(mode);
        pdata->PosixOpenFlags = cpu_to_le32(posix_flags);
@@ -2537,8 +2538,9 @@ CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
        pSMB->TotalDataCount = pSMB->DataCount;
        pSMB->TotalParameterCount = pSMB->ParameterCount;
        pSMB->ParameterOffset = cpu_to_le16(param_offset);
+       /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
        parm_data = (struct cifs_posix_lock *)
-                       (((char *) &pSMB->hdr.Protocol) + offset);
+                       (((char *)pSMB) + offset + 4);
 
        parm_data->lock_type = cpu_to_le16(lock_type);
        if (waitFlag) {
@@ -2767,7 +2769,8 @@ int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *pTcon,
        param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
        offset = param_offset + params;
 
-       data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
+       /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
+       data_offset = (char *)(pSMB) + offset + 4;
        rename_info = (struct set_file_rename *) data_offset;
        pSMB->MaxParameterCount = cpu_to_le16(2);
        pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB from sess */
@@ -2925,7 +2928,8 @@ createSymLinkRetry:
                                InformationLevel) - 4;
        offset = param_offset + params;
 
-       data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
+       /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
+       data_offset = (char *)pSMB + offset + 4;
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len_target =
                    cifsConvertToUTF16((__le16 *) data_offset, toName,
@@ -3009,7 +3013,8 @@ createHardLinkRetry:
                                InformationLevel) - 4;
        offset = param_offset + params;
 
-       data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
+       /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
+       data_offset = (char *)pSMB + offset + 4;
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len_target =
                    cifsConvertToUTF16((__le16 *) data_offset, fromName,
@@ -5626,9 +5631,9 @@ CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
        pSMB->TotalDataCount = pSMB->DataCount;
        pSMB->TotalParameterCount = pSMB->ParameterCount;
        pSMB->ParameterOffset = cpu_to_le16(param_offset);
+       /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
        parm_data =
-               (struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol)
-                               + offset);
+               (struct file_end_of_file_info *)(((char *)pSMB) + offset + 4);
        pSMB->DataOffset = cpu_to_le16(offset);
        parm_data->FileSize = cpu_to_le64(size);
        pSMB->Fid = cfile->fid.netfid;
@@ -5761,7 +5766,8 @@ CIFSSMBSetFileDisposition(const unsigned int xid, struct cifs_tcon *tcon,
        param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
        offset = param_offset + params;
 
-       data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
+       /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
+       data_offset = (char *)(pSMB) + offset + 4;
 
        count = 1;
        pSMB->MaxParameterCount = cpu_to_le16(2);
@@ -6062,9 +6068,8 @@ setPermsRetry:
        param_offset = offsetof(struct smb_com_transaction2_spi_req,
                                InformationLevel) - 4;
        offset = param_offset + params;
-       data_offset =
-           (FILE_UNIX_BASIC_INFO *) ((char *) &pSMB->hdr.Protocol +
-                                     offset);
+       /* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
+       data_offset = (FILE_UNIX_BASIC_INFO *)((char *) pSMB + offset + 4);
        memset(data_offset, 0, count);
        pSMB->DataOffset = cpu_to_le16(offset);
        pSMB->ParameterOffset = cpu_to_le16(param_offset);