* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [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 - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to