From owner-freebsd-hackers Sat Jun 1 23:01:14 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id XAA01917 for hackers-outgoing; Sat, 1 Jun 1996 23:01:14 -0700 (PDT) Received: from dyson.iquest.net (dyson.iquest.net [198.70.144.127]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id XAA01912; Sat, 1 Jun 1996 23:01:00 -0700 (PDT) Received: (from root@localhost) by dyson.iquest.net (8.7.5/8.6.9) id BAA00232; Sun, 2 Jun 1996 01:00:09 -0500 (EST) From: "John S. Dyson" Message-Id: <199606020600.BAA00232@dyson.iquest.net> Subject: Re: bugs To: bde@zeta.org.au (Bruce Evans) Date: Sun, 2 Jun 1996 01:00:09 -0500 (EST) Cc: bde@freebsd.org, pjf@cts.com, dyson@freebsd.org, hackers@freebsd.org In-Reply-To: <199606020543.PAA12662@godzilla.zeta.org.au> from "Bruce Evans" at Jun 2, 96 03:43:37 pm X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > Which version of FreeBSD? :-) > > >(1) mmap doesn't seem to work for extending a file. Here's a sample: > > >------------------------------------------ > >#include > >#include > >#include > > >main() > >{ > > int fd = open("newfile", O_RDWR|O_CREAT|O_EXCL, 0660); > > char *buf = mmap(NULL, 100, PROT_WRITE, MAP_SHARED, fd, 0); > > printf("%lx\n", buf); > > strcpy(buf, "hi!"); > >} > >------------------------------------------ > > >This test program dies when trying to do the strcpy. What we're > >trying to do is create a file using mmap() instead of write(). > >(This is in BSDI too.) > > I don't know much about mmap. This still seems to be broken. It works if > the file already exists and is nonempty and is opened in non-exclusive > mode. I tried a file of length 512. Setting buf[4095] to 1 didn't trap > but the file wasn't extended. Setting buf[4096] to 1 trapped. > MMAP doesn't extend files, AFAIK it doesn't on many (if not most other OSes.) To set the length of the file you need to do an ftruncate. After that, then blocks will be allocated as needed. John