summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2019-08-13 15:09:51 +0200
committerJeremy Allison <jra@samba.org>2019-09-17 22:49:36 +0000
commiteb99635d0f2a8dbd52d4a5143efe5a9716401b08 (patch)
treeff5edf9a65975a9d4f6429793c4819171dde395a /source3/locking
parentbe799acb4558f347c6e6a82874897c7af0c0c3d8 (diff)
downloadsamba-eb99635d0f2a8dbd52d4a5143efe5a9716401b08.tar.gz
smbd: Add share_mode_forall_entries()
Abstract away the fact that we store the share modes as an array inside "struct share_mode_data". Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/locking.c47
-rw-r--r--source3/locking/proto.h7
2 files changed, 54 insertions, 0 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 547741ecbc7..e8820ee0356 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -1261,6 +1261,53 @@ bool file_has_open_streams(files_struct *fsp)
return false;
}
+bool share_mode_forall_entries(
+ struct share_mode_lock *lck,
+ bool (*fn)(struct share_mode_entry *e,
+ bool *modified,
+ void *private_data),
+ void *private_data)
+{
+ struct share_mode_data *d = lck->data;
+ uint32_t i;
+
+ for (i=0; i<d->num_share_modes; i++) {
+ struct share_mode_entry *e = &d->share_modes[i];
+ struct server_id pid = e->pid;
+ uint64_t share_file_id = e->share_file_id;
+ bool ok, stop;
+ bool modified = false;
+
+ ok = is_valid_share_mode_entry(e);
+ if (!ok) {
+ continue;
+ }
+
+ stop = fn(e, &modified, private_data);
+
+ if (modified || e->stale) {
+ d->modified = true;
+ }
+
+ if (modified) {
+ /*
+ * In a later commit we will sort the share
+ * mode array keyed by pid and
+ * share_file_id. Make sure that from within
+ * this routine those values don't change.
+ */
+ SMB_ASSERT(server_id_equal(&pid, &e->pid));
+ SMB_ASSERT(share_file_id == e->share_file_id);
+ }
+
+ if (stop) {
+ return true;
+ }
+ }
+
+ return true;
+}
+
/*
* Walk share mode entries, looking at every lease only once
*/
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index f60655eb590..ae8768e68e9 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -223,6 +223,13 @@ bool share_mode_forall_leases(
void *private_data),
void *private_data);
+bool share_mode_forall_entries(
+ struct share_mode_lock *lck,
+ bool (*fn)(struct share_mode_entry *e,
+ bool *modified,
+ void *private_data),
+ void *private_data);
+
/* The following definitions come from locking/posix.c */