Date: Mon, 23 Jun 1997 03:00:40 -0700 From: John-Mark Gurney <jmg@hydrogen.nike.efn.org> To: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: problem with /dev/zero and mmap?? Message-ID: <19970623030040.50241@hydrogen.nike.efn.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970623030040.50241>