diff options
author | Robert Love <rlove@google.com> | 2010-10-27 14:53:28 +0800 |
---|---|---|
committer | Lily Zhang <r58066@freescale.com> | 2010-11-22 09:39:19 +0800 |
commit | 418f10aecea02315040eba4e3efbd56782f7bfaf (patch) | |
tree | 278ecc5beaff8267ba3f314b8b18c6f09a4aa4ab /mm/shmem.c | |
parent | 8a7bcef2dba98f1ccb43c93815a8746b656962aa (diff) |
Android MM: Add anonymous shared memory subsystem
ASHMEM is more similar to shmem and mmap, by
not requiring the specified size to be page aligned,
instead rounding it internally as needed, and does not
need export to tmpfs.
Signed-off-by: Robert Love <rlove@google.com>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index f65f84062db5..5446c68fc79d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2739,6 +2739,14 @@ put_memory: } EXPORT_SYMBOL_GPL(shmem_file_setup); +void shmem_set_file(struct vm_area_struct *vma, struct file *file) +{ + if (vma->vm_file) + fput(vma->vm_file); + vma->vm_file = file; + vma->vm_ops = &shmem_vm_ops; +} + /** * shmem_zero_setup - setup a shared anonymous mapping * @vma: the vma to be mmapped is prepared by do_mmap_pgoff @@ -2751,10 +2759,6 @@ int shmem_zero_setup(struct vm_area_struct *vma) file = shmem_file_setup("dev/zero", size, vma->vm_flags); if (IS_ERR(file)) return PTR_ERR(file); - - if (vma->vm_file) - fput(vma->vm_file); - vma->vm_file = file; - vma->vm_ops = &shmem_vm_ops; + shmem_set_file(vma, file); return 0; } |