libsmb: Make cli_posix_unlink/rmdir proper tevent_req/subreq pairs
authorVolker Lendecke <vl@samba.org>
Thu, 28 Feb 2019 20:47:51 +0000 (21:47 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 2 Mar 2019 00:55:56 +0000 (00:55 +0000)
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

source3/libsmb/clifile.c

index 7d72dc82858eb665a019faf0a67a37cf25228f02..49e58c0d252acad6498e7abb6560dee98bae19e5 100644 (file)
@@ -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)