X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/96c9b0231cc7a29b2f22d0555ce435c54f29c351..f9cae86329ea8c8fc89870e540c78860261254eb:/sys/vm/vm_mmap.c diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 992e338418..d2b93c3d16 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -229,19 +230,20 @@ kern_mmap(struct vmspace *vms, caddr_t uaddr, size_t ulen, return (EINVAL); if (addr + size < addr) return (EINVAL); + } else if ((flags & MAP_TRYFIXED) == 0) { + /* + * XXX for non-fixed mappings where no hint is provided or + * the hint would fall in the potential heap space, + * place it after the end of the largest possible heap. + * + * There should really be a pmap call to determine a reasonable + * location. + */ + if (addr == 0 || + (addr >= round_page((vm_offset_t)vms->vm_taddr) && + addr < round_page((vm_offset_t)vms->vm_daddr + maxdsiz))) + addr = round_page((vm_offset_t)vms->vm_daddr + maxdsiz); } - /* - * XXX for non-fixed mappings where no hint is provided or - * the hint would fall in the potential heap space, - * place it after the end of the largest possible heap. - * - * There should really be a pmap call to determine a reasonable - * location. - */ - else if (addr == 0 || - (addr >= round_page((vm_offset_t)vms->vm_taddr) && - addr < round_page((vm_offset_t)vms->vm_daddr + maxdsiz))) - addr = round_page((vm_offset_t)vms->vm_daddr + maxdsiz); if (flags & MAP_ANON) { /* @@ -331,7 +333,7 @@ kern_mmap(struct vmspace *vms, caddr_t uaddr, size_t ulen, if (securelevel >= 1) disablexworkaround = 1; else - disablexworkaround = suser(td); + disablexworkaround = priv_check(td, PRIV_ROOT); if (vp->v_type == VCHR && disablexworkaround && (flags & (MAP_PRIVATE|MAP_COPY))) { error = EINVAL; @@ -908,7 +910,7 @@ sys_mlock(struct mlock_args *uap) p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur) return (ENOMEM); #else - error = suser_cred(p->p_ucred, 0); + error = priv_check_cred(p->p_ucred, PRIV_ROOT, 0); if (error) return (error); #endif @@ -960,7 +962,7 @@ sys_munlock(struct munlock_args *uap) return (EINVAL); #ifndef pmap_wired_count - error = suser(td); + error = priv_check(td, PRIV_ROOT); if (error) return (error); #endif @@ -982,7 +984,8 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, { boolean_t fitit; vm_object_t object; - struct vnode *vp = NULL; + struct vnode *vp; + struct thread *td = curthread; struct proc *p; objtype_t type; int rv = KERN_SUCCESS; @@ -1031,10 +1034,11 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, /* * Unnamed anonymous regions always start at 0. */ - if (handle == 0) + if (handle == NULL) foff = 0; + vp = NULL; } else { - vp = (struct vnode *) handle; + vp = (struct vnode *)handle; if (vp->v_type == VCHR) { type = OBJT_DEVICE; handle = (void *)(intptr_t)vp->v_rdev; @@ -1128,6 +1132,12 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, goto out; } } + + /* + * Set the access time on the vnode + */ + if (vp != NULL) + vn_mark_atime(vp, td); out: switch (rv) { case KERN_SUCCESS: