delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2016/10/25/16:49:46

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <580FC5AA.5010009@gmx.de>
Date: Tue, 25 Oct 2016 22:50:50 +0200
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: A grep 2.26 test fails because fopen sets errno to EACCES when
openning an existing directory.
References: <580BCAA5 DOT 2000304 AT gmx DOT de> <83d1irppmj DOT fsf AT gnu DOT org> <580D0638 DOT 8080605 AT gmx DOT de> <numomu$png$1 AT gioia DOT aioe DOT org>
In-Reply-To: <numomu$png$1@gioia.aioe.org>
X-Provags-ID: V03:K0:/kudwD/xD5/iICQq4whKYC4ocSyAl6DcW/BeNFNLccULTwj3Xk2
KUoYZhhjVWagjQAFLX91HlM9gXEf+WKs44JwvBUg8gR2AphNzHacGN9l2ZkN/ojaPoenS9Q
tm34akmxi+fPvj/NAuwxLslsRWjCu5bHnZBB2msy0Ydm+2JorRJaBUagWebUaZoDUAjkE8O
4NRy9Yl+jO7FSekYb5X3Q==
X-UI-Out-Filterresults: notjunk:1;V01:K0:IYhYJcbPJK0=:nKsNYQeLFP1C0u+v5SfQ/1
otGmUejEW5Kg52K8aDLz9m2AoqXWHRm5VTbnkiRZFS7RPk6RYJSdmTv4pHTHmr3nUNxYut4EH
bqh0Sm1r7X5lq7HqRXojUitxL+cXnHom4/7M1IygPmhJulUn3Dv+QGHXJsblMFsfJsm6ONdc6
k31y3j8DLndMQcRTTTjIttT5bvw0Vktz+zvw/nlUE7ulaVp64HDDYwDlypKRMCLYbcV8gjUor
FSey9/OvbVDMbjfa+GKcPalTKoGIvtwAZ2uNdveLFTzfjGkLpYbgbQj+/IED/fM33/4VWLZ6b
oHhMts8/yOG+CtDOcIhiz8mRlSUd5oNMhyDRzd9UZwwadFAc0oEREfnobOB5n+DUpwqOMU72b
2K5w+83OZdt4uMYcw88MMmJA7xxzN9ULLfMfbi0fg73DYCGDyAKiTmx58NmXFdOjs0g9O/9jK
p9R6cdohMCSS/+1ghJUgpNS9c0G09tuKmzZA/fYUFGB6WmcHWTqkJB7y4Csv8qBcgyIGk224Z
wYe6NC0diFbjIZK1R7rG0HT1Mg8BBmswJPkcauEdCAiFpw4pwcY2nBVVjXBQsuInc5KVnMqU/
Ao0yT0lLg5PQ0aMDSmibbtWLzAvIQFxG3iYWhPbCra3+ZJYD88F4Ndb53JIoTa+LrXba6Ytxe
Eg7KPh9V9is1nsHUHysfDLD68hcK9n2ZQ5yYxge93aQj3Mrdy0k6rrBDc9h4bpjP2goSNCnYJ
JWO0yx5YScmeysQYny3PjqPvR17rxA3Cvflu38fz7n77w2lUOuAaSX6zUOA4cyZKlAqA3ePT2
mDJFVYo
Reply-To: djgpp AT delorie DOT com

Am 25.10.2016 06:57, schrieb Martin Str|mberg (ams AT ludd DOT luth DOT se) [via djgpp AT delorie DOT com]:
> "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]"<djgpp AT delorie DOT com>  wrote:
>> I have compiled grep-2.26 with cygwin, debian 8.2.0 and openSUSE 11.4 (my linux box).
>> They all return EISDIR for the failing fread.  These seems to indicate that
>> EISDIR is the defacto value that have been choosen for this fread failure.
>
> How about looking at the documentation?
>
> fread() isn't documented to use errno (not in C99 (sorry that's the
> latest I have, nor in the latest man page for linux
> <http://man7.org/linux/man-pages/man3/fread.3.html>  (I arrived there
> from<https://www.kernel.org/doc/man-pages/>)), so you've found a bug
> in the test suite as in that case it's plainly wrong to look at errno.
>
>
> However, you are one of the few maintaining poor DJGPP, so you're
> welcome to do what you see fit.
>
>

IMHO, there is neither an error in grep nor in the testsuite.  They simple
expect a posix comforming behavior of fopen and fread.  According to the
man pages of my almost 10-year old linux box the following shall hold for
a posix conforming fread (verbatim copy):

RETURN VALUE
        Upon  successful  completion,  fread() shall return the number of ele-
        ments successfully read which is less than nitems only if a read error
        or  end-of-file  is encountered. If size or nitems is 0, fread() shall
        return 0 and the contents of the array and the  state  of  the  stream
        remain unchanged. Otherwise, if a read error occurs, the error indica-
        tor for the stream shall be set,  and errno shall be set  to  indicate
        the error.

I have also inspected http://pubs.opengroup.org/onlinepubs/009695399/functions/fread.html
and it states the same.  Unfortunately nobody says what the errnos are.

But I fear that the issue is far more complicated.  The errno itself is not
really important.  Important is the exit value of grep and this should be 2
but it is 1 for the DJGPP port.  The test issues the following command:
   ./grep -f a/ < /dev/null
and a/ is an empty directory.  The directory is open using fopen and read
using fread.  On linux and djgpp fread returns with a value of zero and the
error status is indagated using ferror.  The linux port returns with some error
and terminates the program immediately with grep status = 2 meanwhile the djgpp
port sees no error at all an continues running until it finishes with grep
status = 1 making the check fail.  I still have not figured out what is going
on here.  I will see how to fix all this.

Regards,
Juan M. Guerrero

- Raw text -


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