From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7818 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: stdio fixes & internals documentation Date: Fri, 29 May 2015 00:32:38 -0400 Message-ID: <20150529043238.GC17573@brightrain.aerifal.cx> References: <20150529013937.GA32093@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1432873973 20765 80.91.229.3 (29 May 2015 04:32:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 May 2015 04:32:53 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7830-gllmg-musl=m.gmane.org@lists.openwall.com Fri May 29 06:32:53 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YyByW-0005DK-Q9 for gllmg-musl@m.gmane.org; Fri, 29 May 2015 06:32:52 +0200 Original-Received: (qmail 5825 invoked by uid 550); 29 May 2015 04:32:51 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 5806 invoked from network); 29 May 2015 04:32:51 -0000 Content-Disposition: inline In-Reply-To: <20150529013937.GA32093@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:7818 Archived-At: On Thu, May 28, 2015 at 09:39:37PM -0400, Rich Felker wrote: > Once these fixes are taken care of I'd like to look at the EOF logic > in f->read() and moving it out to the callers (only __uflow and fread) > where we won't have to worry about bugs (which I think exist) in the > FILE-type-specific read functions. Actually there don't seem to be such bugs, so I'm not in a big hurry to make changes here. I did notice one issue though with __toread and __towrite: they set the error status for the FILE when an illegal operation (per the fopen mode) is attempted, but they don't set errno. glibc sets errno to EBADF in this case, which I'm not sure is a permitted behavior. POSIX says: [EBADF] [CX] [Option Start] The file descriptor underlying stream is not a valid file descriptor open for reading. [Option End] So if the underlying fd allows reading but the fopen mode doesn't, I think this would be reusing a specified errno value with a meaning distinct from the specified meaning, and thus non-conforming. I don't know what would be an appropriate errno value, though. On the other hand, the general text for EBADF reads: [EBADF] Bad file descriptor. A file descriptor argument is out of range, refers to no open file, or a read (write) request is made to a file that is only open for writing (reading). which makes it sound more permissible here. Rich