Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 May 2000 02:10:57 -0700
From:      Alfred Perlstein <bright@wintelcom.net>
To:        nathan@khmere.com
Cc:        "hackers@FreeBSD.ORG" <hackers@FreeBSD.ORG>
Subject:   Re: mremap help ? or no support for FreeBSD ? so do what ?
Message-ID:  <20000513021057.F28383@fw.wintelcom.net>
In-Reply-To: <391D7249.14E1E77B@khmere.com>; from nathan@khmere.com on Sat, May 13, 2000 at 08:18:33AM -0700
References:  <391D39E0.934224E4@khmere.com> <20000512235721.A28383@fw.wintelcom.net> <391D61DA.C9793AAC@khmere.com> <20000513011918.C28383@fw.wintelcom.net> <391D7249.14E1E77B@khmere.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* nathan@khmere.com <nathan@khmere.com> [000513 01:53] wrote:
> 
> When you  wrote
> 
> if (!mmap(base + offset, additional length,
>     PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, offset)) {
> 
> This may sound silly but after this is done then the file will
> reflect the changes?
>
> and now the file will extend beyond the original size ? why do
> you need to unmap it ? if the file was mmap 'ed with MAP_SHARED
> and not MAP_FIXED wouldn't the changes be made to all objects?
> then you only need to msync back the diff if any ? (or at all)
>
> See I want to get around using the fd at all. I just want to open
> the file then close it and just reference it from mem only. With
> Linux I think that you can do this by calling mremap  Linux man :
> "mremap expands (or shrinks) an existing memory mapping" So it
> would be kinda like realloc but the changes would be seen by all
> objects...... ? and then I can close the fd and only keep track of
> 1 object. If I need to add to it ....... mremap on it.
> 
> Or am I just way off in my understanding ? I know that I did
> misuse the mmap in the top snipit but I was just playing.....

No, you _must_ write() or ftruncate() the file to extend it before
writing to the mmap'd region, whoever made that actually work (if
it even does) under Linux really tossed the whole interface out
which encourages code that will not work on any other operating
system.

In fact the way you are ab^H^Husing mremap() on Linux may wind up
biting you later when they change the interface to be more like
other mmap() interfaces.

-- 
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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