diff options
author | Volker Lendecke <vl@samba.org> | 2019-02-28 21:47:51 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-03-02 00:55:56 +0000 |
commit | d1c2fe89073bf463a5791d433f60bc9381bdad62 (patch) | |
tree | 74d2b06088cd3e8356fe43556d0fd8939972022f /source3 | |
parent | 65c269d53821bbb2e050ee5f557d6b8806f8ac76 (diff) | |
download | samba-d1c2fe89073bf463a5791d433f60bc9381bdad62.tar.gz |
libsmb: Make cli_posix_unlink/rmdir proper tevent_req/subreq pairs
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Mar 2 00:55:56 UTC 2019 on sn-devel-144
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libsmb/clifile.c | 63 |
1 files changed, 58 insertions, 5 deletions
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) |