about getcwd

Tu Juan jtu at utstar.com
Sat Sep 8 01:13:37 UTC 2001


see this in getcwd.c:
      /*
       * If it's a mount point, have to stat each element because
       * the inode number in the directory is for the entry in the
       * parent directory, not the inode number of the mounted file.
       */

      save_errno = 0;
if (s.st_dev == dev)   ---------------------- I always goes in here, then
goto notfound.
                                                                   I found
that the dp->d_ino has been set  to 1 in imfs_dir_read (imfs_directory.c)
{                                                                      
   for (;;)
     {
       if (!(dp = _readdir (dir)))
  goto notfound;
       if (dp->d_ino == ino)
  break;
     }
 }
    else   --------------------------- I have tested that this is work. I get the correct path.
 for (;;)
   {
     if (!(dp = _readdir (dir)))
       goto notfound;
     if (ISDOT (dp))
       continue;
     bcopy (dp->d_name, bup, strlen (dp->d_name) + 1);

     /* Save the first error for later. */
     if (stat (up, &s))
       {
  if (!save_errno)
    save_errno = errno;
  errno = 0;
  continue;
       }
     if (s.st_dev == dev && s.st_ino == ino)
       break;
   }


My question is: Why we need this "if"? or I misunderstand something?

----- Original Message ----- 
From: "Joel Sherrill" <joel.sherrill at OARcorp.com>
To: "Tu Juan" <jtu at utstar.com>
Cc: "jennifer averett" <jennifer.averett at OARcorp.com>; <rtems-users at OARcorp.com>
Sent: Friday, September 07, 2001 12:30 PM
Subject: Re: about getcwd


> 
> 
> Tu Juan wrote:
> > 
> > It doesn't work.
> 
> Could you provide a more specific example of the failure?  
> A test case is very much appreciated.
> 
> --joel
> 
> > ----- Original Message -----
> > From: "jennifer averett" <jennifer.averett at oarcorp.com>
> > To: "Tu Juan" <jtu at utstar.com>
> > Cc: <rtems-users at oarcorp.com>
> > Sent: Friday, September 07, 2001 8:01 AM
> > Subject: Re: about getcwd
> > 
> > > I'm sorry but I'm afraid I do not understand the questi
on.
> > > Are you saying that the getcwd does not work or are you
> > > asking how the code works?
> > >
> > > Jennifer
> > >
> > > Tu Juan wrote:
> > >
> > > >    Part 1.1    Type: Plain Text (text/plain)
> > > >            Encoding: quoted-printable
>
> --
> Joel Sherrill, Ph.D.             Director of Research & Development
> joel at OARcorp.com                 On-Line Applications Research
> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
> Support Available                (256) 722-9985




More information about the users mailing list