]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:locking: add share_mode_set_{changed,old}_write_time() helpers
authorStefan Metzmacher <metze@samba.org>
Tue, 30 Aug 2022 05:55:03 +0000 (05:55 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 20 Sep 2022 00:34:35 +0000 (00:34 +0000)
These will be used in future to call them unter an existing share mode
lock...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/share_mode_lock.c
source3/locking/share_mode_lock.h

index 933b9377202dc9e61631e535436c255a32c9822d..9d88f7766b2b7db1a57b1c42eb065ca4e10323f6 100644 (file)
@@ -36,6 +36,7 @@
 */
 
 #include "includes.h"
+#include "lib/util/time_basic.h"
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
 #include "share_mode_lock.h"
@@ -1168,6 +1169,42 @@ NTTIME share_mode_changed_write_time(struct share_mode_lock *lck)
        return d->changed_write_time;
 }
 
+void share_mode_set_changed_write_time(struct share_mode_lock *lck, struct timespec write_time)
+{
+       struct file_id fileid = share_mode_lock_file_id(lck);
+       struct share_mode_data *d = share_mode_lock_assert_private_data(lck);
+       struct file_id_buf ftmp;
+       struct timeval_buf tbuf;
+       NTTIME nt = full_timespec_to_nt_time(&write_time);
+
+       DBG_INFO("%s id=%s\n",
+                timespec_string_buf(&write_time, true, &tbuf),
+                file_id_str_buf(fileid, &ftmp));
+
+       if (d->changed_write_time != nt) {
+               d->modified = true;
+               d->changed_write_time = nt;
+       }
+}
+
+void share_mode_set_old_write_time(struct share_mode_lock *lck, struct timespec write_time)
+{
+       struct file_id fileid = share_mode_lock_file_id(lck);
+       struct share_mode_data *d = share_mode_lock_assert_private_data(lck);
+       struct file_id_buf ftmp;
+       struct timeval_buf tbuf;
+       NTTIME nt = full_timespec_to_nt_time(&write_time);
+
+       DBG_INFO("%s id=%s\n",
+                timespec_string_buf(&write_time, true, &tbuf),
+                file_id_str_buf(fileid, &ftmp));
+
+       if (d->changed_write_time != nt) {
+               d->modified = true;
+               d->old_write_time = nt;
+       }
+}
+
 const char *share_mode_servicepath(struct share_mode_lock *lck)
 {
        struct share_mode_data *d = share_mode_lock_assert_private_data(lck);
index e6d7e5dc88f76d08db7dabb0812aa85d000d22a3..1702141c1783f2523abd9d38262d218d4b8d042d 100644 (file)
@@ -106,6 +106,8 @@ bool share_mode_forall_entries(
        void *private_data);
 
 NTTIME share_mode_changed_write_time(struct share_mode_lock *lck);
+void share_mode_set_changed_write_time(struct share_mode_lock *lck, struct timespec write_time);
+void share_mode_set_old_write_time(struct share_mode_lock *lck, struct timespec write_time);
 const char *share_mode_servicepath(struct share_mode_lock *lck);
 char *share_mode_filename(TALLOC_CTX *mem_ctx, struct share_mode_lock *lck);
 char *share_mode_data_dump(