On Wed, Nov 12, 2003 at 08:18:05PM +0100, Dimitry Andric wrote:
> On 2003-11-11 at 15:31:15 Wiktor Niesiobedzki wrote:
> 
> > $ mkdir foo
> > $ cd foo
> > $ touch foo
> > $ cp foo foo2
> > cp: foo: Invalid argument
> Anyway, cp (and possibly other tools which use munmap) will need to be
> fixed. For now, I simply disabled the VM_AND_BUFFER_CACHE_SYNCHRONIZED
> flag in the Makefile for cp, which simply disables the whole mmap'ing
> stuff. I don't notice any difference without it...
I would still propose my one-line solution, to use mmap only when the file
size is greater than 0. As far as I looked into source tree, most usages of
munmap are in unsafe way - i.e. without checking the return value. 
 
Is there someone willing to commit this trival change? For now, some number of
ports will refuse tu build/install.

Cheers,

Wiktor Niesiobedzki

PS. The acctual patch attached.

--- utils.c     2003/06/22 07:02:17     1.41
+++ utils.c     2003/11/11 14:32:17     
@@ -133,7 +133,7 @@
         * wins some CPU back.
         */
 #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
+       if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576 && fs->st_size > 0) {
-       if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576) {
                if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
                    MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) {
                        warn("%s", entp->fts_path);
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to