diff options
author | glebius <glebius@FreeBSD.org> | 2013-06-08 13:13:40 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2013-06-08 13:13:40 +0000 |
commit | 163379d62d47e4f123dc7ec4a8272fedd248d52d (patch) | |
tree | 0731bb5eeb2ebfdb950198635d60023b3dbb4da7 | |
parent | 98da44e07dc7ec986e81e92627be3cef29812d12 (diff) | |
download | FreeBSD-src-163379d62d47e4f123dc7ec4a8272fedd248d52d.zip FreeBSD-src-163379d62d47e4f123dc7ec4a8272fedd248d52d.tar.gz |
Make sys_mlock() function just a wrapper around vm_mlock() function
that does all the job.
Reviewed by: kib, jilles
Sponsored by: Nginx, Inc.
-rw-r--r-- | sys/vm/vm_extern.h | 1 | ||||
-rw-r--r-- | sys/vm/vm_mmap.c | 15 |
2 files changed, 11 insertions, 5 deletions
diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index 74a9b39..4a2dc04 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -90,5 +90,6 @@ struct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset); void vm_imgact_unmap_page(struct sf_buf *sf); void vm_thread_dispose(struct thread *td); int vm_thread_new(struct thread *td, int pages); +int vm_mlock(struct proc *, struct ucred *, const void *, size_t); #endif /* _KERNEL */ #endif /* !_VM_EXTERN_H_ */ diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index bf9f5f9..c7e22c3 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1036,18 +1036,24 @@ sys_mlock(td, uap) struct thread *td; struct mlock_args *uap; { - struct proc *proc; + + return (vm_mlock(td->td_proc, td->td_ucred, uap->addr, uap->len)); +} + +int +vm_mlock(struct proc *proc, struct ucred *cred, const void *addr0, size_t len) +{ vm_offset_t addr, end, last, start; vm_size_t npages, size; vm_map_t map; unsigned long nsize; int error; - error = priv_check(td, PRIV_VM_MLOCK); + error = priv_check_cred(cred, PRIV_VM_MLOCK, 0); if (error) return (error); - addr = (vm_offset_t)uap->addr; - size = uap->len; + addr = (vm_offset_t)addr0; + size = len; last = addr + size; start = trunc_page(addr); end = round_page(last); @@ -1056,7 +1062,6 @@ sys_mlock(td, uap) npages = atop(end - start); if (npages > vm_page_max_wired) return (ENOMEM); - proc = td->td_proc; map = &proc->p_vmspace->vm_map; PROC_LOCK(proc); nsize = ptoa(npages + pmap_wired_count(map->pmap)); |