summaryrefslogtreecommitdiff
path: root/libcli/smb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-08-07 14:41:24 -0700
committerStefan Metzmacher <metze@samba.org>2013-08-15 09:07:05 +0200
commit00f784ec91d2cfa95b20327ac20f5bc3fa1f400e (patch)
treef0dfed5bd884049cccd80468295c367e72e7eee6 /libcli/smb
parent97288b7f1048c1bf712463293a1e62737738292c (diff)
downloadsamba-00f784ec91d2cfa95b20327ac20f5bc3fa1f400e.tar.gz
samba-00f784ec91d2cfa95b20327ac20f5bc3fa1f400e.tar.bz2
samba-00f784ec91d2cfa95b20327ac20f5bc3fa1f400e.zip
libcli/smb: Fix smb2cli_write_recv() and smb2cli_write() to return the bytes written.
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'libcli/smb')
-rw-r--r--libcli/smb/smb2cli_write.c30
-rw-r--r--libcli/smb/smbXcli_base.h6
2 files changed, 29 insertions, 7 deletions
diff --git a/libcli/smb/smb2cli_write.c b/libcli/smb/smb2cli_write.c
index 8e65460fcb..89137bd5ba 100644
--- a/libcli/smb/smb2cli_write.c
+++ b/libcli/smb/smb2cli_write.c
@@ -26,6 +26,7 @@
struct smb2cli_write_state {
uint8_t fixed[48];
uint8_t dyn_pad[1];
+ uint32_t written;
};
static void smb2cli_write_done(struct tevent_req *subreq);
@@ -94,7 +95,11 @@ static void smb2cli_write_done(struct tevent_req *subreq)
struct tevent_req *req =
tevent_req_callback_data(subreq,
struct tevent_req);
+ struct smb2cli_write_state *state =
+ tevent_req_data(req,
+ struct smb2cli_write_state);
NTSTATUS status;
+ struct iovec *iov;
static const struct smb2cli_req_expected_response expected[] = {
{
.status = NT_STATUS_OK,
@@ -102,18 +107,32 @@ static void smb2cli_write_done(struct tevent_req *subreq)
}
};
- status = smb2cli_req_recv(subreq, NULL, NULL,
+ status = smb2cli_req_recv(subreq, state, &iov,
expected, ARRAY_SIZE(expected));
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
}
+ state->written = IVAL(iov[1].iov_base, 4);
tevent_req_done(req);
}
-NTSTATUS smb2cli_write_recv(struct tevent_req *req)
+NTSTATUS smb2cli_write_recv(struct tevent_req *req, uint32_t *written)
{
- return tevent_req_simple_recv_ntstatus(req);
+ struct smb2cli_write_state *state =
+ tevent_req_data(req,
+ struct smb2cli_write_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ tevent_req_received(req);
+ return status;
+ }
+ if (written) {
+ *written = state->written;
+ }
+ tevent_req_received(req);
+ return NT_STATUS_OK;
}
NTSTATUS smb2cli_write(struct smbXcli_conn *conn,
@@ -126,7 +145,8 @@ NTSTATUS smb2cli_write(struct smbXcli_conn *conn,
uint64_t fid_volatile,
uint32_t remaining_bytes,
uint32_t flags,
- const uint8_t *data)
+ const uint8_t *data,
+ uint32_t *written)
{
TALLOC_CTX *frame = talloc_stackframe();
struct tevent_context *ev;
@@ -155,7 +175,7 @@ NTSTATUS smb2cli_write(struct smbXcli_conn *conn,
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
- status = smb2cli_write_recv(req);
+ status = smb2cli_write_recv(req, written);
fail:
TALLOC_FREE(frame);
return status;
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index f7b60d30bb..997869ba07 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -429,7 +429,8 @@ struct tevent_req *smb2cli_write_send(TALLOC_CTX *mem_ctx,
uint32_t remaining_bytes,
uint32_t flags,
const uint8_t *data);
-NTSTATUS smb2cli_write_recv(struct tevent_req *req);
+NTSTATUS smb2cli_write_recv(struct tevent_req *req,
+ uint32_t *written);
NTSTATUS smb2cli_write(struct smbXcli_conn *conn,
uint32_t timeout_msec,
struct smbXcli_session *session,
@@ -440,7 +441,8 @@ NTSTATUS smb2cli_write(struct smbXcli_conn *conn,
uint64_t fid_volatile,
uint32_t remaining_bytes,
uint32_t flags,
- const uint8_t *data);
+ const uint8_t *data,
+ uint32_t *written);
struct tevent_req *smb2cli_flush_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,