[En-Nut-Discussion] ReadDir fail, wrong retcode in PhatDirEntryRead ?

Jesper Hansen jesperh at telia.com
Wed Jan 25 22:02:28 CET 2006


I saw how it was done in the ftpd sample, but also read the documentation.
In this case I wonder what the difference between and error and reading 
past the end of the directory is ?
I think the way of checking name[0] for 0 is rather silly and absolutely 
nothing the application should be involved in.
But, you're the one with CVS write access ;-)

/Jesper

Harald Kipp wrote:
> In a simplified way: Yes, I agree.
> 
> In fact this is a bit more complicated, as all routines clearly
> determine between an error and the end of a directory. Though,
> the implementation of readdir() is wrong, because the manual
> page specifies "It returns NULL on reaching the end-of-file or
> if an error occurred."
> 
> ftpserv deals with this wrong implementation, checking for an
> empty name. Changing PhatDirEntryRead() following your suggestion
> will make this and other code (e.g. in PhatDirEntryFind)
> unnecessary.
> 
> That was the complicated part of my acceptance. :-)
> 
> Harald
> 
> 
> At 17:11 25.01.2006 +0100, you wrote:
> 
>> In PhatDirEntryRead, the return code is 0 if the end of the directory 
>> is found. This causes (at least) ReadDir to fail or, more correctly, 
>> to never terminate. The correct return code should have been -1, IMHO.
>>
>> snippet from PhatDirEntryRead
>>
>>   } else {
>>     /* End marker found. */
>>     srch->phfind_name[0] = 0;
>>     return -1; <<<<<<<<<<<<<<<<<< shouldn't this have been here ?
>>   }
>>   break;
> 
> 
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
> 
> 



More information about the En-Nut-Discussion mailing list