summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-03-27 17:04:56 +0200
committerVolker Lendecke <vl@samba.org>2011-03-27 19:04:10 +0200
commit5d9075c0498853010fb8036d4aa71bd6e1b284af (patch)
treefb3ef34ab1040ab835512a7bc363b3f1b1b4efa1
parentb47b4c9e3dd1a3776f38b879041fb83a0edb6c36 (diff)
downloadsamba-5d9075c0498853010fb8036d4aa71bd6e1b284af.tar.gz
samba-5d9075c0498853010fb8036d4aa71bd6e1b284af.tar.bz2
samba-5d9075c0498853010fb8036d4aa71bd6e1b284af.zip
s3: Remove a use of cli_send_smb
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/libsmb/clireadwrite.c83
-rw-r--r--source3/torture/torture.c2
3 files changed, 50 insertions, 39 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a24b7d0019..b5b1c860fc 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2205,8 +2205,8 @@ ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
ssize_t cli_write(struct cli_state *cli,
uint16_t fnum, uint16 write_mode,
const char *buf, off_t offset, size_t size);
-ssize_t cli_smbwrite(struct cli_state *cli,
- uint16_t fnum, char *buf, off_t offset, size_t size1);
+NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
+ off_t offset, size_t size1, size_t *ptotal);
struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli, uint16_t fnum,
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index cd95b17f80..a6620d9f5e 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -856,56 +856,67 @@ ssize_t cli_write(struct cli_state *cli,
write to a file using a SMBwrite and not bypassing 0 byte writes
****************************************************************************/
-ssize_t cli_smbwrite(struct cli_state *cli,
- uint16_t fnum, char *buf, off_t offset, size_t size1)
+NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
+ off_t offset, size_t size1, size_t *ptotal)
{
- char *p;
+ uint8_t *bytes;
ssize_t total = 0;
- do {
- size_t size = MIN(size1, cli->max_xmit - 48);
-
- memset(cli->outbuf,'\0',smb_size);
- memset(cli->inbuf,'\0',smb_size);
-
- cli_set_message(cli->outbuf,5, 0,True);
-
- SCVAL(cli->outbuf,smb_com,SMBwrite);
- SSVAL(cli->outbuf,smb_tid,cli->cnum);
- cli_setup_packet(cli);
-
- SSVAL(cli->outbuf,smb_vwv0,fnum);
- SSVAL(cli->outbuf,smb_vwv1,size);
- SIVAL(cli->outbuf,smb_vwv2,offset);
- SSVAL(cli->outbuf,smb_vwv4,0);
-
- p = smb_buf(cli->outbuf);
- *p++ = 1;
- SSVAL(p, 0, size); p += 2;
- memcpy(p, buf + total, size); p += size;
-
- cli_setup_bcc(cli, p);
+ /*
+ * 3 bytes prefix
+ */
- if (!cli_send_smb(cli))
- return -1;
+ bytes = TALLOC_ARRAY(talloc_tos(), uint8_t, 3);
+ if (bytes == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ bytes[0] = 1;
- if (!cli_receive_smb(cli))
- return -1;
+ do {
+ size_t size = MIN(size1, cli->max_xmit - 48);
+ struct tevent_req *req;
+ uint16_t vwv[5];
+ uint16_t *ret_vwv;
+ NTSTATUS status;
+
+ SSVAL(vwv+0, 0, fnum);
+ SSVAL(vwv+1, 0, size);
+ SIVAL(vwv+2, 0, offset);
+ SSVAL(vwv+4, 0, 0);
+
+ bytes = TALLOC_REALLOC_ARRAY(talloc_tos(), bytes, uint8_t,
+ size+3);
+ if (bytes == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ SSVAL(bytes, 1, size);
+ memcpy(bytes + 3, buf + total, size);
- if (cli_is_error(cli))
- return -1;
+ status = cli_smb(talloc_tos(), cli, SMBwrite, 0, 5, vwv,
+ size+3, bytes, &req, 1, NULL, &ret_vwv,
+ NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(bytes);
+ return status;
+ }
- size = SVAL(cli->inbuf,smb_vwv0);
- if (size == 0)
+ size = SVAL(ret_vwv+0, 0);
+ TALLOC_FREE(req);
+ if (size == 0) {
break;
-
+ }
size1 -= size;
total += size;
offset += size;
} while (size1);
- return total;
+ TALLOC_FREE(bytes);
+
+ if (ptotal != NULL) {
+ *ptotal = total;
+ }
+ return NT_STATUS_OK;
}
/*
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 61cfb9e92f..a2230ec203 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -961,7 +961,7 @@ static bool run_readwritelarge_internal(int max_xmit_k)
cli1->max_xmit = 4*1024;
- cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf));
+ cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf), NULL);
if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
cli1, fnum1, NULL, &fsize, NULL, NULL,