From owner-freebsd-hackers Sat May 27 11:34:45 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 7AEBB37B8F9 for ; Sat, 27 May 2000 11:34:40 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e4RJ91p02825; Sat, 27 May 2000 12:09:01 -0700 (PDT) Date: Sat, 27 May 2000 12:09:01 -0700 From: Alfred Perlstein To: Trent Nelson Cc: hackers@FreeBSD.ORG, dillon@backplane.com Subject: Re: Erroneous mmap() behaviour? Message-ID: <20000527120901.H28594@fw.wintelcom.net> References: <39300E44.558B632F@student.cowan.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <39300E44.558B632F@student.cowan.edu.au>; from tpnelson@echidna.stu.cowan.edu.au on Sun, May 28, 2000 at 02:04:52AM +0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Trent Nelson [000527 11:44] wrote: > > Can someone explain to me why mmap() returns an address map you're > prohibited from accessing if the fd argument represents a file that has > just been created? > [snip incorrect use of mmap] > > Which is where my problem lies. > > Is it me, or mmap()? If it's me, is there any better way of doing what > I want to do? (which is essentially allocating memory to be modified, > then sync'd to a most probably newly-created file). > > From what I can see, the code works as it should in Linux. Linux is wrong. FreeBSD doesn't function as a crutch, you must use mmap() properly. You must use ftruncate() to extend the file before you try to write to an invalid area of the mmap(). -- -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