static void add_share_mode_entry(struct share_mode_data *d,
const struct share_mode_entry *entry)
{
+ uint32_t i = 0;
+
+ while (i < d->num_share_modes) {
+ struct share_mode_entry *e = &d->share_modes[i];
+ if (e->pid.pid == UINT64_MAX &&
+ e->pid.task_id == UINT32_MAX &&
+ e->pid.vnn == UINT32_MAX &&
+ e->pid.unique_id == UINT64_MAX) {
+ *e = d->share_modes[d->num_share_modes-1];
+ d->num_share_modes -= 1;
+ d->modified = True;
+ continue;
+ }
+
+ i += 1;
+ }
+
ADD_TO_ARRAY(d, struct share_mode_entry, *entry,
&d->share_modes, &d->num_share_modes);
d->modified = True;
bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp)
{
struct share_mode_entry entry, *e;
+ uint32_t i = 0;
/* Don't care about the pid owner being correct here - just a search. */
fill_share_mode_entry(&entry, fsp, (uid_t)-1, 0, NO_OPLOCK);
*e = lck->data->share_modes[lck->data->num_share_modes-1];
lck->data->num_share_modes -= 1;
lck->data->modified = True;
+
+ while (i < lck->data->num_share_modes) {
+ e = &lck->data->share_modes[i];
+
+ if (e->pid.pid == UINT64_MAX &&
+ e->pid.task_id == UINT32_MAX &&
+ e->pid.vnn == UINT32_MAX &&
+ e->pid.unique_id == UINT64_MAX) {
+ *e = lck->data->share_modes[lck->data->num_share_modes-1];
+ lck->data->num_share_modes -= 1;
+ continue;
+ }
+
+ i += 1;
+ }
+
return True;
}