Subject: Re: WARNING: defaulted mmap() share type to MAP_PRIVATE
To: None <kpneal@pobox.com>
From: Chuck Cranor <chuck@xxx.research.att.com>
List: current-users
Date: 09/16/2000 00:37:22
In article <20000916000443.A11267@tome.neutralgood.org>,
Kevin P. Neal <kpneal@pobox.com> wrote:
>What does this msg mean? I didn't see it until I installed the
>snapshot (i386) that was current on Aug 22.
>WARNING: defaulted mmap() share type to MAP_PRIVATE (pid 2103 comm cmp)
>WARNING: defaulted mmap() share type to MAP_PRIVATE (pid 2103 comm cmp)
>WARNING: defaulted mmap() share type to MAP_PRIVATE (pid 2157 comm cmp)
>WARNING: defaulted mmap() share type to MAP_PRIVATE (pid 2157 comm cmp)
the short answer is that you are running a -DDEBUG kernel and it
is warning you about a program that uses non-standard old-BSD specific
args to mmap(2).
the long answer is:
when you mmap a file you are supposed to use either MAP_PRIVATE
(copy-on-write) or MAP_SHARED. old versions of BSD had a non-standard
flag called MAP_FILE which is defined as:
/usr/include/sys/mman.h:#define MAP_FILE 0x0000 /* map from file (default) */
there is a DEBUG printf in uvm_mmap.c that detects the non-standard usage
of MAP_FILE and let's you know about it:
if ((flags & (MAP_SHARED|MAP_PRIVATE)) == 0) {
#if defined(DEBUG)
printf("WARNING: defaulted mmap() share type to "
"%s (pid %d comm %s)\n", vp->v_type == VCHR ?
"MAP_SHARED" : "MAP_PRIVATE", p->p_pid,
p->p_comm);
#endif
if (vp->v_type == VCHR)
flags |= MAP_SHARED; /* for a device */
else
flags |= MAP_PRIVATE; /* for a file */
}
as you can see from the above code, the best way i could figure to
map "MAP_FILE" into a normal flag value was to treat it as MAP_SHARED
for VCHR devices and MAP_PRIVATE for everything else.
looking at the CVS log of src/usr.bin/cmp/regular.c, i see that mrg
added MAP_PRIVATE in 1.6. jdolecek removed MAP_PRIVATE in 1.9...
a mistake corrected by mycroft in 1.10. this was pulled up to 1.5
branch in 1.8.4.2, so it should be ok now.
however, I believe all occurances of "MAP_FILE" should be removed
from mmap calls in the tree. we shouldn't be using it in our code
(but should leave the #define for backward compat...).
chuck
--
Chuck Cranor http://www.research.att.com/info/chuck
Senior Technical Staff Member chuck@research.att.com
Internet and Networking Systems Research Lab
AT&T Labs-Research, Florham Park, NJ