Paul Eggert wrote:
> > * Maintainability: What we have here effectively is a function
> > with 3 possible outcomes:
> > - file is a symlink.
> > - file is not a symlink.
> > - there was an error determining whether file is a symlink.
>
> By "file is not a symlink" do you mean "file is a non-symlink"? Many
> callers want to know whether the directory entry is there. This could be
> done by having 4 outcomes, or (probably better) by having "file does not
> exist" in the "there was an error" category.
>
> It might be useful to return an errno value when there was an error.
Yes, I meant "file is a non-symlink" for the second case.
And yes, in the third case error should be set (preserved) on return.
If this errno value is == ENOENT, it means the file does not exist.
I think we should introduce this function
- to avoid logic bugs in the future,
- for new code, because a normal developer, when wanting to test for
a symlink, would use lstat() + S_ISLNK.
It should take a dirfd parameter; otherwise we need two functions, one
with dirfd parameter and one without.
How should we call it? islnkat? islinkat?
(lstatat and lfstatat would probably be too confusing.)
Bruno