From 7b3fccd5b4342494a33081f88b5069b2af9749de Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 24 Oct 2010 16:45:54 +0200 Subject: s3: Add async cli_setpathinfo --- source3/libsmb/clifile.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'source3/libsmb/clifile.c') diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 6ce884adf5..e735a6e3db 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -127,6 +127,84 @@ static uint8_t *trans2_bytes_push_str(uint8_t *buf, bool ucs2, false, pconverted_size); } +struct cli_setpathinfo_state { + uint16_t setup; + uint8_t *param; +}; + +static void cli_setpathinfo_done(struct tevent_req *subreq); + +struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + uint16_t level, + const char *path, + uint8_t *data, + size_t data_len) +{ + struct tevent_req *req, *subreq; + struct cli_setpathinfo_state *state; + + req = tevent_req_create(mem_ctx, &state, + struct cli_setpathinfo_state); + if (req == NULL) { + return NULL; + } + + /* Setup setup word. */ + SSVAL(&state->setup, 0, TRANSACT2_SETPATHINFO); + + /* Setup param array. */ + state->param = TALLOC_ZERO_ARRAY(state, uint8_t, 6); + if (tevent_req_nomem(state->param, req)) { + return tevent_req_post(req, ev); + } + SSVAL(state->param, 0, level); + + state->param = trans2_bytes_push_str( + state->param, cli_ucs2(cli), path, strlen(path)+1, NULL); + if (tevent_req_nomem(state->param, req)) { + return tevent_req_post(req, ev); + } + + subreq = cli_trans_send( + state, /* mem ctx. */ + ev, /* event ctx. */ + cli, /* cli_state. */ + SMBtrans2, /* cmd. */ + NULL, /* pipe name. */ + -1, /* fid. */ + 0, /* function. */ + 0, /* flags. */ + &state->setup, /* setup. */ + 1, /* num setup uint16_t words. */ + 0, /* max returned setup. */ + state->param, /* param. */ + talloc_get_size(state->param), /* num param. */ + 2, /* max returned param. */ + data, /* data. */ + data_len, /* num data. */ + 0); /* max returned data. */ + + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_setpathinfo_done, req); + return req; +} + +static void cli_setpathinfo_done(struct tevent_req *subreq) +{ + NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, NULL, 0, NULL, + NULL, 0, NULL, NULL, 0, NULL); + tevent_req_simple_finish_ntstatus(subreq, status); +} + +NTSTATUS cli_setpathinfo_recv(struct tevent_req *req) +{ + return tevent_req_simple_recv_ntstatus(req); +} + /**************************************************************************** Hard/Symlink a file (UNIX extensions). Creates new name (sym)linked to oldname. -- cgit