From owner-freebsd-hackers Wed Mar 13 1: 3:44 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from pintail.mail.pas.earthlink.net (pintail.mail.pas.earthlink.net [207.217.120.122]) by hub.freebsd.org (Postfix) with ESMTP id 0AED637B405 for ; Wed, 13 Mar 2002 01:03:42 -0800 (PST) Received: from pool0296.cvx15-bradley.dialup.earthlink.net ([209.179.45.41] helo=sm.socccd.cc.ca.us) by pintail.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 16l4fZ-0007Gf-00; Wed, 13 Mar 2002 01:03:37 -0800 Message-ID: <3C8F1635.B6E3FA5A@sm.socccd.cc.ca.us> Date: Wed, 13 Mar 2002 01:04:53 -0800 From: Farooq Mela X-Mailer: Mozilla 4.76 [en] (X11; U; FreeBSD 4.2-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Alfred Perlstein Cc: freebsd-hackers@freebsd.org, tlambert2@mindspring.com Subject: Re: Recv() to a mmap'ed file? References: <3C8E6CD5.67F23CF2@sm.socccd.cc.ca.us> <20020312214851.GK92565@elvis.mu.org> <3C8EEA50.C3E17315@sm.socccd.cc.ca.us> <20020313060553.GF32410@elvis.mu.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi, WRT to Terry's email, I initialized the file by writing N nul ('\0') bytes to it. Alfred Perlstein wrote: > Have you tried the mapping with PROT_READ as well? I don't think > most arches allow for access without PROT_READ along with PROT_WRITE. Oops.. and I even read the thread a little while ago about PROT_WRITE alone not working on x86, but working on alpha because write-only pages are supported on that architecture.. silly me  anyhow, I changed it to use O_RDWR instead of O_WRONLY to open(2) and then I used both PROT_READ and PROT_WRITE as the protection argument, and then the file transfer worked like a charm. Which brings us to the question, on x86 arch why do we even allow a PROT_WRITE only map to be created? It is useless and a program which gets a write-only map will think it actually has such a mmap'ed region, but it will get a SIGBUS if it tries to write to it. It would be better to return -1 and set errno to EFAULT than to have this brain damage imho. -- Farooq To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message