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]

A question about fileio, passing an empty string argument to chdir's problem


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()

------------------------------------------------------------------------------------------------
1  __externC int cyg_mtab_lookup( cyg_dir *dir, const char **name, 
cyg_mtab_entry **mte) 
2  { 
3    cyg_mtab_entry *m, *best = NULL; 
4    int best_len = 0; 
5 
6    // Unrooted file names start from current dir 
7    if( **name != '/' ) { 
8        int cwd_len; 
9        if (*mte == (cyg_mtab_entry *)NULL) { 
10           // No known current directory 
11           return -1; 
12       } 
13   ...
14  } 
------------------------------------------------------------------------------------------------

we add to line 5

------------------------------------------------------------------------------------------------
3    cyg_mtab_entry *m, *best = NULL; 
4    int best_len = 0; 
5 
     if (**name == '\0')        // if an empty string, then **name == '\0'
         return -1;
6    // Unrooted file names start from current dir 
7    if( **name != '/' ) { 
8       int cwd_len; 
9       if (*mte == (cyg_mtab_entry *)NULL) { 
10           // No known current directory 
11           return -1; 
12       } 
13    ...
14    } 
------------------------------------------------------------------------------------------------

But we are not sure whether we are correct, or maybe eCos has some deep 
consideration, so could 

you please examine this, then tell us whether we are right or explain for 
us, thank you so much.


Sincerely Yours


***********************************************
Beijing Sunnorth eCos Maintainer Group

Maintainers:
liqin@sunnorth.com.cn
wanghui@sunnorth.com.cn
taiyun@sunnorth.com.cn
yxinghua@sunnorth.com.cn

Bejing Sunnorth Electronic Technology Co.,LTD
***********************************************


***********************************************
Beijing Sunnorth eCos Maintainer Group

Maintainers:
liqin@sunnorth.com.cn
wanghui@sunnorth.com.cn
taiyun@sunnorth.com.cn
yxinghua@sunnorth.com.cn

Bejing Sunnorth Electronic Technology Co.,LTD
***********************************************

-- 
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]