This makes ashmem more similar to shmem and mmap, by
not requiring the specified size to be page aligned,
instead rounding it internally as needed.
Signed-off-by: Marco Nelissen <marcone@android.com>
/* per custom, you can pass zero for len to mean "everything onward" */
if (!pin.len)
- pin.len = asma->size - pin.offset;
+ pin.len = PAGE_ALIGN(asma->size) - pin.offset;
if (unlikely((pin.offset | pin.len) & ~PAGE_MASK))
return -EINVAL;
if (unlikely(((__u32) -1) - pin.offset < pin.len))
return -EINVAL;
- if (unlikely(asma->size < pin.offset + pin.len))
+ if (unlikely(PAGE_ALIGN(asma->size) < pin.offset + pin.len))
return -EINVAL;
pgstart = pin.offset / PAGE_SIZE;
break;
case ASHMEM_SET_SIZE:
ret = -EINVAL;
- if (!asma->file && !(arg & ~PAGE_MASK)) {
+ if (!asma->file) {
ret = 0;
asma->size = (size_t) arg;
}