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: opendir with empty directory name?


Alex,

Thanks for your quick reply!  BTW, will this also apply to jffs2?

Zhichao Hong,CSDP 

-----Original Message-----
From: Alex Garcia [mailto:thekyz@gmail.com] 
Sent: Tuesday, March 18, 2008 11:32 AM
To: Hong,Zhichao
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] opendir with empty directory name?

Hi,

The fatfs implementation of opendir uses init_dirsearch() to check the
actual dir variable passed through the aforementioned.
Here's the function:

static void
init_dirsearch(fatfs_dirsearch_t *ds,
              fatfs_disk_t      *disk,
              fatfs_node_t      *dir,
              const char        *name)
{
   ds->disk = disk;
     if (NULL == dir)
       ds->dir = disk->root;
   else
       ds->dir = dir;
     ds->path    = name;
   ds->node    = ds->dir;
   ds->namelen = 0;
   ds->last    = false;
}

In my understanding of it the function would consider both "" & "." as
referring to the current directory since "." always refers to it this
way, so I would assume ... feature ^^.

More on this just to confirm you that the function I previously
mentioned seem to be the one actually called by the opendir()
implementation.
Take a look at "io/fileio/current/src/dir.cxx" for the actual opendir
function declaration.

The call is handled on line 127 here:

    LOCK_FS( mte );
    ret = mte->fs->opendir( mte, dir, name, file );
    UNLOCK_FS( mte );

Someone may prove me wrong, anyway, my 2 cents.

Alex Garcia

PS: sorry for the double post, forgot to reply-to-all ...

Hong,Zhichao wrote:
> Hi, all,
>  
> I am wondering what is the behavior of opendir("") in eCos fileio 
> implementation?  I am reading some code written by others.  And the 
> comment says open the current directory then code is written as 
> opendir("").
> And the code seems to work as documented.  But should not this 
> actually be opendir(".").  I search the POSIX and various compiler 
> implementation.  It does not seem any of them support this kind of 
> empty directory.  Is this an eCos bug or a feature?
>
> Zhichao Hong,CSDP
>
>
>   

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