svn commit: samba r5730 - in branches/SAMBA_4_0/source/torture/basic: .

jra at samba.org jra at samba.org
Thu Mar 10 21:42:20 GMT 2005


Author: jra
Date: 2005-03-10 21:42:20 +0000 (Thu, 10 Mar 2005)
New Revision: 5730

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

Log:
More fun with delayed write semantics with multiple file handles
open on the same file on the same connection.
Jeremy.

Modified:
   branches/SAMBA_4_0/source/torture/basic/delaywrite.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/basic/delaywrite.c
===================================================================
--- branches/SAMBA_4_0/source/torture/basic/delaywrite.c	2005-03-10 20:14:24 UTC (rev 5729)
+++ branches/SAMBA_4_0/source/torture/basic/delaywrite.c	2005-03-10 21:42:20 UTC (rev 5730)
@@ -122,6 +122,7 @@
 	const char *fname = BASEDIR "\\torture_file.txt";
 	NTSTATUS status;
 	int fnum1 = -1;
+	int fnum2 = -1;
 	BOOL ret = True;
 	ssize_t written;
 	time_t t;
@@ -259,7 +260,7 @@
 	/* Once the time was set using setfileinfo then it stays set - writes
 	   don't have any effect. But make sure. */
 
-	while (time(NULL) < t+40) {
+	while (time(NULL) < t+15) {
 		status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2);
 
 		if (!NT_STATUS_IS_OK(status)) {
@@ -279,9 +280,171 @@
 	}
 	
 	if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
-		printf("Server did not update write time?!\n");
+		printf("Server did not update write time\n");
 	}
 
+	fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+	if (fnum2 == -1) {
+		printf("Failed to open %s\n", fname);
+		return False;
+	}
+	
+	printf("Doing a 10 byte write to extend the file via second fd and see if this changes the last write time.\n");
+
+	written =  smbcli_write(cli->tree, fnum2, 0, "0123456789", 11, 10);
+
+	if (written != 10) {
+		printf("write failed - wrote %d bytes (%s)\n", written, __location__);
+		return False;
+	}
+
+	status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+		return False;
+	}
+	printf("write time %s\n", 
+	       nt_time_string(mem_ctx, finfo2.basic_info.out.write_time));
+	if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
+		printf("Server updated write_time\n");
+	}
+
+	printf("Closing the first fd to see if write time updated.\n");
+	smbcli_close(cli->tree, fnum1);
+	fnum1 = -1;
+
+	printf("Doing a 10 byte write to extend the file via second fd and see if this changes the last write time.\n");
+
+	written =  smbcli_write(cli->tree, fnum2, 0, "0123456789", 21, 10);
+
+	if (written != 10) {
+		printf("write failed - wrote %d bytes (%s)\n", written, __location__);
+		return False;
+	}
+
+	finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
+	finfo1.basic_info.in.fnum = fnum2;
+	finfo2 = finfo1;
+	status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+		return False;
+	}
+	printf("write time %s\n", 
+	       nt_time_string(mem_ctx, finfo2.basic_info.out.write_time));
+	if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
+		printf("Server updated write_time\n");
+	}
+
+	t = time(NULL);
+
+	/* Once the time was set using setfileinfo then it stays set - writes
+	   don't have any effect. But make sure. */
+
+	while (time(NULL) < t+15) {
+		status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2);
+
+		if (!NT_STATUS_IS_OK(status)) {
+			DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+			ret = False;
+			break;
+		}
+		printf("write time %s\n", 
+		       nt_time_string(mem_ctx, finfo2.basic_info.out.write_time));
+		if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
+			printf("Server updated write_time after %d seconds\n",
+			       (int)(time(NULL) - t));
+			break;
+		}
+		sleep(1);
+		fflush(stdout);
+	}
+	
+	if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
+		printf("Server did not update write time\n");
+	}
+
+	printf("Closing both fd's to see if write time updated.\n");
+
+	smbcli_close(cli->tree, fnum2);
+	fnum2 = -1;
+
+	fnum1 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
+	if (fnum1 == -1) {
+		printf("Failed to open %s\n", fname);
+		return False;
+	}
+
+	finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
+	finfo1.basic_info.in.fnum = fnum1;
+	finfo2 = finfo1;
+
+	status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo1);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+		return False;
+	}
+	
+	printf("Second open initial write time %s\n", 
+	       nt_time_string(mem_ctx, finfo1.basic_info.out.write_time));
+
+	sleep(10);
+	printf("Doing a 10 byte write to extend the file to see if this changes the last write time.\n");
+
+	written =  smbcli_write(cli->tree, fnum1, 0, "0123456789", 31, 10);
+
+	if (written != 10) {
+		printf("write failed - wrote %d bytes (%s)\n", written, __location__);
+		return False;
+	}
+
+	finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
+	finfo1.basic_info.in.fnum = fnum1;
+	finfo2 = finfo1;
+	status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+		return False;
+	}
+	printf("write time %s\n", 
+	       nt_time_string(mem_ctx, finfo2.basic_info.out.write_time));
+	if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
+		printf("Server updated write_time\n");
+	}
+
+	t = time(NULL);
+
+	/* Once the time was set using setfileinfo then it stays set - writes
+	   don't have any effect. But make sure. */
+
+	while (time(NULL) < t+15) {
+		status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2);
+
+		if (!NT_STATUS_IS_OK(status)) {
+			DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+			ret = False;
+			break;
+		}
+		printf("write time %s\n", 
+		       nt_time_string(mem_ctx, finfo2.basic_info.out.write_time));
+		if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
+			printf("Server updated write_time after %d seconds\n",
+			       (int)(time(NULL) - t));
+			break;
+		}
+		sleep(1);
+		fflush(stdout);
+	}
+	
+	if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
+		printf("Server did not update write time\n");
+	}
+
+
 	/* One more test to do. We should read the filetime via findfirst on the
 	   second connection to ensure it's the same. This is very easy for a Windows
 	   server but a bastard to get right on a POSIX server. JRA. */
@@ -403,6 +566,9 @@
 	if (finfo1.basic_info.out.write_time !=
 	    finfo2.basic_info.out.write_time) {
 		printf("(%s) write_time changed\n", __location__);
+		printf("write time conn 1 = %s, conn 2 = %s\n", 
+		       nt_time_string(mem_ctx, finfo1.basic_info.out.write_time),
+		       nt_time_string(mem_ctx, finfo2.basic_info.out.write_time));
 		ret = False;
 		goto done;
 	}



More information about the samba-cvs mailing list