summaryrefslogtreecommitdiff
path: root/source3/libsmb/clifile.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-06-20 08:41:59 +0000
committerVolker Lendecke <vl@samba.org>2014-06-21 20:38:11 +0200
commit891e63b4bef9ca28fedd311a0e02192e9a0ded19 (patch)
treee188b59ec7ee0bb33286eaa5780f29bfa29d6991 /source3/libsmb/clifile.c
parentf0876ff68a664ab5dd10ae77cddf2186e8a39768 (diff)
downloadsamba-891e63b4bef9ca28fedd311a0e02192e9a0ded19.tar.gz
libsmb: Add cli_create_send/recv
Async wrapper around smb1 and smb2 create Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/libsmb/clifile.c')
-rw-r--r--source3/libsmb/clifile.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 1c527303e66..6fd4f39e3b3 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1919,6 +1919,90 @@ NTSTATUS cli_ntcreate_recv(struct tevent_req *req,
return NT_STATUS_OK;
}
+struct cli_create_state {
+ NTSTATUS (*recv)(struct tevent_req *req, uint16_t *fnum,
+ struct smb_create_returns *cr);
+ struct smb_create_returns cr;
+ uint16_t fnum;
+};
+
+static void cli_create_done(struct tevent_req *subreq);
+
+struct tevent_req *cli_create_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ const char *fname,
+ uint32_t create_flags,
+ uint32_t desired_access,
+ uint32_t file_attributes,
+ uint32_t share_access,
+ uint32_t create_disposition,
+ uint32_t create_options,
+ uint8_t security_flags)
+{
+ struct tevent_req *req, *subreq;
+ struct cli_create_state *state;
+
+ req = tevent_req_create(mem_ctx, &state, struct cli_create_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+ state->recv = cli_smb2_create_fnum_recv;
+ subreq = cli_smb2_create_fnum_send(
+ state, ev, cli, fname, create_flags, desired_access,
+ file_attributes, share_access, create_disposition,
+ create_options);
+ } else {
+ state->recv = cli_ntcreate_recv;
+ subreq = cli_ntcreate_send(
+ state, ev, cli, fname, create_flags, desired_access,
+ file_attributes, share_access, create_disposition,
+ create_options, security_flags);
+ }
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, cli_create_done, req);
+ return req;
+}
+
+static void cli_create_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct cli_create_state *state = tevent_req_data(
+ req, struct cli_create_state);
+ NTSTATUS status;
+
+ status = state->recv(subreq, &state->fnum, &state->cr);
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ tevent_req_done(req);
+}
+
+NTSTATUS cli_create_recv(struct tevent_req *req, uint16_t *fnum,
+ struct smb_create_returns *cr)
+{
+ struct cli_create_state *state = tevent_req_data(
+ req, struct cli_create_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ if (fnum != NULL) {
+ *fnum = state->fnum;
+ }
+ if (cr != NULL) {
+ *cr = state->cr;
+ }
+ return NT_STATUS_OK;
+}
+
NTSTATUS cli_ntcreate(struct cli_state *cli,
const char *fname,
uint32_t CreatFlags,