This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: A question about fileio opendir's problem
- From: Andrew Lunn <andrew at lunn dot ch>
- To: eCos at sunnorth dot com dot cn
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Sun, 2 Mar 2008 21:51:17 +0100
- Subject: Re: [ECOS] A question about fileio opendir's problem
- References: <OF13CF5FBE.FDE049AE-ON482573FE.0033D8D3-482573FE.00341878@sunnorth.com.cn>
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