From: Volker Lendecke Date: Thu, 28 Feb 2019 20:47:51 +0000 (+0100) Subject: libsmb: Make cli_posix_unlink/rmdir proper tevent_req/subreq pairs X-Git-Tag: talloc-2.2.0~211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1c2fe89073bf463a5791d433f60bc9381bdad62;p=thirdparty%2Fsamba.git libsmb: Make cli_posix_unlink/rmdir proper tevent_req/subreq pairs Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat Mar 2 00:55:56 UTC 2019 on sn-devel-144 --- diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 7d72dc82858..49e58c0d252 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -5486,13 +5486,43 @@ static void cli_posix_unlink_internal_done(struct tevent_req *subreq) tevent_req_simple_finish_ntstatus(subreq, status); } +static NTSTATUS cli_posix_unlink_internal_recv(struct tevent_req *req) +{ + return tevent_req_simple_recv_ntstatus(req); +} + +struct cli_posix_unlink_state { + uint8_t dummy; +}; + +static void cli_posix_unlink_done(struct tevent_req *subreq); + struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, const char *fname) { - return cli_posix_unlink_internal_send(mem_ctx, ev, cli, fname, - SMB_POSIX_UNLINK_FILE_TARGET); + struct tevent_req *req = NULL, *subreq = NULL; + struct cli_posix_unlink_state *state; + + req = tevent_req_create( + mem_ctx, &state, struct cli_posix_unlink_state); + if (req == NULL) { + return NULL; + } + subreq = cli_posix_unlink_internal_send( + mem_ctx, ev, cli, fname, SMB_POSIX_UNLINK_FILE_TARGET); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_posix_unlink_done, req); + return req; +} + +static void cli_posix_unlink_done(struct tevent_req *subreq) +{ + NTSTATUS status = cli_posix_unlink_internal_recv(subreq); + tevent_req_simple_finish_ntstatus(subreq, status); } NTSTATUS cli_posix_unlink_recv(struct tevent_req *req) @@ -5549,14 +5579,37 @@ NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname) rmdir - POSIX semantics. ****************************************************************************/ +struct cli_posix_rmdir_state { + uint8_t dummy; +}; + +static void cli_posix_rmdir_done(struct tevent_req *subreq); + struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, const char *fname) { - return cli_posix_unlink_internal_send( - mem_ctx, ev, cli, fname, - SMB_POSIX_UNLINK_DIRECTORY_TARGET); + struct tevent_req *req = NULL, *subreq = NULL; + struct cli_posix_rmdir_state *state; + + req = tevent_req_create(mem_ctx, &state, struct cli_posix_rmdir_state); + if (req == NULL) { + return NULL; + } + subreq = cli_posix_unlink_internal_send( + mem_ctx, ev, cli, fname, SMB_POSIX_UNLINK_DIRECTORY_TARGET); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_posix_rmdir_done, req); + return req; +} + +static void cli_posix_rmdir_done(struct tevent_req *subreq) +{ + NTSTATUS status = cli_posix_unlink_internal_recv(subreq); + tevent_req_simple_finish_ntstatus(subreq, status); } NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)