cygwin 1.7 fstat weirdness

Gregg Reynolds dev@mobileink.com
Tue Apr 7 00:16:00 GMT 2009


On Mon, Apr 6, 2009 at 3:11 PM, Corinna Vinschen
<corinna-cygwin@cygwin.com> wrote:
> On Apr  6 14:46, Gregg Reynolds wrote:
>> Hi,
>>
>> I'm trying to get tokyo cabinet running.  I have a strange error.  One
>> of the test utilities does:
>>
>>   #define TCFILEMODE     00644             // permission of a creating file
>>   int fd = path ? open(path, O_RDONLY, TCFILEMODE) : 0;  // path = "Makefile"
>>
>> and then fstats:
>>
>>   if(fstat(fd, &sbuf) == -1) {...}
>>   else {
>>     if (!S_ISREG(sbuf.st_mode)){
>>            printf("is dir %d\n", S_ISDIR(sbuf.st_mode));  // added for debugging
>>            ...etc...
>>   }}
>>
>> What's weird is that fstat says ./Makefile is of type S_ISCHR .  I
>
> Is fd == 0 by any chance?  The 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 == 0.  In this case fd == 3.

> can't open path.  You should debug your code.  Other than that, I'd
> really need a reproducible testcase.  I 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/



More information about the Cygwin mailing list