]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: remove get_change_timespec()
authorRalph Boehme <slow@samba.org>
Fri, 14 Mar 2025 06:59:33 +0000 (07:59 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 27 Mar 2025 05:37:43 +0000 (05:37 +0000)
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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/script/tests/test_smbclient_s3.sh
source3/script/tests/test_timestamps.sh
source3/smbd/dosmode.c
source3/smbd/proto.h
source3/smbd/smb1_nttrans.c
source3/smbd/smb2_close.c
source3/smbd/smb2_create.c
source3/smbd/smb2_trans2.c
source4/torture/smb2/rename.c
source4/torture/smb2/timestamps.c

index 35a283a8546516a2651dfe4f3db1a031dcd05e72..0b076c38d2e849da0d6eb431fb594731d2bcb513 100755 (executable)
@@ -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
index a158beb03d1a0f737990270ba3aeb05a31430fb1..af9625d14efd611b7ff1a568767322f383d20b38 100755 (executable)
@@ -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
index 9a8ecf6e0a7c4a4fbad35c30154052560c4897cb..ee80f79889181d8acdf9ab38351c5737a27d97d6 100644 (file)
@@ -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;
-}
index 4cf10ed727122ccd0bad1f8f7c9639a57b8aba98..ad70e4161ae176bb173ea811cda5ac94b9c5befd 100644 (file)
@@ -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);
index 554059059d4702b99da221754bed168c50046ee4..1d2bae76f897abe41e74b605257a83b5f0fd0cc8 100644 (file)
@@ -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);
index d68c0bd9e6c2a8a509dea1cf92883b3b352ce735..d37b6cec4c8c4559e3537221ec249d56582e7c12 100644 (file)
@@ -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);
index 01e06894364a55f02bf9a27acf7c759c066f4eb6..78da998e1697f70427bdf37ef30bb8af1f5801ee 100644 (file)
@@ -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);
index bfaabaf5db7446a2517c56e3b13a148c3bc2afe9..80f81ffe777c08264426ca6939a2f38359597601 100644 (file)
@@ -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);
index 31e30fa19b49f207dfc7f95e9719a053b0626df0..53cd9f4ad2d551e962dd1fd9d85065bacb1b19be 100644 (file)
@@ -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)) {
index a9416481c61adfae0176ecbe2e972cf54baa0db4..4b15b94535440919b127ce17d24fae7aee69c24c 100644 (file)
@@ -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)) {