This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: cygwin 1.7 fstat weirdness
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/