*/
if (VM_MAX_ADDRESS > 0 &&
((vm_offset_t) uap->addr + uap->len) > VM_MAX_ADDRESS)
- return (EINVAL);
+ return (ENOMEM);
if (VM_MIN_ADDRESS > 0 && uap->addr < VM_MIN_ADDRESS)
- return (EINVAL);
+ return (ENOMEM);
if (((vm_offset_t) uap->addr + uap->len) < (vm_offset_t) uap->addr)
- return (EINVAL);
+ return (ENOMEM);
/*
* Since this routine is only advisory, we default to conservative
switch (uap->behav) {
case MADV_RANDOM:
new_behavior = VM_BEHAVIOR_RANDOM;
+ break;
case MADV_SEQUENTIAL:
new_behavior = VM_BEHAVIOR_SEQUENTIAL;
+ break;
case MADV_NORMAL:
- default:
new_behavior = VM_BEHAVIOR_DEFAULT;
+ break;
+ case MADV_WILLNEED:
+ new_behavior = VM_BEHAVIOR_WILLNEED;
+ break;
+ case MADV_DONTNEED:
+ new_behavior = VM_BEHAVIOR_DONTNEED;
+ break;
+ default:
+ return(EINVAL);
}
- result = vm_behavior_set(user_map, start, end, uap->behav);
+ result = vm_behavior_set(user_map, start, end, new_behavior);
switch (result) {
case KERN_SUCCESS:
return (0);
user_map = current_map();
/* vm_wire */
- result = vm_wire(host_priv_self(), user_map, addr, size, VM_PROT_ALL);
+ result = vm_map_wire(user_map, addr, (vm_offset_t)(addr+size), VM_PROT_NONE, TRUE);
return (result == KERN_SUCCESS ? 0 : ENOMEM);
}
vm_map_copy_t tmp;
int err=0;
vm_map_t my_map;
- struct proc *p =(struct proc *)(get_bsdtask_info(current_task()));
+ struct proc *p =(struct proc *)current_proc();
#if 0
extern int print_map_addr;
#endif /* 0 */
if (fp->f_type != DTYPE_VNODE)
return(KERN_INVALID_ARGUMENT);
+
+ if (!(fp->f_flag & FREAD))
+ return (KERN_PROTECTION_FAILURE);
+
vp = (struct vnode *)fp->f_data;
if (vp->v_type != VREG)
return (KERN_INVALID_ARGUMENT);
if (offset & PAGE_MASK_64) {
- printf("map_fd: file offset not page aligned(%d : %s\)n",p->p_pid, p->p_comm);
+ printf("map_fd: file offset not page aligned(%d : %s)\n",p->p_pid, p->p_comm);
return (KERN_INVALID_ARGUMENT);
}
map_size = round_page(size);