From 1b2e8caad3fb01ea3b61bda63965d324de61c815 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 13:08:31 +0000 Subject: r11680: added smb2_close(). This also demonstrates that file handles are 16 bytes, not 20 bytes (metze, you were right!) (This used to be commit d3bcc6628cde9ddedf0fd408cbee573f133ce582) --- source4/torture/smb2/connect.c | 52 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'source4/torture/smb2') diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c index 955df4c890..ee323a8b3a 100644 --- a/source4/torture/smb2/connect.c +++ b/source4/torture/smb2/connect.c @@ -203,6 +203,7 @@ static struct smb2_handle torture_smb2_create(struct smb2_tree *tree, { struct smb2_create io; NTSTATUS status; + TALLOC_CTX *tmp_ctx = talloc_new(tree); ZERO_STRUCT(io); io.in.unknown1 = 0x09000039; @@ -216,12 +217,49 @@ static struct smb2_handle torture_smb2_create(struct smb2_tree *tree, return io.out.handle; } - printf("Open gave handle:\n"); - dump_data(0, io.out.handle.data, 20); + printf("Open gave:\n"); + printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time)); + printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time)); + printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time)); + printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time)); + printf("handle = %016llx%016llx\n", + io.out.handle.data[0], + io.out.handle.data[1]); + + talloc_free(tmp_ctx); return io.out.handle; } +/* + send a close +*/ +static NTSTATUS torture_smb2_close(struct smb2_tree *tree, struct smb2_handle handle) +{ + struct smb2_close io; + NTSTATUS status; + TALLOC_CTX *tmp_ctx = talloc_new(tree); + + ZERO_STRUCT(io); + io.in.unknown1 = 0x10018; + io.in.handle = handle; + status = smb2_close(tree, &io); + if (!NT_STATUS_IS_OK(status)) { + printf("close failed - %s\n", nt_errstr(status)); + return status; + } + + printf("Close gave:\n"); + printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time)); + printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time)); + printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time)); + printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time)); + + talloc_free(tmp_ctx); + + return status; +} + /* basic testing of SMB2 connection calls */ @@ -234,15 +272,15 @@ BOOL torture_smb2_connect(void) const char *host = lp_parm_string(-1, "torture", "host"); const char *share = lp_parm_string(-1, "torture", "share"); struct cli_credentials *credentials = cmdline_credentials; - struct smb2_handle h; + struct smb2_handle h1, h2; transport = torture_smb2_negprot(mem_ctx, host); session = torture_smb2_session(transport, credentials); tree = torture_smb2_tree(session, share); - h = torture_smb2_create(tree, "test2.dat"); - h = torture_smb2_create(tree, "test3.dat"); - h = torture_smb2_create(tree, "test4.dat"); - h = torture_smb2_create(tree, "test5.dat"); + h1 = torture_smb2_create(tree, "test1.dat"); + h2 = torture_smb2_create(tree, "test2.dat"); + torture_smb2_close(tree, h1); + torture_smb2_close(tree, h2); talloc_free(mem_ctx); -- cgit