error = uvm_map(&p->p_vmspace->vm_map, &attach_va, size,
rv = uvm_map(&p->p_vmspace->vm_map, &attach_va, size,
sys_shmat(p, v, retval)	struct proc *p;	void *v;	register_t *retval;{	struct sys_shmat_args /* {		syscallarg(int) shmid;		syscallarg(const void *) shmaddr;		syscallarg(int) shmflg;	} */ *uap = v;	int error, i, flags;	struct ucred *cred = p->p_ucred;	struct shmid_ds *shmseg;	struct shmmap_state *shmmap_s = NULL;	struct shm_handle *shm_handle;	vaddr_t attach_va;	vm_prot_t prot;	vsize_t size;	shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;	if (shmmap_s == NULL) {		size = shminfo.shmseg * sizeof(struct shmmap_state);		shmmap_s = malloc(size, M_SHM, M_WAITOK);		for (i = 0; i < shminfo.shmseg; i++)			shmmap_s[i].shmid = -1;		p->p_vmspace->vm_shm = (caddr_t)shmmap_s;	}	shmseg = shm_find_segment_by_shmid(SCARG(uap, shmid));	if (shmseg == NULL)		return EINVAL;	error = ipcperm(cred, &shmseg->shm_perm,		    (SCARG(uap, shmflg) & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W);	if (error)		return error;	for (i = 0; i < shminfo.shmseg; i++) {		if (shmmap_s->shmid == -1)			break;		shmmap_s++;	}	if (i >= shminfo.shmseg)		return EMFILE;	size = round_page(shmseg->shm_segsz);	prot = VM_PROT_READ;	if ((SCARG(uap, shmflg) & SHM_RDONLY) == 0)		prot |= VM_PROT_WRITE;	flags = MAP_ANON | MAP_SHARED;	if (SCARG(uap, shmaddr)) {		flags |= MAP_FIXED;		if (SCARG(uap, shmflg) & SHM_RND) 			attach_va =			    (vaddr_t)SCARG(uap, shmaddr) & ~(SHMLBA-1);		else if (((vaddr_t)SCARG(uap, shmaddr) & (SHMLBA-1)) == 0)			attach_va = (vaddr_t)SCARG(uap, shmaddr);		else			return EINVAL;	} else {		/* This is just a hint to vm_mmap() about where to put it. */		attach_va = round_page((vaddr_t)p->p_vmspace->vm_taddr +		    MAXTSIZ + MAXDSIZ);	}	shm_handle = shmseg->shm_internal;	uao_reference(shm_handle->shm_object);	error = uvm_map(&p->p_vmspace->vm_map, &attach_va, size,	    shm_handle->shm_object, 0, 0, UVM_MAPFLAG(prot, prot,	    UVM_INH_SHARE, UVM_ADV_RANDOM, 0));	if (error) {		return error;	}	shmmap_s->va = attach_va;	shmmap_s->shmid = SCARG(uap, shmid);	shmseg->shm_lpid = p->p_pid;	shmseg->shm_atime = time.tv_sec;	shmseg->shm_nattch++;	*retval = attach_va;	return 0;}