aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorsuzuki <suzuki@in.ibm.com>2005-07-27 14:43:59 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-27 19:25:54 -0400
commit165cd40235732644b1856a5ed5e158c9b93f6010 (patch)
treec68180b6d700953530c8a7852a095f9ac4840345 /mm
parent4bfdf37830111321e2cd1fe0102dd776ce93194d (diff)
[PATCH] madvise() does not always return -EBADF on non-file mapped area
The madvise() system call returns -EBADF for areas which does not map to files, only for *behaviour* request MADV_WILLNEED. According to man pages, madvise returns : EBADF - the map exists, but the area maps something that isn't a file. Fixes bug 2995. Signed-off-by: Suzuki K P <suzuki@in.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/madvise.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mm/madvise.c b/mm/madvise.c
index 73180a22877e..c8c01a12fea4 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -83,9 +83,6 @@ static long madvise_willneed(struct vm_area_struct * vma,
83{ 83{
84 struct file *file = vma->vm_file; 84 struct file *file = vma->vm_file;
85 85
86 if (!file)
87 return -EBADF;
88
89 if (file->f_mapping->a_ops->get_xip_page) { 86 if (file->f_mapping->a_ops->get_xip_page) {
90 /* no bad return value, but ignore advice */ 87 /* no bad return value, but ignore advice */
91 return 0; 88 return 0;
@@ -140,11 +137,16 @@ static long madvise_dontneed(struct vm_area_struct * vma,
140 return 0; 137 return 0;
141} 138}
142 139
143static long madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev, 140static long
144 unsigned long start, unsigned long end, int behavior) 141madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
142 unsigned long start, unsigned long end, int behavior)
145{ 143{
144 struct file *filp = vma->vm_file;
146 long error = -EBADF; 145 long error = -EBADF;
147 146
147 if (!filp)
148 goto out;
149
148 switch (behavior) { 150 switch (behavior) {
149 case MADV_NORMAL: 151 case MADV_NORMAL:
150 case MADV_SEQUENTIAL: 152 case MADV_SEQUENTIAL:
@@ -165,6 +167,7 @@ static long madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev
165 break; 167 break;
166 } 168 }
167 169
170out:
168 return error; 171 return error;
169} 172}
170 173