diff options
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -1029,6 +1029,40 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, | |||
1029 | } | 1029 | } |
1030 | EXPORT_SYMBOL(do_mmap_pgoff); | 1030 | EXPORT_SYMBOL(do_mmap_pgoff); |
1031 | 1031 | ||
1032 | /* | ||
1033 | * Some shared mappigns will want the pages marked read-only | ||
1034 | * to track write events. If so, we'll downgrade vm_page_prot | ||
1035 | * to the private version (using protection_map[] without the | ||
1036 | * VM_SHARED bit). | ||
1037 | */ | ||
1038 | int vma_wants_writenotify(struct vm_area_struct *vma) | ||
1039 | { | ||
1040 | unsigned int vm_flags = vma->vm_flags; | ||
1041 | |||
1042 | /* If it was private or non-writable, the write bit is already clear */ | ||
1043 | if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED))) | ||
1044 | return 0; | ||
1045 | |||
1046 | /* The backer wishes to know when pages are first written to? */ | ||
1047 | if (vma->vm_ops && vma->vm_ops->page_mkwrite) | ||
1048 | return 1; | ||
1049 | |||
1050 | /* The open routine did something to the protections already? */ | ||
1051 | if (pgprot_val(vma->vm_page_prot) != | ||
1052 | pgprot_val(protection_map[vm_flags & | ||
1053 | (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)])) | ||
1054 | return 0; | ||
1055 | |||
1056 | /* Specialty mapping? */ | ||
1057 | if (vm_flags & (VM_PFNMAP|VM_INSERTPAGE)) | ||
1058 | return 0; | ||
1059 | |||
1060 | /* Can the mapping track the dirty pages? */ | ||
1061 | return vma->vm_file && vma->vm_file->f_mapping && | ||
1062 | mapping_cap_account_dirty(vma->vm_file->f_mapping); | ||
1063 | } | ||
1064 | |||
1065 | |||
1032 | unsigned long mmap_region(struct file *file, unsigned long addr, | 1066 | unsigned long mmap_region(struct file *file, unsigned long addr, |
1033 | unsigned long len, unsigned long flags, | 1067 | unsigned long len, unsigned long flags, |
1034 | unsigned int vm_flags, unsigned long pgoff, | 1068 | unsigned int vm_flags, unsigned long pgoff, |