From owner-freebsd-hackers Wed Aug 11 10:57:36 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from houston.matchlogic.com (houston.matchlogic.com [205.216.147.127]) by hub.freebsd.org (Postfix) with ESMTP id 6F86B14E17 for ; Wed, 11 Aug 1999 10:57:32 -0700 (PDT) (envelope-from crandall@matchlogic.com) Received: by houston.matchlogic.com with Internet Mail Service (5.5.2448.0) id ; Wed, 11 Aug 1999 11:56:42 -0600 Message-ID: <64003B21ECCAD11185C500805F31EC0303786B72@houston.matchlogic.com> From: Charles Randall To: freebsd-hackers@FreeBSD.ORG Cc: Oleg Derevenetz Subject: RE: mmap bug Date: Wed, 11 Aug 1999 11:56:39 -0600 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Looks like Oleg made a mistake in posting the code. I saw an earlier version of this in freebsd-questions and followed up with him. I've appended the version I think he meant to include. He's reporting this behavior with 3.2R. Runs fine with 'mmap -u', appears to hang the machine on the second iteration (file "1") with 'mmap'. Runs fine on Solaris 2.6 and Digital Unix 4.0D -- with the exception of filling the disk without "-u" :^). He's trying to ask if this is a problem with the code in question or 3.2R's mmap. Charles --- mmap.c --- #include #include #include #include #include #include #include main(int argc, char *argv[]) { int fd; int i; int len=1024*1024*10; /*ie 10Mbytes*/ caddr_t addr; char ttt[80]; int bunlink = 0; if ( argc > 1 && strcmp(argv[1], "-u") == 0 ) { bunlink = 1; } printf("unlink files? %s\n", bunlink ? "YES" : "NO"); for (i=0;;i++) { sprintf (ttt,"%d",i); printf("mmaping %ld byte region on file %s\n", len, ttt); fd=open(ttt,O_CREAT|O_RDWR,0666); if (fd<0) { printf("open error %ld\n",errno); exit(1); } lseek(fd,len-1,SEEK_SET); write(fd,"",1); addr=mmap(0,len,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); if (addr==MAP_FAILED) { printf("mmap error %ld",errno); exit(1); } memset(addr,'x',len); if ( munmap(addr, len) != 0 ) { fprintf(stderr, "munmap failed\n"); exit(EXIT_FAILURE); } close(fd); if ( bunlink ) unlink(ttt); } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message