Make the mincore(2) return ENOMEM when requested range is not fully mapped.

Requested by:	Bruno Haible <bruno at clisp org>
Reviewed by:	alc
Approved by:	pjd (mentor)
MFC after:	1 month
This commit is contained in:
Konstantin Belousov 2006-06-21 12:59:05 +00:00
parent a6557dcb04
commit 455dd7d4c7
2 changed files with 17 additions and 5 deletions

View file

@ -92,12 +92,12 @@ The
.Fn mincore
system call will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
.It Bq Er ENOMEM
The virtual address range specified by the
.Fa addr
and
.Fa len
arguments is not valid.
arguments is not fully mapped.
.It Bq Er EFAULT
The
.Fa vec

View file

@ -757,7 +757,7 @@ mincore(td, uap)
end = addr + (vm_size_t)round_page(uap->len);
map = &td->td_proc->p_vmspace->vm_map;
if (end > vm_map_max(map) || end < addr)
return (EINVAL);
return (ENOMEM);
/*
* Address of byte vector
@ -770,8 +770,10 @@ mincore(td, uap)
RestartScan:
timestamp = map->timestamp;
if (!vm_map_lookup_entry(map, addr, &entry))
entry = entry->next;
if (!vm_map_lookup_entry(map, addr, &entry)) {
vm_map_unlock_read(map);
return (ENOMEM);
}
/*
* Do this on a map entry basis so that if the pages are not
@ -783,6 +785,16 @@ RestartScan:
(current != &map->header) && (current->start < end);
current = current->next) {
/*
* check for contiguity
*/
if (current->end < end &&
(entry->next == &map->header ||
current->next->start > current->end)) {
vm_map_unlock_read(map);
return (ENOMEM);
}
/*
* ignore submaps (for now) or null objects
*/