Date: Wed, 13 Mar 2002 01:04:53 -0800 From: Farooq Mela <fmela0@sm.socccd.cc.ca.us> To: Alfred Perlstein <bright@mu.org> Cc: freebsd-hackers@freebsd.org, tlambert2@mindspring.com Subject: Re: Recv() to a mmap'ed file? Message-ID: <3C8F1635.B6E3FA5A@sm.socccd.cc.ca.us> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C8F1635.B6E3FA5A>