aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2005-01-04 05:24:59 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-01-04 05:24:59 -0800
commitf5f20ef06a07cd9f51ba99094cd88bee47bc58d2 (patch)
treeff66bcca6a25718a9332fb447a2dcb3737fb8ba9 /fs
parent6fc96ef247499815299a0d57c64ef7660235315f (diff)
downloadhistory-f5f20ef06a07cd9f51ba99094cd88bee47bc58d2.tar.gz
[PATCH] Permit nommu MAP_SHARED of memory backed files
The attached patch applies some further fixes and extensions to the nommu mmap implementation: (1) /proc/maps distinguishes shareable private mappings and real shared mappings by marking the former with 's' and the latter with 'S'. (2) Rearrange and optimise the checking portion of do_mmap_pgoff() to make it easier to follow. (3) Only set VM_SHARED on MAP_SHARED mappings. Its presence indicates that the backing memory is supplied by the underlying file or chardev. VM_MAYSHARE indicates that a VMA may be shared if it's a private VMA. The memory for a private VMA is allocated by do_mmap_pgoff() from a kmalloc slab and then the file contents are read into it before returning. (4) Permit MAP_SHARED + PROT_WRITE on memory-backed files[*] and chardevs to indicate a contiguous area of memory when its get_unmapped_area() is called if the backing fs/chardev is willing. [*] file->f_mapping->backing_dev_info->memory_backed == 1 (5) Require chardevs and files that support to provide a get_unmapped_area() file operation. (6) Made sure a private mapping of /dev/zero is possible. Shared mappings of /dev/zero are not currently supported because this'd need greater interaction of mmap with the chardev driver than is currently supported. (7) Add in some extra checks from mm/mmap.c: security, file having write access for a writable shared mapping, file not being in append mode. (8) Only account the mapping memory if it's allocated here; memory belonging to a shared chardev or file is not accounted. With this patch it should be possible to map contiguous flash files directly out of ROM simply by providing get_unmapped_area() for a read-only/shared mapping. I think that it might be worth splitting do_mmap_pgoff() up into smaller subfunctions: one to handle the checking, one to handle shared mappings and one to handle private mappings. Signed-Off-By: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/proc/nommu.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index 3423101bb0807f..f3bf016d5ee309 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -62,7 +62,7 @@ static int nommu_vma_list_show(struct seq_file *m, void *v)
flags & VM_READ ? 'r' : '-',
flags & VM_WRITE ? 'w' : '-',
flags & VM_EXEC ? 'x' : '-',
- flags & VM_MAYSHARE ? 's' : 'p',
+ flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
vma->vm_pgoff << PAGE_SHIFT,
MAJOR(dev), MINOR(dev), ino, &len);