aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2007-07-16 02:38:26 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:37 -0400
commit0165ab443556bdfad388da6c33d74a71b77d72b2 (patch)
treec2449128f60ebed846b7d63633ccee3f88949a1c
parentc44939ecb6e05aeaaf12d4e1bb046719c97e457e (diff)
split mmap
This is a straightforward split of do_mmap_pgoff() into two functions: - do_mmap_pgoff() checks the parameters, and calculates the vma flags. Then it calls - mmap_region(), which does the actual mapping Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/mm.h4
-rw-r--r--mm/mmap.c25
2 files changed, 23 insertions, 6 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index bbd427e8741a..d4ab4e590e23 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1071,6 +1071,10 @@ extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned lo
1071extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, 1071extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1072 unsigned long len, unsigned long prot, 1072 unsigned long len, unsigned long prot,
1073 unsigned long flag, unsigned long pgoff); 1073 unsigned long flag, unsigned long pgoff);
1074extern unsigned long mmap_region(struct file *file, unsigned long addr,
1075 unsigned long len, unsigned long flags,
1076 unsigned int vm_flags, unsigned long pgoff,
1077 int accountable);
1074 1078
1075static inline unsigned long do_mmap(struct file *file, unsigned long addr, 1079static inline unsigned long do_mmap(struct file *file, unsigned long addr,
1076 unsigned long len, unsigned long prot, 1080 unsigned long len, unsigned long prot,
diff --git a/mm/mmap.c b/mm/mmap.c
index 9f70c8e8c871..144b4a290f2c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -894,14 +894,11 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
894 unsigned long flags, unsigned long pgoff) 894 unsigned long flags, unsigned long pgoff)
895{ 895{
896 struct mm_struct * mm = current->mm; 896 struct mm_struct * mm = current->mm;
897 struct vm_area_struct * vma, * prev;
898 struct inode *inode; 897 struct inode *inode;
899 unsigned int vm_flags; 898 unsigned int vm_flags;
900 int correct_wcount = 0;
901 int error; 899 int error;
902 struct rb_node ** rb_link, * rb_parent;
903 int accountable = 1; 900 int accountable = 1;
904 unsigned long charged = 0, reqprot = prot; 901 unsigned long reqprot = prot;
905 902
906 /* 903 /*
907 * Does the application expect PROT_READ to imply PROT_EXEC? 904 * Does the application expect PROT_READ to imply PROT_EXEC?
@@ -1027,6 +1024,24 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
1027 if (error) 1024 if (error)
1028 return error; 1025 return error;
1029 1026
1027 return mmap_region(file, addr, len, flags, vm_flags, pgoff,
1028 accountable);
1029}
1030EXPORT_SYMBOL(do_mmap_pgoff);
1031
1032unsigned long mmap_region(struct file *file, unsigned long addr,
1033 unsigned long len, unsigned long flags,
1034 unsigned int vm_flags, unsigned long pgoff,
1035 int accountable)
1036{
1037 struct mm_struct *mm = current->mm;
1038 struct vm_area_struct *vma, *prev;
1039 int correct_wcount = 0;
1040 int error;
1041 struct rb_node **rb_link, *rb_parent;
1042 unsigned long charged = 0;
1043 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
1044
1030 /* Clear old maps */ 1045 /* Clear old maps */
1031 error = -ENOMEM; 1046 error = -ENOMEM;
1032munmap_back: 1047munmap_back:
@@ -1175,8 +1190,6 @@ unacct_error:
1175 return error; 1190 return error;
1176} 1191}
1177 1192
1178EXPORT_SYMBOL(do_mmap_pgoff);
1179
1180/* Get an address range which is currently unmapped. 1193/* Get an address range which is currently unmapped.
1181 * For shmat() with addr=0. 1194 * For shmat() with addr=0.
1182 * 1195 *