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)