From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11794 invoked by alias); 21 Jul 2011 19:58:16 -0000 Received: (qmail 11782 invoked by uid 22791); 21 Jul 2011 19:58:15 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from nm25-vm4.bullet.mail.ne1.yahoo.com (HELO nm25-vm4.bullet.mail.ne1.yahoo.com) (98.138.91.185) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Thu, 21 Jul 2011 19:57:59 +0000 Received: from [98.138.90.55] by nm25.bullet.mail.ne1.yahoo.com with NNFMP; 21 Jul 2011 19:57:59 -0000 Received: from [98.138.226.132] by tm8.bullet.mail.ne1.yahoo.com with NNFMP; 21 Jul 2011 19:57:59 -0000 Received: from [127.0.0.1] by smtp219.mail.ne1.yahoo.com with NNFMP; 21 Jul 2011 19:57:58 -0000 X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o- Received: from cgf.cx (cgf@108.20.226.5 with login) by smtp219.mail.ne1.yahoo.com with SMTP; 21 Jul 2011 12:57:58 -0700 PDT Received: from localhost (ednor.casa.cgf.cx [192.168.187.5]) by cgf.cx (Postfix) with ESMTP id CE49613C002 for ; Thu, 21 Jul 2011 15:57:57 -0400 (EDT) Date: Thu, 21 Jul 2011 19:58:00 -0000 From: Christopher Faylor To: cygwin@cygwin.com Subject: Re: ioctl: FIONREAD and ENOTTY Message-ID: <20110721195746.GB11231@ednor.casa.cgf.cx> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <1311149476.7796.50.camel@YAAKOV04> <20110720154647.GA15150@calimero.vinschen.de> <1311201422.6248.10.camel@YAAKOV04> <20110721143930.GP15150@calimero.vinschen.de> <20110721170502.GA11218@ednor.casa.cgf.cx> <20110721174717.GR15150@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110721174717.GR15150@calimero.vinschen.de> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2011-07/txt/msg00289.txt.bz2 On Thu, Jul 21, 2011 at 07:47:17PM +0200, Corinna Vinschen wrote: >On Jul 21 13:05, Christopher Faylor wrote: >> On Thu, Jul 21, 2011 at 04:39:31PM +0200, Corinna Vinschen wrote: >> >On Jul 20 17:37, Yaakov (Cygwin/X) wrote: >> >> On Wed, 2011-07-20 at 17:46 +0200, Corinna Vinschen wrote: >> >> > On Jul 20 03:11, Yaakov (Cygwin/X) wrote: >> >> > > On Linux, ioctl(2) returns several different errors[1]: >> >> > > >> >> > > EBADF d is not a valid descriptor. >> >> > > EFAULT argp references an inaccessible memory area. >> >> > > EINVAL Request or argp is not valid. >> >> > > ENOTTY d is not associated with a character special device. >> >> > > ENOTTY The specified request does not apply to the kind of object that >> >> > > the descriptor d references. >> >> > > >> >> > > In the case of FIONREAD, Cygwin doesn't seem to distinguish between >> >> > > EINVAL and ENOTTY, and this causes at least one major bug: >> >> > > >> >> > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35536 >> >> > > >> >> > > I have patched GCJ and GNU classpath to work around it, but this really >> >> > > needs to be fixed in Cygwin itself. >> >> > >> >> > Would this patch be sufficient? >> >> > >> >> > Index: fhandler.cc >> >> > =================================================================== >> >> > RCS file: /cvs/src/src/winsup/cygwin/fhandler.cc,v >> >> > retrieving revision 1.397 >> >> > diff -u -p -r1.397 fhandler.cc >> >> > --- fhandler.cc 5 Jul 2011 12:02:10 -0000 1.397 >> >> > +++ fhandler.cc 20 Jul 2011 15:46:40 -0000 >> >> > @@ -1151,6 +1151,10 @@ fhandler_base::ioctl (unsigned int cmd, >> >> > set_nonblocking (*(int *) buf); >> >> > res = 0; >> >> > break; >> >> > + case FIONREAD: >> >> > + set_errno (ENOTTY); >> >> > + res = -1; >> >> > + break; >> >> > default: >> >> > set_errno (EINVAL); >> >> > res = -1; >> >> >> >> Given my testcases, give me a few days to check this out. >> > >> >Ok, but the patch doesn't build as is. You have to add >> > >> > #include >> > >> >to get the FIONREAD definition. Sorry about that. >> >> Btw, I don't think the above is sufficient. I think you'll have to add a >> similar test to other fhandlers (like fhandler_windows) which completely >> implement ioctl without reverting to fhandler_base. > >Hmm, isn't that just a bug in these ioctl methods? I think they >all should fall through to fhandler_base::ioctl. Yep. I think you're right. I'll handle that if you want. cgf -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple