From 74f4d62a271e481fb93acf451cecf684921e8104 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Tue, 21 Sep 2004 02:48:14 -0700 Subject: [PATCH] [PATCH] cifs: annotate WRITE_{REQ,RESP} Signed-off-by: Al Viro Signed-off-by: Linus Torvalds --- fs/cifs/cifspdu.h | 26 +++++++++++++------------- fs/cifs/cifssmb.c | 21 +++++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index 34bcde0a7f8a7..37441b5b48500 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h @@ -670,17 +670,17 @@ typedef struct smb_com_write_req { struct smb_hdr hdr; /* wct = 14 */ __u8 AndXCommand; __u8 AndXReserved; - __u16 AndXOffset; + __le16 AndXOffset; __u16 Fid; - __u32 OffsetLow; + __le32 OffsetLow; __u32 Reserved; - __u16 WriteMode; - __u16 Remaining; - __u16 DataLengthHigh; - __u16 DataLengthLow; - __u16 DataOffset; - __u32 OffsetHigh; - __u16 ByteCount; + __le16 WriteMode; + __le16 Remaining; + __le16 DataLengthHigh; + __le16 DataLengthLow; + __le16 DataOffset; + __le32 OffsetHigh; + __le16 ByteCount; __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */ char Data[1]; } WRITE_REQ; @@ -689,10 +689,10 @@ typedef struct smb_com_write_rsp { struct smb_hdr hdr; /* wct = 6 */ __u8 AndXCommand; __u8 AndXReserved; - __u16 AndXOffset; - __u16 Count; - __u16 Remaining; - __u32 Reserved; + __le16 AndXOffset; + __le16 Count; + __le16 Remaining; + __le32 Reserved; __u16 ByteCount; } WRITE_RSP; diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index f2f591ff45ca2..1bcad36a98823 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -739,6 +739,8 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, WRITE_REQ *pSMB = NULL; WRITE_RSP *pSMBr = NULL; int bytes_returned; + unsigned bytes_sent; + __u16 byte_count; rc = smb_init(SMB_COM_WRITE_ANDX, 14, tcon, (void **) &pSMB, (void **) &pSMBr); @@ -753,21 +755,20 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF); pSMB->OffsetHigh = cpu_to_le32(offset >> 32); pSMB->Remaining = 0; - if (count > ((tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFF00)) - pSMB->DataLengthLow = - (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFF00; - else - pSMB->DataLengthLow = count; + bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & ~0xFF; + if (bytes_sent > count) + bytes_sent = count; pSMB->DataLengthHigh = 0; pSMB->DataOffset = cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4); - memcpy(pSMB->Data,buf,pSMB->DataLengthLow); + memcpy(pSMB->Data,buf,bytes_sent); - pSMB->ByteCount += pSMB->DataLengthLow + 1 /* pad */ ; - pSMB->DataLengthLow = cpu_to_le16(pSMB->DataLengthLow); - pSMB->hdr.smb_buf_length += pSMB->ByteCount; - pSMB->ByteCount = cpu_to_le16(pSMB->ByteCount); + byte_count = bytes_sent + 1 /* pad */ ; + pSMB->DataLengthLow = cpu_to_le16(bytes_sent); + pSMB->DataLengthHigh = 0; + pSMB->hdr.smb_buf_length += byte_count; + pSMB->ByteCount = cpu_to_le16(byte_count); rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, (struct smb_hdr *) pSMBr, &bytes_returned, long_op); -- 2.53.0