svn commit: samba r11776 - in branches/SAMBA_4_0/source/torture/smb2: .

tridge at samba.org tridge at samba.org
Fri Nov 18 09:51:13 GMT 2005


Author: tridge
Date: 2005-11-18 09:51:13 +0000 (Fri, 18 Nov 2005)
New Revision: 11776

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11776

Log:

no need to call out to SMB to setup test files for SMB2 any more

Modified:
   branches/SAMBA_4_0/source/torture/smb2/getinfo.c
   branches/SAMBA_4_0/source/torture/smb2/scan.c
   branches/SAMBA_4_0/source/torture/smb2/util.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/smb2/getinfo.c
===================================================================
--- branches/SAMBA_4_0/source/torture/smb2/getinfo.c	2005-11-18 09:25:25 UTC (rev 11775)
+++ branches/SAMBA_4_0/source/torture/smb2/getinfo.c	2005-11-18 09:51:13 UTC (rev 11776)
@@ -156,15 +156,22 @@
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 	struct smb2_tree *tree;
 	BOOL ret = True;
+	NTSTATUS status;
 
 	if (!torture_smb2_connection(mem_ctx, &tree)) {
 		return False;
 	}
 
-	torture_setup_complex_file(FNAME);
-	torture_setup_complex_file(FNAME ":streamtwo");
-	torture_setup_complex_dir(DNAME);
-	torture_setup_complex_file(DNAME ":streamtwo");
+	status = torture_setup_complex_file(tree, FNAME);
+	if (!NT_STATUS_IS_OK(status)) {
+		return False;
+	}
+	torture_setup_complex_file(tree, FNAME ":streamtwo");
+	status = torture_setup_complex_dir(tree, DNAME);
+	if (!NT_STATUS_IS_OK(status)) {
+		return False;
+	}
+	torture_setup_complex_file(tree, DNAME ":streamtwo");
 
 	ret &= torture_smb2_fileinfo(tree);
 	ret &= torture_smb2_fsinfo(tree);

Modified: branches/SAMBA_4_0/source/torture/smb2/scan.c
===================================================================
--- branches/SAMBA_4_0/source/torture/smb2/scan.c	2005-11-18 09:25:25 UTC (rev 11775)
+++ branches/SAMBA_4_0/source/torture/smb2/scan.c	2005-11-18 09:51:13 UTC (rev 11776)
@@ -48,15 +48,19 @@
 		return False;
 	}
 
-	if (!torture_setup_complex_file(FNAME)) {
+	status = torture_setup_complex_file(tree, FNAME);
+	if (!NT_STATUS_IS_OK(status)) {
 		printf("Failed to setup complex file '%s'\n", FNAME);
+		return False;
 	}
-	torture_setup_complex_file(FNAME ":2ndstream");
+	torture_setup_complex_file(tree, FNAME ":2ndstream");
 
-	if (!torture_setup_complex_dir(DNAME)) {
+	status = torture_setup_complex_dir(tree, DNAME);
+	if (!NT_STATUS_IS_OK(status)) {
 		printf("Failed to setup complex dir  '%s'\n", DNAME);
+		return False;
 	}
-	torture_setup_complex_file(DNAME ":2ndstream");
+	torture_setup_complex_file(tree, DNAME ":2ndstream");
 
 	torture_smb2_testfile(tree, FNAME, &fhandle);
 	torture_smb2_testdir(tree, DNAME, &dhandle);
@@ -112,10 +116,12 @@
 		return False;
 	}
 
-	if (!torture_setup_complex_file(FNAME)) {
+	status = torture_setup_complex_file(tree, FNAME);
+	if (!NT_STATUS_IS_OK(status)) {
 		printf("Failed to setup complex file '%s'\n", FNAME);
+		return False;
 	}
-	torture_setup_complex_file(FNAME ":2ndstream");
+	torture_setup_complex_file(tree, FNAME ":2ndstream");
 
 	torture_smb2_testfile(tree, FNAME, &handle);
 

Modified: branches/SAMBA_4_0/source/torture/smb2/util.c
===================================================================
--- branches/SAMBA_4_0/source/torture/smb2/util.c	2005-11-18 09:25:25 UTC (rev 11775)
+++ branches/SAMBA_4_0/source/torture/smb2/util.c	2005-11-18 09:51:13 UTC (rev 11776)
@@ -88,9 +88,10 @@
 }
 
 /*
-  create a complex file using the SMB2 protocol
+  create a complex file/dir using the SMB2 protocol
 */
-NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle)
+static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, 
+					 struct smb2_handle *handle, BOOL dir)
 {
 	TALLOC_CTX *tmp_ctx = talloc_new(tree);
 	char buf[7] = "abc";
@@ -100,6 +101,7 @@
 	time_t t = (time(NULL) & ~1);
 	NTSTATUS status;
 
+	smb2_util_unlink(tree, fname);
 	ZERO_STRUCT(io);
 	io.in.access_mask = SEC_RIGHTS_FILE_ALL;
 	io.in.file_attr   = FILE_ATTRIBUTE_NORMAL;
@@ -110,6 +112,12 @@
 		NTCREATEX_SHARE_ACCESS_WRITE;
 	io.in.create_options = 0;
 	io.in.fname = fname;
+	if (dir) {
+		io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+		io.in.share_access &= ~NTCREATEX_SHARE_ACCESS_DELETE;
+		io.in.file_attr   = FILE_ATTRIBUTE_DIRECTORY;
+		io.in.open_disposition = NTCREATEX_DISP_CREATE;
+	}
 
 	io.in.sd = security_descriptor_create(tmp_ctx,
 					      NULL, NULL,
@@ -141,8 +149,10 @@
 
 	*handle = io.out.handle;
 
-	status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf));
-	NT_STATUS_NOT_OK_RETURN(status);
+	if (!dir) {
+		status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf));
+		NT_STATUS_NOT_OK_RETURN(status);
+	}
 
 	/* make sure all the timestamps aren't the same, and are also 
 	   in different DST zones*/
@@ -183,6 +193,24 @@
 }
 
 /*
+  create a complex file using the SMB2 protocol
+*/
+NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, 
+					 struct smb2_handle *handle)
+{
+	return smb2_create_complex(tree, fname, handle, False);
+}
+
+/*
+  create a complex dir using the SMB2 protocol
+*/
+NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname, 
+				 struct smb2_handle *handle)
+{
+	return smb2_create_complex(tree, fname, handle, True);
+}
+
+/*
   show lots of information about a file
 */
 void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
@@ -201,6 +229,7 @@
 		return;
 	}
 
+	d_printf("all_info for '%s'\n", io.all_info2.out.fname.s);
 	d_printf("\tcreate_time:    %s\n", nt_time_string(tmp_ctx, io.all_info2.out.create_time));
 	d_printf("\taccess_time:    %s\n", nt_time_string(tmp_ctx, io.all_info2.out.access_time));
 	d_printf("\twrite_time:     %s\n", nt_time_string(tmp_ctx, io.all_info2.out.write_time));
@@ -217,7 +246,6 @@
 	d_printf("\taccess_mask:    0x%08x\n", io.all_info2.out.access_mask);
 	d_printf("\tunknown2:       0x%llx\n", io.all_info2.out.unknown2);
 	d_printf("\tunknown3:       0x%llx\n", io.all_info2.out.unknown3);
-	d_printf("\tfname:          '%s'\n", io.all_info2.out.fname.s);
 
 	/* short name, if any */
 	io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION;
@@ -347,44 +375,24 @@
   create a complex file using the old SMB protocol, to make it easier to 
   find fields in SMB2 getinfo levels
 */
-BOOL torture_setup_complex_file(const char *fname)
+NTSTATUS torture_setup_complex_file(struct smb2_tree *tree, const char *fname)
 {
-	struct smbcli_state *cli;
-	int fnum;
+	struct smb2_handle handle;
+	NTSTATUS status = smb2_create_complex_file(tree, fname, &handle);
+	NT_STATUS_NOT_OK_RETURN(status);
+	return smb2_util_close(tree, handle);
+}
 
-	if (!torture_open_connection(&cli)) {
-		return False;
-	}
 
-	fnum = create_complex_file(cli, cli, fname);
-
-	if (DEBUGLVL(1)) {
-		torture_all_info(cli->tree, fname);
-	}
-	
-	talloc_free(cli);
-	return fnum != -1;
-}
-
 /*
-  create a complex directory using the old SMB protocol, to make it easier to 
+  create a complex dir using the old SMB protocol, to make it easier to 
   find fields in SMB2 getinfo levels
 */
-BOOL torture_setup_complex_dir(const char *dname)
+NTSTATUS torture_setup_complex_dir(struct smb2_tree *tree, const char *fname)
 {
-	struct smbcli_state *cli;
-	int fnum;
+	struct smb2_handle handle;
+	NTSTATUS status = smb2_create_complex_dir(tree, fname, &handle);
+	NT_STATUS_NOT_OK_RETURN(status);
+	return smb2_util_close(tree, handle);
+}
 
-	if (!torture_open_connection(&cli)) {
-		return False;
-	}
-
-	fnum = create_complex_dir(cli, cli, dname);
-
-	if (DEBUGLVL(1)) {
-		torture_all_info(cli->tree, dname);
-	}
-	
-	talloc_free(cli);
-	return fnum != -1;
-}



More information about the samba-cvs mailing list