libsmb: Add sync cli_mknod() for smbclient3's use
authorVolker Lendecke <vl@samba.org>
Wed, 5 Jul 2023 07:06:58 +0000 (09:06 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 25 Sep 2023 17:09:37 +0000 (17:09 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/clifile.c
source3/libsmb/proto.h

index 30c36e4c314254a5a39a59b1c05a0f5c773dd808..daeea4a3a50a8265cdf6ae3aceaed8f6e94b5739 100644 (file)
@@ -1312,6 +1312,38 @@ NTSTATUS cli_mknod_recv(struct tevent_req *req)
        return tevent_req_simple_recv_ntstatus(req);
 }
 
+NTSTATUS
+cli_mknod(struct cli_state *cli, const char *fname, mode_t mode, dev_t dev)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       struct tevent_context *ev;
+       struct tevent_req *req;
+       NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+       if (smbXcli_conn_has_async_calls(cli->conn)) {
+               /*
+                * Can't use sync call while an async call is in flight
+                */
+               status = NT_STATUS_INVALID_PARAMETER;
+               goto fail;
+       }
+       ev = samba_tevent_context_init(frame);
+       if (ev == NULL) {
+               goto fail;
+       }
+       req = cli_mknod_send(ev, ev, cli, fname, mode, dev);
+       if (req == NULL) {
+               goto fail;
+       }
+       if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+               goto fail;
+       }
+       status = cli_mknod_recv(req);
+fail:
+       TALLOC_FREE(frame);
+       return status;
+}
+
 /****************************************************************************
  Rename a file.
 ****************************************************************************/
index 1d17cc8cb76f8625fb7fd0f6929c05c7d00bf877..a7c58264f0ed4b80facd1392c63c83765a7413f3 100644 (file)
@@ -335,6 +335,8 @@ struct tevent_req *cli_mknod_send(
        mode_t mode,
        dev_t dev);
 NTSTATUS cli_mknod_recv(struct tevent_req *req);
+NTSTATUS
+cli_mknod(struct cli_state *cli, const char *fname, mode_t mode, dev_t dev);
 struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
                                   struct tevent_context *ev,
                                   struct cli_state *cli,