*BSD News Article 16164


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!agate!agate.berkeley.edu!cgd
From: cgd@thresher.CS.Berkeley.EDU (Chris G. Demetriou)
Newsgroups: comp.os.386bsd.misc
Subject: Re: mmap
Date: 16 May 93 22:11:00
Organization: Kernel Hackers 'r' Us
Lines: 55
Distribution: world
Message-ID: <CGD.93May16221100@thresher.CS.Berkeley.EDU>
References: <1t5p55$f1p@urmel.informatik.rwth-aachen.de>
NNTP-Posting-Host: thresher.cs.berkeley.edu
In-reply-to: kuku@acds.physik.rwth-aachen.de's message of 16 May 1993 16:12:21 GMT

In article <1t5p55$f1p@urmel.informatik.rwth-aachen.de> kuku@acds.physik.rwth-aachen.de (Christoph Kukulies) writes:
>I'm wondering whether mmap under 386BSD is broken or if it's just again
>my ignorance.

m-x sarcasm-mode

386BSD's mmap is perfect; you *must* be doing something wrong!  8-)

m-x normal-mode

X    if((memory=mmap(0,1024,PROT_READ|PROT_WRITE,MAP_FILE,fd,0)) == -1){
X    if((memory=mmap(0,1024,PROT_READ|PROT_WRITE,MAP_FILE,fd,0)) == (caddr_t)(-1)){

both of these use MAP_FILE for the flags, to map a normal file...

however, there are other bits of flags, too...  all of the flags
bits are listed here:

(from /usr/include/sys/mman.h)
/*
 * Flags contain mapping type, sharing type and options.
 * Mapping type; choose one
 */
#define MAP_FILE        0x0001  /* mapped from a file or device */
#define MAP_ANON        0x0002  /* allocated from memory, swap space */
#define MAP_TYPE        0x000f  /* mask for type field */

/*
 * Sharing types; choose one
 */
#define MAP_COPY        0x0020  /* "copy" region at mmap time */
#define MAP_SHARED      0x0010  /* share changes */
#define MAP_PRIVATE     0x0000  /* changes are private */

/*
 * Other flags
 */
#define MAP_FIXED       0x0100  /* map addr must be exactly as requested */
#define MAP_NOEXTEND    0x0200  /* for MAP_FILE, don't change file size */
#define MAP_HASSEMPHORE 0x0400  /* region may contain semaphores */
#define MAP_INHERIT     0x0800  /* region is retained after exec */


note that you didn't chose a sharing type, and it defaulted to
MAP_PRIVATE...




chris
--
Chris G. Demetriou                                    cgd@cs.berkeley.edu

   "386bsd as depth first search: whenever you go to fix something you
       find that 3 more things are actually broken." -- Adam Glass