Mail Archives: djgpp-workers/2003/03/19/17:04:36
Hello.
Eli Zaretskii wrote:
>
> > Date: Wed, 19 Mar 2003 17:44:25 +0000
> > From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
> >
> > 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.
>
> The question is, what does `fstat' do on Unix for file handles opened
> on symbolic links: does it return info about the link or about its
> target?
According to POSIX: You can't get a file descriptor for a symlink using
open(). For a symlink, open() should follow the symlink.
We have the additional options:
* O_NOFOLLOW, which causes open() to fail, if the file is a symlink.
* O_NOLINK, which causes open() to actually open the symlink as a normal file.
If you've used O_NOLINK, I think it's reasonable to return info about the
symlink.
(I think this behaviour is OK.)
I suppose you could get a handle to a symlink using _open(). But in that case
the file descriptor was created outside the normal POSIX I/O functions. I
think it's reasonable to treat the "symlink" as a normal file in that case.
This is analogous to open(..., O_NOLINK|...), I guess.
Bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -