Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4fb23e439ce09157d64b89a21061b9fc08f2b495
Commit:     4fb23e439ce09157d64b89a21061b9fc08f2b495
Parent:     c7ef259bfb4084d8806dfff9eb8bfc6e82bb8c45
Author:     Linus Torvalds <[EMAIL PROTECTED]>
AuthorDate: Sat Dec 16 16:01:50 2006 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Sat Dec 16 16:01:50 2006 -0800

    Fix up mm/mincore.c error value cases
    
    Hugh Dickins correctly points out that mincore() is actually _supposed_
    to fail on an unmapped hole in the user address space, rather than
    return valid ("empty") information about the hole.  This just simplifies
    the problem further (I had been misled by our previous confusing and
    complicated way of doing mincore()).
    
    Also, in the unlikely situation that we can't allocate a temporary
    kernel buffer, we should actually return EAGAIN, not ENOMEM, to keep the
    "unmapped hole" and "allocation failure" error cases separate.
    
    Finally, add a comment about our stupid historical lack of support for
    anonymous mappings.  I'll fix that if somebody reminds me after 2.6.20
    is out.
    
    Acked-by: Hugh Dickins <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 mm/mincore.c |   29 ++++++++++-------------------
 1 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index b44d7f8..566b6c2 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -49,29 +49,20 @@ static long do_mincore(unsigned long addr, unsigned char 
*vec, unsigned long pag
        struct vm_area_struct *vma = find_vma(current->mm, addr);
 
        /*
-        * find_vma() didn't find anything: the address
-        * is above everything we have mapped.
+        * find_vma() didn't find anything above us, or we're
+        * in an unmapped hole in the address space: ENOMEM.
         */
-       if (!vma) {
-               memset(vec, 0, pages);
-               return pages;
-       }
-
-       /*
-        * find_vma() found something, but we might be
-        * below it: check for that.
-        */
-       if (addr < vma->vm_start) {
-               unsigned long gap = (vma->vm_start - addr) >> PAGE_SHIFT;
-               if (gap > pages)
-                       gap = pages;
-               memset(vec, 0, gap);
-               return gap;
-       }
+       if (!vma || addr < vma->vm_start)
+               return -ENOMEM;
 
        /*
         * Ok, got it. But check whether it's a segment we support
         * mincore() on. Right now, we don't do any anonymous mappings.
+        *
+        * FIXME: This is just stupid. And returning ENOMEM is 
+        * stupid too. We should just look at the page tables. But
+        * this is what we've traditionally done, so we'll just
+        * continue doing it.
         */
        if (!vma->vm_file)
                return -ENOMEM;
@@ -142,7 +133,7 @@ asmlinkage long sys_mincore(unsigned long start, size_t len,
 
        tmp = (void *) __get_free_page(GFP_USER);
        if (!tmp)
-               return -ENOMEM;
+               return -EAGAIN;
 
        retval = 0;
        while (pages) {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to