From: Ralph Boehme Date: Fri, 14 Mar 2025 06:59:33 +0000 (+0100) Subject: smbd: remove get_change_timespec() X-Git-Tag: tevent-0.17.0~503 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=907f17dda9984dd70af9fd23ab02c21b7c50fbe8;p=thirdparty%2Fsamba.git smbd: remove get_change_timespec() Return ctime from the filesystem instead of mtime. Adjust existing tests by removing ctime check. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13594 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 35a283a8546..0b076c38d2e 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -1724,7 +1724,6 @@ EOF num_create=$(echo "$out_sorted" | grep -c 'create_time:') num_access=$(echo "$out_sorted" | grep -c 'access_time:') num_write=$(echo "$out_sorted" | grep -c 'write_time:') - num_change=$(echo "$out_sorted" | grep -c 'change_time:') if [ "$num_create" != "2" ]; then echo "failed - should get two create_time $out" false @@ -1740,11 +1739,6 @@ EOF false return fi - if [ "$num_change" != "1" ]; then - echo "failed - should only get one change_time $out" - false - return - fi # This could be: Sun Jan 1 05:10:20 AM 2017 # or : Sun Jan 1 05:10:20 2017 CET diff --git a/source3/script/tests/test_timestamps.sh b/source3/script/tests/test_timestamps.sh index a158beb03d1..af9625d14ef 100755 --- a/source3/script/tests/test_timestamps.sh +++ b/source3/script/tests/test_timestamps.sh @@ -49,7 +49,7 @@ test_time() echo "smbclient allinfo on $file returned: \"$out\"" # Ignore create_time as that is synthesized - for time in access_time write_time change_time; do + for time in access_time write_time ; do echo "$out" | grep "$time" | grep "$expected" || { echo "Expected \"$expected\", got: \"$(echo $out | grep $time)\"" return 1 diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 9a8ecf6e0a7..ee80f798891 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -1332,14 +1332,3 @@ struct timespec get_create_timespec(connection_struct *conn, } return smb_fname->st.st_ex_btime; } - -/****************************************************************** - Return a change time (may look at EA in future). -******************************************************************/ - -struct timespec get_change_timespec(connection_struct *conn, - struct files_struct *fsp, - const struct smb_filename *smb_fname) -{ - return smb_fname->st.st_ex_mtime; -} diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 4cf10ed7271..ad70e4161ae 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -236,10 +236,6 @@ struct timespec get_create_timespec(connection_struct *conn, struct files_struct *fsp, const struct smb_filename *smb_fname); -struct timespec get_change_timespec(connection_struct *conn, - struct files_struct *fsp, - const struct smb_filename *smb_fname); - NTSTATUS parse_dos_attribute_blob(struct smb_filename *smb_fname, DATA_BLOB blob, uint32_t *pattr); diff --git a/source3/smbd/smb1_nttrans.c b/source3/smbd/smb1_nttrans.c index 554059059d4..1d2bae76f89 100644 --- a/source3/smbd/smb1_nttrans.c +++ b/source3/smbd/smb1_nttrans.c @@ -765,7 +765,7 @@ void reply_ntcreate_and_X(struct smb_request *req) create_timespec = get_create_timespec(conn, fsp, smb_fname); a_timespec = smb_fname->st.st_ex_atime; m_timespec = smb_fname->st.st_ex_mtime; - c_timespec = get_change_timespec(conn, fsp, smb_fname); + c_timespec = smb_fname->st.st_ex_ctime; if (lp_dos_filetime_resolution(SNUM(conn))) { dos_filetime_timespec(&create_timespec); @@ -1310,7 +1310,7 @@ static void call_nt_transact_create(connection_struct *conn, create_timespec = get_create_timespec(conn, fsp, smb_fname); a_timespec = smb_fname->st.st_ex_atime; m_timespec = smb_fname->st.st_ex_mtime; - c_timespec = get_change_timespec(conn, fsp, smb_fname); + c_timespec = smb_fname->st.st_ex_ctime; if (lp_dos_filetime_resolution(SNUM(conn))) { dos_filetime_timespec(&create_timespec); diff --git a/source3/smbd/smb2_close.c b/source3/smbd/smb2_close.c index d68c0bd9e6c..d37b6cec4c8 100644 --- a/source3/smbd/smb2_close.c +++ b/source3/smbd/smb2_close.c @@ -165,7 +165,7 @@ static void setup_close_full_information(connection_struct *conn, *out_last_write_ts = smb_fname->st.st_ex_mtime; *out_last_access_ts = smb_fname->st.st_ex_atime; *out_creation_ts = get_create_timespec(conn, NULL, smb_fname); - *out_change_ts = get_change_timespec(conn, NULL, smb_fname); + *out_change_ts = smb_fname->st.st_ex_ctime; if (lp_dos_filetime_resolution(SNUM(conn))) { dos_filetime_timespec(out_creation_ts); diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c index 01e06894364..78da998e169 100644 --- a/source3/smbd/smb2_create.c +++ b/source3/smbd/smb2_create.c @@ -1960,8 +1960,7 @@ static void smbd_smb2_create_finish(struct tevent_req *req) result, result->fsp_name); state->out_last_access_ts = result->fsp_name->st.st_ex_atime; state->out_last_write_ts = result->fsp_name->st.st_ex_mtime; - state->out_change_ts = get_change_timespec(smb1req->conn, - result, result->fsp_name); + state->out_change_ts = result->fsp_name->st.st_ex_ctime; if (lp_dos_filetime_resolution(SNUM(smb2req->tcon->compat))) { dos_filetime_timespec(&state->out_creation_ts); diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index bfaabaf5db7..80f81ffe777 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -1083,7 +1083,7 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx, mdate_ts = smb_fname->st.st_ex_mtime; adate_ts = smb_fname->st.st_ex_atime; create_date_ts = get_create_timespec(conn, NULL, smb_fname); - cdate_ts = get_change_timespec(conn, NULL, smb_fname); + cdate_ts = smb_fname->st.st_ex_ctime; if (lp_dos_filetime_resolution(SNUM(conn))) { dos_filetime_timespec(&create_date_ts); @@ -3055,7 +3055,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, create_time_ts = get_create_timespec(conn, fsp, smb_fname); mtime_ts = psbuf->st_ex_mtime; atime_ts = psbuf->st_ex_atime; - ctime_ts = get_change_timespec(conn, fsp, smb_fname); + ctime_ts = psbuf->st_ex_ctime; if (lp_dos_filetime_resolution(SNUM(conn))) { dos_filetime_timespec(&create_time_ts); diff --git a/source4/torture/smb2/rename.c b/source4/torture/smb2/rename.c index 31e30fa19b4..53cd9f4ad2d 100644 --- a/source4/torture/smb2/rename.c +++ b/source4/torture/smb2/rename.c @@ -1524,9 +1524,6 @@ static bool torture_smb2_rename_simple_modtime( torture_assert_nttime_equal( torture, c1.out.write_time, gi.all_info.out.write_time, "Bad timestamp\n"); - torture_assert_nttime_equal( - torture, c1.out.change_time, gi.all_info.out.change_time, - "Bad timestamp\n"); torture_comment(torture, "Renaming file2.txt --> file1.txt\n"); @@ -1556,9 +1553,6 @@ static bool torture_smb2_rename_simple_modtime( torture_assert_nttime_equal( torture, c2.out.write_time, gi.all_info.out.write_time, "Bad timestamp\n"); - torture_assert_nttime_equal( - torture, c2.out.change_time, gi.all_info.out.change_time, - "Bad timestamp\n"); done: if (!smb2_util_handle_empty(h1)) { diff --git a/source4/torture/smb2/timestamps.c b/source4/torture/smb2/timestamps.c index a9416481c61..4b15b945354 100644 --- a/source4/torture/smb2/timestamps.c +++ b/source4/torture/smb2/timestamps.c @@ -76,8 +76,6 @@ static bool test_close_no_attrib(struct torture_context *tctx, ret, done, "Unexpected access time\n"); torture_assert_u64_equal_goto(tctx, c.out.write_time, NTTIME_OMIT, ret, done, "Unexpected write time\n"); - torture_assert_u64_equal_goto(tctx, c.out.change_time, NTTIME_OMIT, - ret, done, "Unexpected change time\n"); torture_assert_u64_equal_goto(tctx, c.out.size, 0, ret, done, "Unexpected size\n"); torture_assert_u64_equal_goto(tctx, c.out.file_attr, 0, @@ -142,7 +140,6 @@ static bool test_time_t(struct torture_context *tctx, nttime = full_timespec_to_nt_time(&ts); si.basic_info.in.create_time = nttime; si.basic_info.in.write_time = nttime; - si.basic_info.in.change_time = nttime; status = smb2_setinfo_file(tree, &si); torture_assert_ntstatus_ok_goto(tctx, status, ret, done, @@ -172,11 +169,6 @@ static bool test_time_t(struct torture_context *tctx, nttime, ret, done, "Wrong write time\n"); - torture_assert_u64_equal_goto(tctx, - gi.basic_info.out.change_time, - nttime, - ret, done, - "Wrong change time\n"); find = (struct smb2_find) { .in.file.handle = testdirh, @@ -199,11 +191,6 @@ static bool test_time_t(struct torture_context *tctx, nttime, ret, done, "Wrong write time\n"); - torture_assert_u64_equal_goto(tctx, - d[0].id_both_directory_info.change_time, - nttime, - ret, done, - "Wrong change time\n"); status = smb2_util_close(tree, handle); torture_assert_ntstatus_ok_goto(tctx, status, ret, done, @@ -248,11 +235,6 @@ static bool test_time_t(struct torture_context *tctx, nttime, ret, done, "Wrong write time\n"); - torture_assert_u64_equal_goto(tctx, - gi.basic_info.out.change_time, - nttime, - ret, done, - "Wrong change time\n"); find = (struct smb2_find) { .in.continue_flags = SMB2_CONTINUE_FLAG_RESTART, @@ -276,11 +258,6 @@ static bool test_time_t(struct torture_context *tctx, nttime, ret, done, "Wrong write time\n"); - torture_assert_u64_equal_goto(tctx, - d[0].id_both_directory_info.change_time, - nttime, - ret, done, - "Wrong change time\n"); status = smb2_util_close(tree, handle); torture_assert_ntstatus_ok_goto(tctx, status, ret, done, @@ -397,7 +374,6 @@ static bool test_freeze_thaw(struct torture_context *tctx, nttime = full_timespec_to_nt_time(&ts); si.basic_info.in.create_time = nttime; si.basic_info.in.write_time = nttime; - si.basic_info.in.change_time = nttime; status = smb2_setinfo_file(tree, &si); torture_assert_ntstatus_ok_goto(tctx, status, ret, done, @@ -432,11 +408,6 @@ static bool test_freeze_thaw(struct torture_context *tctx, nttime, ret, done, "Wrong write time\n"); - torture_assert_u64_equal_goto(tctx, - gi.basic_info.out.change_time, - nttime, - ret, done, - "Wrong change time\n"); /* * Step 3: @@ -446,7 +417,6 @@ static bool test_freeze_thaw(struct torture_context *tctx, si.basic_info.in.create_time = NTTIME_FREEZE; si.basic_info.in.write_time = NTTIME_FREEZE; - si.basic_info.in.change_time = NTTIME_FREEZE; status = smb2_setinfo_file(tree, &si); torture_assert_ntstatus_ok_goto(tctx, status, ret, done, @@ -486,11 +456,6 @@ static bool test_freeze_thaw(struct torture_context *tctx, nttime, ret, done, "Wrong write time\n"); - torture_assert_u64_equal_goto(tctx, - gi.basic_info.out.change_time, - nttime, - ret, done, - "Wrong change time\n"); /* * Step 5: @@ -500,7 +465,6 @@ static bool test_freeze_thaw(struct torture_context *tctx, si.basic_info.in.create_time = NTTIME_THAW; si.basic_info.in.write_time = NTTIME_THAW; - si.basic_info.in.change_time = NTTIME_THAW; status = smb2_setinfo_file(tree, &si); torture_assert_ntstatus_ok_goto(tctx, status, ret, done, @@ -540,11 +504,6 @@ static bool test_freeze_thaw(struct torture_context *tctx, nttime, ret, done, "Wrong write time\n"); - torture_assert_u64_equal_goto(tctx, - gi.basic_info.out.change_time, - nttime, - ret, done, - "Wrong change time\n"); done: if (!smb2_util_handle_empty(handle)) {