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, passing an empty string argument to chdir's problem


On Wed, Feb 27, 2008 at 06:06:43PM +0800, eCos@sunnorth.com.cn wrote:
> Dear all:
> 
> We think there is a problem with eCos' chdir. When this fileio's function 
> is passed an empty 
> 
> string as its argument, eCos' chdir does nothing and will not fail. 
> Calling chdir("") seems to 
> 
> have the same effect as chdir(".").
> 
> However, as far as POSIX standard is concerned, calling chdir("") should 
> fail and return ENOENT, 
> 
>  just as described below(from POSIX document), please NOTE the contents in 
> the stars:
> 
> ------------------------------------------------------------------------------------------------
> The chdir() function shall fail if: 
> [EACCES] 
> Search permission is denied for any component of the pathname. 
> [ELOOP] 
> A loop exists in symbolic links encountered during resolution of the path 
> argument. 
> [ENAMETOOLONG] 
> The length of the path argument exceeds {PATH_MAX} or a pathname component 
> is longer than 
> 
> {NAME_MAX}. 
> ***********************************************************************************************
> [ENOENT] 
> A component of path does not name an existing directory or path is an 
> empty string. 
> ***********************************************************************************************
> [ENOTDIR] 
> A component of the pathname is not a directory. 
> ------------------------------------------------------------------------------------------------
> 
> We assume that eCos is in accord with POSIX as a matter of course, and we 
> think maybe this 
> 
> problem can be resolved by adding a check condition to cyg_mtab_lookup 
> function,  cause chdir
> 
> (open, mkdir, etc. are the same) will call cyg_mtab_lookup()

I just checked the man pages for open and mkdir. Only chdir returns
ENOENT for a "" path. Also cyg_mtab_lookup() just finds the mount
point of a filesystem which contains the given path. To me i don't see
why it should be making checks which only apply to chdir().

I would put the check in chdir() itself.

Please send me a patch for this and also extend some of the test cases
which use chdir to test for chdir("") returns ENOENT.

As a side note. You are probably aware of this already, but remember
eCos is thread based, not process based. If a thread uses chdir() it
affects all threads. If you are porting Unix code which was originally
designed to run in a process, not a thread, you might get into
trouble.

        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]