From owner-freebsd-hackers Sat May 13 1:38:51 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id C3F9537B644 for ; Sat, 13 May 2000 01:38:48 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e4D9AvK04795; Sat, 13 May 2000 02:10:57 -0700 (PDT) Date: Sat, 13 May 2000 02:10:57 -0700 From: Alfred Perlstein To: nathan@khmere.com Cc: "hackers@FreeBSD.ORG" Subject: Re: mremap help ? or no support for FreeBSD ? so do what ? Message-ID: <20000513021057.F28383@fw.wintelcom.net> References: <391D39E0.934224E4@khmere.com> <20000512235721.A28383@fw.wintelcom.net> <391D61DA.C9793AAC@khmere.com> <20000513011918.C28383@fw.wintelcom.net> <391D7249.14E1E77B@khmere.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <391D7249.14E1E77B@khmere.com>; from nathan@khmere.com on Sat, May 13, 2000 at 08:18:33AM -0700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * 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