delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/04/06/16:50:08

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_44,SARE_MSGID_LONG40
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <20090406201123.GT852@calimero.vinschen.de>
References: <75cc17ac0904061246y54f76f40h6611dc982f0a7bdc AT mail DOT gmail DOT com> <20090406201123 DOT GT852 AT calimero DOT vinschen DOT de>
Date: Mon, 6 Apr 2009 15:49:48 -0500
Message-ID: <75cc17ac0904061349t19a50dafrf595d85f5774f48b@mail.gmail.com>
Subject: Re: cygwin 1.7 fstat weirdness
From: Gregg Reynolds <dev AT mobileink DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
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 Mon, Apr 6, 2009 at 3:11 PM, Corinna Vinschen
<corinna-cygwin AT cygwin DOT com> wrote:
> On Apr =C2=A06 14:46, Gregg Reynolds wrote:
>> Hi,
>>
>> I'm trying to get tokyo cabinet running. =C2=A0I have a strange error. =
=C2=A0One
>> of the test utilities does:
>>
>> =C2=A0 #define TCFILEMODE =C2=A0 =C2=A0 00644 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 // permission of a creating file
>> =C2=A0 int fd =3D path ? open(path, O_RDONLY, TCFILEMODE) : 0; =C2=A0// =
path =3D "Makefile"
>>
>> and then fstats:
>>
>> =C2=A0 if(fstat(fd, &sbuf) =3D=3D -1) {...}
>> =C2=A0 else {
>> =C2=A0 =C2=A0 if (!S_ISREG(sbuf.st_mode)){
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf("is dir %d\n", S_ISDIR(s=
buf.st_mode)); =C2=A0// added for debugging
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0...etc...
>> =C2=A0 }}
>>
>> What's weird is that fstat says ./Makefile is of type S_ISCHR . =C2=A0I
>
> Is fd =3D=3D 0 by any chance? =C2=A0The above code silently sets fd to 0 =
if it

Hi,

Sorry, I was a little too concise and didn't show the code that checks
for fd =3D=3D 0.  In this case fd =3D=3D 3.

> can't open path. =C2=A0You should debug your code. =C2=A0Other than that,=
 I'd
> really need a reproducible testcase. =C2=A0I don't see any chance that an
> open file on disk is recognized as S_ISCHR.
>
I haven't been able to reproduce it in a test program.  I think it
might be a linking mixup.  Now I'm seeing a negative value for
sbuf.st_mode.  Is it possible mode_t is too small?  It also may be
that the configuration script sets some #defs that mess with system
defines, I guess.  I'll keep plugging.

Thanks,

gregg

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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