r16736: - convert unix times to nttime before sending it to the wire...
authorStefan Metzmacher <metze@samba.org>
Sat, 1 Jul 2006 14:20:14 +0000 (14:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:09:42 +0000 (14:09 -0500)
- return an error code if an error happens

metze
(This used to be commit 9b52322e90003302ec99e2808c80c6c733a84358)

source4/torture/smb2/util.c

index 89c54884266d1cb34b5f18da726129db5f17f8d4..cd5cfdafa642f29721c3b19196d6d202ee1d720a 100644 (file)
@@ -147,15 +147,16 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
        setfile.generic.level = RAW_SFILEINFO_BASIC_INFORMATION;
        setfile.generic.in.file.handle = *handle;
 
-       setfile.basic_info.in.create_time = t +  9*30*24*60*60;
-       setfile.basic_info.in.access_time = t +  6*30*24*60*60;
-       setfile.basic_info.in.write_time  = t +  3*30*24*60*60;
-       setfile.basic_info.in.change_time = t +  1*30*24*60*60;
+       unix_to_nt_time(&setfile.basic_info.in.create_time, t + 9*30*24*60*60);
+       unix_to_nt_time(&setfile.basic_info.in.access_time, t + 6*30*24*60*60);
+       unix_to_nt_time(&setfile.basic_info.in.write_time,  t + 3*30*24*60*60);
+       unix_to_nt_time(&setfile.basic_info.in.change_time, t + 1*30*24*60*60);
        setfile.basic_info.in.attrib      = FILE_ATTRIBUTE_NORMAL;
 
        status = smb2_setinfo_file(tree, &setfile);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to setup file times - %s\n", nt_errstr(status));
+               return status;
        }
 
        /* make sure all the timestamps aren't the same */
@@ -165,19 +166,28 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
        status = smb2_getinfo_file(tree, tree, &fileinfo);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to query file times - %s\n", nt_errstr(status));
+               return status;
+               
        }
 
-       if (setfile.basic_info.in.create_time != fileinfo.basic_info.out.create_time) {
-               printf("create_time not setup correctly\n");
-       }
-       if (setfile.basic_info.in.access_time != fileinfo.basic_info.out.access_time) {
-               printf("access_time not setup correctly\n");
-       }
-       if (setfile.basic_info.in.write_time != fileinfo.basic_info.out.write_time) {
-               printf("write_time not setup correctly\n");
-       }
-       
-       return NT_STATUS_OK;
+#define CHECK_TIME(field) do {\
+       if (setfile.basic_info.in.field != fileinfo.basic_info.out.field) { \
+               printf("(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \
+                       __location__, \
+                       nt_time_string(tree, setfile.basic_info.in.field), \
+                       setfile.basic_info.in.field, \
+                       nt_time_string(tree, fileinfo.basic_info.out.field), \
+                       fileinfo.basic_info.out.field); \
+               status = NT_STATUS_INVALID_PARAMETER; \
+       } \
+} while (0)
+
+       CHECK_TIME(create_time);
+       CHECK_TIME(access_time);
+       CHECK_TIME(write_time);
+       CHECK_TIME(change_time);
+
+       return status;
 }
 
 /*