From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 2 08:54:13 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 63A0516A4CE; Tue, 2 Mar 2004 08:54:13 -0800 (PST) Received: from VARK.homeunix.com (adsl-68-122-0-124.dsl.pltn13.pacbell.net [68.122.0.124]) by mx1.FreeBSD.org (Postfix) with ESMTP id A9FD843D2F; Tue, 2 Mar 2004 08:54:12 -0800 (PST) (envelope-from das@FreeBSD.ORG) Received: from VARK.homeunix.com (localhost [127.0.0.1]) by VARK.homeunix.com (8.12.11/8.12.10) with ESMTP id i22GrNLL021483; Tue, 2 Mar 2004 08:53:24 -0800 (PST) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.homeunix.com (8.12.11/8.12.10/Submit) id i22GrNiu021482; Tue, 2 Mar 2004 08:53:23 -0800 (PST) (envelope-from das@FreeBSD.ORG) Date: Tue, 2 Mar 2004 08:53:23 -0800 From: David Schultz To: "Jordan K. Hubbard" Message-ID: <20040302165323.GA17665@VARK.homeunix.com> Mail-Followup-To: "Jordan K. Hubbard" , standards@FreeBSD.ORG References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailman-Approved-At: Wed, 03 Mar 2004 04:53:47 -0800 cc: standards@FreeBSD.ORG Subject: Re: Another conformance question... This time fputs(). X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2004 16:54:13 -0000 On Tue, Mar 02, 2004, Jordan K. Hubbard wrote: > That gives us this behavior for our little test program: > > errno = 13, rc = -1 > fwrite errno = 13, rc = 0 > > In both cases, we get EACCES for fputs() or fwrite() attempts on a > read-only file pointer pointing to a read-only device, something we'd > expect to get "permission denied" for I think. Nice catch. I think the wording of POSIX suggests that the error code is supposed to be EBADF, which is returned if ``the file descriptor [...] is not a valid file descriptor for writing.'' Although you could argue that the standard is wrong, Linux and Solaris return EBADF, so we probably should, too. (By the way, there are a few other cantwrite() calls in libc that probably have the same bug.) > In the case where we > open the fp for write access, the FreeBSD behavior is unchanged: > > errno = 19, rc = 0 > fwrite errno = 0, rc = 18 > > Which gives us ENODEV for the fputs(3) and no error for the fwrite(3). > I'm not sure why an error is returned at all in the fputs(3) case since > it seems perfectly valid to write onto /dev/null and simply have the > data be discarded, but that error is coming back from somewhere deeper > of the bowels of stdio and has nothing to do with my proposed diff in > any case. Red Hat Linux, interestingly enough, returns errno 25 in > this case (ENOTTY)! I'll bet the isatty() call in __smakebuf() is setting errno because /dev/null doesn't support the relevant ioctl. Note that rc=0 so libc is ignoring the error and completing the write, even though it spuriously sets errno. In any case, you're right that this is an unrelated bug. > This is your libc. This is your libc on SUSv2*. Any questions? ASCII stupid question, get a stupid ANSI.