This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A question about fileio opendir's problem


On Fri, Feb 29, 2008 at 05:29:01PM +0800, eCos@sunnorth.com.cn wrote:
> Dear all:
> 
> Still We have another question about fileio's opendir
> We have checked eCos' source code
> ----------------------------------------------------
> DIR * opendir(const char *path) 
> { 
>         ... 
>         fd = cyg_fd_alloc(1); // Never return fd 0 
>         ... 
> 
>         DIR *dirp = (DIR *)fd;
> 
>          FILEIO_RETURN_VALUE(dirp);
> 
> }
> ----------------------------------------------------
> here opendir function will never be 0, therefore max dirs can be opened 
> will be 1, 2, ..., OPEN_MAX,

I think it is actually 1,2, .., (OPEN_MAX-1)

> the value of max dirs can be opened is OPEN_MAX-1.  However, POSIX
> standard requires the value to be OPEN_MAX
 
> from POSIX document
> The opendir() function shall open a directory stream corresponding to the 
> directory named by the dirname argument. The directory stream is 
> positioned at the first entry. If the type DIR is implemented using a file 
> descriptor, applications shall only be able to open up to a total of 
> {OPEN_MAX} files and directories.

files _and_ directories.

Since a file can take fd==0 it could be argued not being able to
allocate OPEN_MAX directories is O.K. So it depends on how you
interpret "files and directories". 

         Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]