struct share_mode_forall_state {
TDB_DATA key;
- int (*fn)(struct file_id fid,
- const struct share_mode_data *data,
- void *private_data);
+ int (*ro_fn)(struct file_id fid,
+ const struct share_mode_data *data,
+ void *private_data);
+ int (*rw_fn)(struct file_id fid,
+ struct share_mode_data *data,
+ void *private_data);
void *private_data;
};
return;
}
- state->fn(fid, d, state->private_data);
+ if (state->ro_fn != NULL) {
+ state->ro_fn(fid, d, state->private_data);
+ } else {
+ state->rw_fn(fid, d, state->private_data);
+ }
TALLOC_FREE(d);
}
return 0;
}
+int share_mode_forall_read(int (*fn)(struct file_id fid,
+ const struct share_mode_data *data,
+ void *private_data),
+ void *private_data)
+{
+ struct share_mode_forall_state state = {
+ .ro_fn = fn,
+ .private_data = private_data
+ };
+ int ret;
+
+ if (lock_ctx == NULL) {
+ return 0;
+ }
+
+ ret = g_lock_locks_read(
+ lock_ctx, share_mode_forall_fn, &state);
+ if (ret < 0) {
+ DBG_ERR("g_lock_locks failed\n");
+ }
+ return ret;
+}
+
int share_mode_forall(int (*fn)(struct file_id fid,
- const struct share_mode_data *data,
+ struct share_mode_data *data,
void *private_data),
void *private_data)
{
struct share_mode_forall_state state = {
- .fn = fn,
+ .rw_fn = fn,
.private_data = private_data
};
int ret;
return 0;
}
- ret = g_lock_locks_read(
+ ret = g_lock_locks(
lock_ctx, share_mode_forall_fn, &state);
if (ret < 0) {
DBG_ERR("g_lock_locks failed\n");
struct share_entry_forall_state state = {
.fn = fn, .private_data = private_data };
- return share_mode_forall(share_entry_traverse_fn, &state);
+ return share_mode_forall_read(share_entry_traverse_fn, &state);
}
static int share_mode_entry_cmp(
NTSTATUS share_mode_count_entries(struct file_id fid, size_t *num_share_modes);
int share_mode_forall(
int (*fn)(struct file_id fid,
- const struct share_mode_data *data,
+ struct share_mode_data *data,
void *private_data),
void *private_data);
+int share_mode_forall_read(int (*fn)(struct file_id fid,
+ const struct share_mode_data *data,
+ void *private_data),
+ void *private_data);
bool share_mode_forall_entries(
struct share_mode_lock *lck,
bool (*fn)(struct share_mode_entry *e,