Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Nov 2003 23:25:17 +0100
From:      Wiktor Niesiobedzki <bsd@w.evip.pl>
To:        Dimitry Andric <dimitry@andric.com>
Cc:        current@freebsd.org
Subject:   Re: munmap & cp [patch enclosed]
Message-ID:  <20031112222517.GJ231@mail.evip.pl>
In-Reply-To: <5342692438.20031112201805@andric.com>
References:  <20031111143115.GB231@mail.evip.pl> <5342692438.20031112201805@andric.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--ylS2wUBXLOxYXZFQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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.


--ylS2wUBXLOxYXZFQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch

--- 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);

--ylS2wUBXLOxYXZFQ--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031112222517.GJ231>