delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/07/21/13:06:47

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY
X-Spam-Check-By: sourceware.org
X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o-
Date: Thu, 21 Jul 2011 13:05:03 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: ioctl: FIONREAD and ENOTTY
Message-ID: <20110721170502.GA11218@ednor.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <1311149476 DOT 7796 DOT 50 DOT camel AT YAAKOV04> <20110720154647 DOT GA15150 AT calimero DOT vinschen DOT de> <1311201422 DOT 6248 DOT 10 DOT camel AT YAAKOV04> <20110721143930 DOT GP15150 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20110721143930.GP15150@calimero.vinschen.de>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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 <asm/socket.h>
>
>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.

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019