-/* $OpenBSD: uvm_mmap.c,v 1.150 2018/04/27 10:13:37 mpi Exp $ */
+/* $OpenBSD: uvm_mmap.c,v 1.151 2018/08/15 20:22:13 kettenis Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
/*
/* check for file mappings (i.e. not anonymous) and verify file. */
if ((flags & MAP_ANON) == 0) {
- KERNEL_LOCK();
- if ((fp = fd_getfile(fdp, fd)) == NULL) {
- KERNEL_UNLOCK();
+ if ((fp = fd_getfile(fdp, fd)) == NULL)
return (EBADF);
- }
if (fp->f_type != DTYPE_VNODE) {
error = ENODEV; /* only mmap vnodes! */
flags |= MAP_ANON;
FRELE(fp, p);
fp = NULL;
- /* XXX */
- KERNEL_UNLOCK();
goto is_anon;
}
* EPERM.
*/
if (fp->f_flag & FWRITE) {
- if ((error =
- VOP_GETATTR(vp, &va, p->p_ucred, p)))
+ KERNEL_LOCK();
+ error = VOP_GETATTR(vp, &va, p->p_ucred, p);
+ KERNEL_UNLOCK();
+ if (error)
goto out;
if ((va.va_flags & (IMMUTABLE|APPEND)) == 0)
maxprot |= PROT_WRITE;
goto out;
}
}
+ KERNEL_LOCK();
error = uvm_mmapfile(&p->p_vmspace->vm_map, &addr, size, prot, maxprot,
flags, vp, pos, p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur, p);
+ KERNEL_UNLOCK();
} else { /* MAP_ANON case */
if (fd != -1)
return EINVAL;
*retval = (register_t)(addr + pageoff);
out:
- if (fp) {
+ if (fp)
FRELE(fp, p);
- KERNEL_UNLOCK();
- }
return (error);
}