Messages in this thread Patch in this message | | | From | "Stephen C. Tweedie" <> | Date | Tue, 4 May 1999 21:29:18 +0100 (BST) | Subject | Re: sed not working on /proc files |
| |
Hi,
On Tue, 4 May 1999 16:45:53 +0100 (BST), alan@lxorguk.ukuu.org.uk (Alan Cox) said:
> To save a thousand follow ups - the glibc code does do the right thing but > the kernel thinks any 0 length mmap succeeds and doesnt error it. So its > a kernel funny
Given that we perform both the 0-length check and the file operations check for every successful mmap(), changing the order of the two tests shouldn't have any performance impact. All it does is guarantee that the error returned for mmap on an invalid fd is ENODEV regardless of the other parameters passed in, which seems a perfectly sane thing to do anyway.
--Stephen
---------------------------------------------------------------- --- mm/mmap.c~ Tue Apr 20 22:33:37 1999 +++ mm/mmap.c Tue May 4 21:26:31 1999 @@ -176,6 +176,9 @@ struct vm_area_struct * vma; int error; + if (file && (!file->f_op || !file->f_op->mmap)) + return -ENODEV; + if ((len = PAGE_ALIGN(len)) == 0) return addr; @@ -244,9 +247,6 @@ * specific mapper. the address has already been validated, but * not unmapped, but the maps are removed from the list. */ - if (file && (!file->f_op || !file->f_op->mmap)) - return -ENODEV; - vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); if (!vma) return -ENOMEM; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |