munmap & cp

Dimitry Andric dimitry at
Wed Nov 12 11:18:21 PST 2003

On 2003-11-11 at 15:31:15 Wiktor Niesiobedzki wrote:

> $ mkdir foo
> $ cd foo
> $ touch foo
> $ cp foo foo2
> cp: foo: Invalid argument

Yes, I've just run into this problem too, because a large number of
ports failed to install because of it. This is because they cp -r a
number of directories to be installed, and these obviously contain 0
byte files... :(

Since the cp source doesn't seem to have been touched for 4 months, it
turns out that the semantics of the munmap call changed suddenly, due
to "Open Group Base Specifications Issue 6", see:

I wonder why mmap of 0 bytes is allowed to succeed, and munmap of the
same amount is not, but then again, it's obviously following a
standard, which doesn't have to abide to any rules of logic. ;)

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...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 183 bytes
Desc: not available
Url :

More information about the freebsd-current mailing list