/* Requires ipc_ids.rw_mutex locked. Returns the LOCKED pointer to the ipc structure if found or NULL if not. If key is found ipc points to the owning ipc structure  */
static struct kern_ipc_perm* ipc_findkey(struct ipc_ids *ids, key_t key)
/* Requires ipc_ids.rw_mutex locked. Returns the LOCKED pointer to the ipc structure if found or NULL if not. If key is found ipc points to the owning ipc structure  */
static struct kern_ipc_perm* ipc_findkey(struct ipc_ids *ids, key_t key)
{
	struct kern_ipc_perm *ipc;
	int next_id;
	int total;
	for (total = 0, next_id = 0; total < ids->in_use; next_id++) {
		ipc = idr_find(&ids->ipcs_idr, next_id);
		if (ipc == NULL)
			continue;
		if (ipc->key != key) {
			total++;
			continue;
		}
		ipc_lock_by_ptr(ipc);
		return ipc;
	}
	return NULL;
}