Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 326270
b: refs/heads/master
c: 009d344
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Shilovsky authored and Steve French committed Sep 25, 2012
1 parent d28d2b3 commit afea37a
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba9ad7257ae50b8aa72a3f44da839830e065363c
refs/heads/master: 009d344398bb3e844b31eb9e6a7860748c6f6dd3
12 changes: 12 additions & 0 deletions trunk/fs/cifs/smb2ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ smb2_sync_read(const unsigned int xid, struct cifsFileInfo *cfile,
return SMB2_read(xid, parms, bytes_read, buf, buf_type);
}

static int
smb2_sync_write(const unsigned int xid, struct cifsFileInfo *cfile,
struct cifs_io_parms *parms, unsigned int *written,
struct kvec *iov, unsigned long nr_segs)
{

parms->persistent_fid = cfile->fid.persistent_fid;
parms->volatile_fid = cfile->fid.volatile_fid;
return SMB2_write(xid, parms, written, iov, nr_segs);
}

struct smb_version_operations smb21_operations = {
.setup_request = smb2_setup_request,
.setup_async_request = smb2_setup_async_request,
Expand Down Expand Up @@ -447,6 +458,7 @@ struct smb_version_operations smb21_operations = {
.async_readv = smb2_async_readv,
.async_writev = smb2_async_writev,
.sync_read = smb2_sync_read,
.sync_write = smb2_sync_write,
};

struct smb_version_values smb21_values = {
Expand Down
61 changes: 61 additions & 0 deletions trunk/fs/cifs/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,3 +1501,64 @@ smb2_async_writev(struct cifs_writedata *wdata)
kfree(iov);
return rc;
}

/*
* SMB2_write function gets iov pointer to kvec array with n_vec as a length.
* The length field from io_parms must be at least 1 and indicates a number of
* elements with data to write that begins with position 1 in iov array. All
* data length is specified by count.
*/
int
SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
unsigned int *nbytes, struct kvec *iov, int n_vec)
{
int rc = 0;
struct smb2_write_req *req = NULL;
struct smb2_write_rsp *rsp = NULL;
int resp_buftype;
*nbytes = 0;

if (n_vec < 1)
return rc;

rc = small_smb2_init(SMB2_WRITE, io_parms->tcon, (void **) &req);
if (rc)
return rc;

if (io_parms->tcon->ses->server == NULL)
return -ECONNABORTED;

req->hdr.ProcessId = cpu_to_le32(io_parms->pid);

req->PersistentFileId = io_parms->persistent_fid;
req->VolatileFileId = io_parms->volatile_fid;
req->WriteChannelInfoOffset = 0;
req->WriteChannelInfoLength = 0;
req->Channel = 0;
req->Length = cpu_to_le32(io_parms->length);
req->Offset = cpu_to_le64(io_parms->offset);
/* 4 for rfc1002 length field */
req->DataOffset = cpu_to_le16(
offsetof(struct smb2_write_req, Buffer) - 4);
req->RemainingBytes = 0;

iov[0].iov_base = (char *)req;
/* 4 for rfc1002 length field and 1 for Buffer */
iov[0].iov_len = get_rfc1002_length(req) + 4 - 1;

/* length of entire message including data to be written */
inc_rfc1001_len(req, io_parms->length - 1 /* Buffer */);

rc = SendReceive2(xid, io_parms->tcon->ses, iov, n_vec + 1,
&resp_buftype, 0);

if (rc) {
cifs_stats_fail_inc(io_parms->tcon, SMB2_WRITE_HE);
cERROR(1, "Send error in write = %d", rc);
} else {
rsp = (struct smb2_write_rsp *)iov[0].iov_base;
*nbytes = le32_to_cpu(rsp->DataLength);
free_rsp_buf(resp_buftype, rsp);
}
return rc;
}
2 changes: 2 additions & 0 deletions trunk/fs/cifs/smb2proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ extern int smb2_async_readv(struct cifs_readdata *rdata);
extern int SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
unsigned int *nbytes, char **buf, int *buf_type);
extern int smb2_async_writev(struct cifs_writedata *wdata);
extern int SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
unsigned int *nbytes, struct kvec *iov, int n_vec);
extern int SMB2_echo(struct TCP_Server_Info *server);

#endif /* _SMB2PROTO_H */

0 comments on commit afea37a

Please sign in to comment.