delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/03/19/13:32:13

Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3E78AC79.D615F93B@phekda.freeserve.co.uk>
Date: Wed, 19 Mar 2003 17:44:25 +0000
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: DJGPP workers <djgpp-workers AT delorie DOT com>
Subject: Re: fchdir, revision 2 [PATCH]
References: <E18vcu4-0000a1-00 AT phekda DOT freeserve DOT co DOT uk> <7458-Wed19Mar2003174724+0200-eliz AT elta DOT co DOT il>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Eli Zaretskii wrote:
[snip]
> Fine with me, but I have one question.  In the following snippet from
> fstat:
> 
> > +  /* See if this is a file descriptor for a directory. If so, just
> > +   * use a normal stat call. */
> > +  if (__get_fd_flags(handle) & FILE_DESC_DIRECTORY)
> > +    {
> > +      const char *filename = __get_fd_name(handle);
> > +
> > +      if (filename)
> > +     return stat(filename, statbuf);
> 
> should we call `stat' or `lstat'?

lstat returns statistics about the file or symbolic link named. stat will
return statistics about the file or follow a symbolic link and return
statistics about the target file.

So, since 'handle' refers to a directory, we know it's not a symbolic link. So
we can just stat it.

Ah, I see, you're thinking that 'filename' might contain symbolic links in its
path, thereby requiring an lstat() instead. I don't think that 'filename' will
contain any symbolic links. The filename from fd_props should have no symbolic
links in it, because open() solves all symlinks, before storing the filename
in fd_props.

So I think stat is OK.

Thanks, bye, Rich =]

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019