return ret;
}
+static bool test_durable_open_delaywrite1_close(void *private_data,
+ union smb_fileinfo *finfo)
+{
+ struct test_durable_open_delaywrite1_state *state =
+ (struct test_durable_open_delaywrite1_state *)private_data;
+ struct torture_context *tctx = state->tctx;
+ union smb_fileinfo t1finfoCL;
+ union smb_fileinfo t2finfoCL;
+ struct smb2_close cl1;
+ struct smb2_close cl2;
+ union smb_fileinfo t2finfo;
+ NTSTATUS status;
+ bool ret = true;
+
+ ZERO_STRUCTP(finfo);
+
+ ZERO_STRUCT(cl1);
+ cl1.in.file.handle = *state->h1;
+ cl1.in.flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
+ status = smb2_close(state->tree1, &cl1);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ state->h1 = NULL;
+ ZERO_STRUCT(t1finfoCL);
+ t1finfoCL.basic_info.out.create_time = cl1.out.create_time;
+ t1finfoCL.basic_info.out.access_time = cl1.out.access_time;
+ t1finfoCL.basic_info.out.write_time = cl1.out.write_time;
+ t1finfoCL.basic_info.out.change_time = cl1.out.change_time;
+ t1finfoCL.basic_info.out.attrib = cl1.out.file_attr;
+
+ ZERO_STRUCT(t2finfo);
+ t2finfo.basic_info.level = RAW_FILEINFO_BASIC_INFORMATION;
+ t2finfo.basic_info.in.file.handle = *state->h2;
+
+ GET_INFO_FILE(state->tree2, t2finfo);
+ COMPARE_ALL_TIMES_EQUAL(t2finfo, t1finfoCL);
+
+ ZERO_STRUCT(cl2);
+ cl2.in.file.handle = *state->h2;
+ cl2.in.flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
+ status = smb2_close(state->tree2, &cl2);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ state->h2 = NULL;
+ ZERO_STRUCT(t2finfoCL);
+ t2finfoCL.basic_info.out.create_time = cl2.out.create_time;
+ t2finfoCL.basic_info.out.access_time = cl2.out.access_time;
+ t2finfoCL.basic_info.out.write_time = cl2.out.write_time;
+ t2finfoCL.basic_info.out.change_time = cl2.out.change_time;
+ t2finfoCL.basic_info.out.attrib = cl2.out.file_attr;
+ COMPARE_ALL_TIMES_EQUAL(t2finfoCL, t1finfoCL);
+
+ finfo->basic_info.out = t1finfoCL.basic_info.out;
+
+done:
+ return ret;
+}
+
static bool test_durable_open_delaywrite1(struct torture_context *tctx,
struct smb2_tree *tree1,
struct smb2_tree *tree2)
TALLOC_CTX *mem_ctx = talloc_new(tctx);
char fname[256];
struct smb2_handle _h1;
- struct smb2_handle *h1 = NULL;
struct smb2_handle _h2;
- struct smb2_handle *h2 = NULL;
struct smb2_create cr1;
struct smb2_create cr2;
- union smb_fileinfo c1finfoCR, c1finfo0, c1finfo1, c1finfo2, c1finfoCL;
- union smb_fileinfo c2finfoCR, c2finfo0, c2finfo1, c2finfo2, c2finfo3, c2finfoCL;
- struct smb2_close cl1;
- struct smb2_close cl2;
+ union smb_fileinfo c1finfoCR, c1finfo0;
+ union smb_fileinfo c2finfoCR, c2finfo0;
//double used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
//double used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 1000000);
double normal_delay = 1000000;
double used_delay = torture_setting_int(tctx, "writetimeupdatedelay", normal_delay);
//double normal_delay = 1000000;
//int normal_delay = 2000000;
- double sec = ((double)used_delay) / ((double)normal_delay);
- int msec = 1000 * sec;
bool ret = true;
bool ok;
status = smb2_create(tree1, mem_ctx, &cr1);
CHECK_STATUS(status, NT_STATUS_OK);
_h1 = cr1.out.file.handle;
- h1 = &_h1;
+ state.h1 = &_h1;
CHECK_CREATED(&cr1, CREATED, FILE_ATTRIBUTE_ARCHIVE);
CHECK_VAL(cr1.out.oplock_level, smb2_util_oplock_level("b"));
CHECK_VAL(cr1.out.durable_open, true);
status = smb2_create(tree2, mem_ctx, &cr2);
CHECK_STATUS(status, NT_STATUS_OK);
_h2 = cr2.out.file.handle;
- h2 = &_h2;
+ state.h2 = &_h2;
CHECK_CREATED(&cr2, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
CHECK_VAL(cr2.out.oplock_level, 0);
CHECK_VAL(cr2.out.durable_open, false);
ZERO_STRUCT(c1finfo0);
c1finfo0.basic_info.level = RAW_FILEINFO_BASIC_INFORMATION;
- c1finfo0.basic_info.in.file.handle = *h1;
- c1finfo1 = c1finfo0;
- c1finfo2 = c1finfo0;
+ c1finfo0.basic_info.in.file.handle = *state.h1;
ZERO_STRUCT(c2finfo0);
c2finfo0.basic_info.level = RAW_FILEINFO_BASIC_INFORMATION;
- c2finfo0.basic_info.in.file.handle = *h2;
- c2finfo1 = c2finfo0;
- c2finfo2 = c2finfo0;
- c2finfo3 = c2finfo0;
+ c2finfo0.basic_info.in.file.handle = *state.h2;
GET_INFO_BOTH(c1finfo0, c2finfo0);
COMPARE_ALL_TIMES_EQUAL(c1finfo0, c1finfoCR);
- state.h1 = h1;
- state.h2 = h2;
-
ok = test_delay_writetime1(tctx, used_delay, normal_delay,
"run1",
test_durable_open_delaywrite1_get_info,
test_durable_open_delaywrite1_write_data,
+ NULL, /* close_cb */
&state);
torture_assert(tctx, ok, "test_delay_writetime1(1)");
ok = test_delay_writetime1(tctx, used_delay, normal_delay,
"run2",
test_durable_open_delaywrite1_get_info,
test_durable_open_delaywrite1_write_data,
+ test_durable_open_delaywrite1_close,
&state);
torture_assert(tctx, ok, "test_delay_writetime2(2)");
- GET_INFO_BOTH(c1finfo1, c2finfo1);
- COMPARE_TIMES_AFTER_WRITE(c1finfo1, c1finfo0);
-
- /* sleep */
- torture_comment(tctx, "Sleep ...\n");
- smb_msleep(5 * msec);
- torture_comment(tctx, "... continue\n");
-
- GET_INFO_BOTH(c1finfo2, c2finfo2);
- COMPARE_ALL_TIMES_EQUAL(c1finfo2, c1finfo1);
-
- /*
- * the close updates the write time to the time of the close
- * and not to the time of the last write!
- */
- torture_comment(tctx, "Close the file handle\n");
-
- ZERO_STRUCT(cl1);
- cl1.in.file.handle = *h1;
- cl1.in.flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
- status = smb2_close(tree1, &cl1);
- CHECK_STATUS(status, NT_STATUS_OK);
- h1 = NULL;
- ZERO_STRUCT(c1finfoCL);
- c1finfoCL.basic_info.out.create_time = cl1.out.create_time;
- c1finfoCL.basic_info.out.access_time = cl1.out.access_time;
- c1finfoCL.basic_info.out.write_time = cl1.out.write_time;
- c1finfoCL.basic_info.out.change_time = cl1.out.change_time;
- c1finfoCL.basic_info.out.attrib = cl1.out.file_attr;
- COMPARE_ALL_TIMES_EQUAL(c1finfoCL, c1finfo2);
-
- GET_INFO_FILE(tree2, c2finfo3);
- COMPARE_ALL_TIMES_EQUAL(c2finfo3, c1finfoCL);
-
- ZERO_STRUCT(cl2);
- cl2.in.file.handle = *h2;
- cl2.in.flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
- status = smb2_close(tree2, &cl2);
- CHECK_STATUS(status, NT_STATUS_OK);
- h2 = NULL;
- ZERO_STRUCT(c2finfoCL);
- c2finfoCL.basic_info.out.create_time = cl2.out.create_time;
- c2finfoCL.basic_info.out.access_time = cl2.out.access_time;
- c2finfoCL.basic_info.out.write_time = cl2.out.write_time;
- c2finfoCL.basic_info.out.change_time = cl2.out.change_time;
- c2finfoCL.basic_info.out.attrib = cl2.out.file_attr;
- COMPARE_ALL_TIMES_EQUAL(c2finfoCL, c1finfoCL);
-
done:
- if (h1 != NULL) {
- smb2_util_close(tree1, *h1);
+ if (state.h1 != NULL) {
+ smb2_util_close(tree1, *state.h1);
}
- if (h2 != NULL) {
- smb2_util_close(tree2, *h2);
+ if (state.h2 != NULL) {
+ smb2_util_close(tree2, *state.h2);
}
smb2_util_unlink(tree1, fname);