added mkdir to SMB2 proxy
authorAndrew Tridgell <tridge@samba.org>
Mon, 19 May 2008 01:39:16 +0000 (11:39 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 19 May 2008 01:39:16 +0000 (11:39 +1000)
source/libcli/smb_composite/smb2.c
source/ntvfs/smb2/vfs_smb2.c
source/torture/smb2/util.c

index 7bce65fb275b3bbfdf972d788ee9dac60973102a..7fccbe3a3c37958f26bfb028ae4f271e746fc443 100644 (file)
@@ -120,3 +120,75 @@ NTSTATUS smb2_composite_unlink(struct smb2_tree *tree, union smb_unlink *io)
        return composite_wait_free(c);
 }
 
+
+
+
+/*
+  continue after the create in a composite mkdir
+ */
+static void continue_mkdir(struct smb2_request *req)
+{
+       struct composite_context *ctx = talloc_get_type(req->async.private_data, 
+                                                       struct composite_context);
+       struct smb2_tree *tree = req->tree;
+       struct smb2_create create_parm;
+       struct smb2_close close_parm;
+       NTSTATUS status;
+
+       status = smb2_create_recv(req, ctx, &create_parm);
+       if (!NT_STATUS_IS_OK(status)) {
+               composite_error(ctx, status);
+               return;
+       }
+
+       ZERO_STRUCT(close_parm);
+       close_parm.in.file.handle = create_parm.out.file.handle;
+       
+       req = smb2_close_send(tree, &close_parm);
+       composite_continue_smb2(ctx, req, continue_close, ctx);
+}
+
+/*
+  composite SMB2 mkdir call
+*/
+struct composite_context *smb2_composite_mkdir_send(struct smb2_tree *tree, 
+                                                    union smb_mkdir *io)
+{
+       struct composite_context *ctx;
+       struct smb2_create create_parm;
+       struct smb2_request *req;
+
+       ctx = composite_create(tree, tree->session->transport->socket->event.ctx);
+       if (ctx == NULL) return NULL;
+
+       ZERO_STRUCT(create_parm);
+
+       create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+       create_parm.in.share_access = 
+               NTCREATEX_SHARE_ACCESS_READ|
+               NTCREATEX_SHARE_ACCESS_WRITE;
+       create_parm.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+       create_parm.in.file_attributes   = FILE_ATTRIBUTE_DIRECTORY;
+       create_parm.in.create_disposition = NTCREATEX_DISP_CREATE;
+       create_parm.in.fname = io->mkdir.in.path;
+       if (create_parm.in.fname[0] == '\\') {
+               create_parm.in.fname++;
+       }
+
+       req = smb2_create_send(tree, &create_parm);
+
+       composite_continue_smb2(ctx, req, continue_mkdir, ctx);
+
+       return ctx;
+}
+
+
+/*
+  composite mkdir call - sync interface
+*/
+NTSTATUS smb2_composite_mkdir(struct smb2_tree *tree, union smb_mkdir *io)
+{
+       struct composite_context *c = smb2_composite_mkdir_send(tree, io);
+       return composite_wait_free(c);
+}
+
index 13dbb4ea2e05943903dfa8c90eae85c2812fd88c..3a9a74a92887ca132b6875483d0913fb98d0c51f 100644 (file)
@@ -450,7 +450,14 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs,
 static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, 
                           struct ntvfs_request *req, union smb_mkdir *md)
 {
-       return NT_STATUS_NOT_IMPLEMENTED;
+       struct cvfs_private *private = ntvfs->private_data;
+       struct composite_context *c_req;
+
+       CHECK_ASYNC(req);
+
+       c_req = smb2_composite_mkdir_send(private->tree, md);
+
+       SIMPLE_COMPOSITE_TAIL;
 }
 
 /*
index 6ac3926c9883ce9b07ab8114798fa13f140aa030..4995bbe978bb11473d3994300523f1dab961e918 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "libcli/smb2/smb2.h"
 #include "libcli/smb2/smb2_calls.h"
+#include "libcli/smb_composite/smb_composite.h"
 #include "lib/cmdline/popt_common.h"
 #include "lib/events/events.h"
 #include "system/time.h"
@@ -51,27 +52,12 @@ NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h)
 */
 NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname)
 {
-       struct smb2_create io;
-       NTSTATUS status;
-
+       union smb_unlink io;
+       
        ZERO_STRUCT(io);
-       io.in.desired_access = SEC_RIGHTS_FILE_ALL;
-       io.in.file_attributes   = FILE_ATTRIBUTE_NORMAL;
-       io.in.create_disposition = NTCREATEX_DISP_OPEN;
-       io.in.share_access = 
-               NTCREATEX_SHARE_ACCESS_DELETE|
-               NTCREATEX_SHARE_ACCESS_READ|
-               NTCREATEX_SHARE_ACCESS_WRITE;
-       io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
-       io.in.fname = fname;
-
-       status = smb2_create(tree, tree, &io);
-       if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
-               return NT_STATUS_OK;
-       }
-       NT_STATUS_NOT_OK_RETURN(status);
+       io.unlink.in.pattern = fname;
 
-       return smb2_util_close(tree, io.out.file.handle);
+       return smb2_composite_unlink(tree, &io);
 }
 
 /*