From owner-freebsd-hackers Mon Jun 23 03:00:47 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id DAA25840 for hackers-outgoing; Mon, 23 Jun 1997 03:00:47 -0700 (PDT) Received: from hydrogen.nike.efn.org (resnet.uoregon.edu [128.223.170.28]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id DAA25830 for ; Mon, 23 Jun 1997 03:00:42 -0700 (PDT) Received: (from jmg@localhost) by hydrogen.nike.efn.org (8.8.5/8.8.5) id DAA15963; Mon, 23 Jun 1997 03:00:40 -0700 (PDT) Message-ID: <19970623030040.50241@hydrogen.nike.efn.org> Date: Mon, 23 Jun 1997 03:00:40 -0700 From: John-Mark Gurney To: FreeBSD Hackers Subject: problem with /dev/zero and mmap?? Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.69 Reply-To: John-Mark Gurney Organization: Cu Networking X-Operating-System: FreeBSD 2.2.1-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk well.. I was just experimenting with mmap and discovered that something works when it shouldn't: fd=open("/dev/zero", O_RDONLY, 0); base=mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); base[0]=4; the above won't cause a bus error.. but replace /dev/zero with a normal file and it will fail as expected (with a Bus error)... shouldn't the mmap behave the same?? if you try and write to the fd, it will set errno to EBADF, just like the man page says... well... I am looking at sys/vm/vm_mmap.c, and it looks like that special hack for SunOS (on line 228) is a bit to early... or does sunos require that you be able to do the above? I know it's minor, but it encorages bad programming, and someone might use code similar to the above and wonder why it stops working when they switch to a normal file, or other char device... -- John-Mark Gurney Modem/FAX: +1 541 683 6954 Cu Networking Live in Peace, destroy Micro$oft, support free software, run FreeBSD