Re: realpath(3) bugs

Casper.Dik-QHcLZuEGTsvQT0dZR+AlfA
2012-05-05T07:34:01Z

>I wrote the Linux man page on 1999-08-24.
>It was first included in man-pages-1.26.
>
>The note about Solaris came from the 4.4BSD-Lite man page realpath.3
>(dated 1994-02-16) which says:

Yes, it noticed that it exists in both BSD and Linux manual pages;
I asssumed it was copied by one or the other. Yours address was the
first I could find to get it remoed.

>I forgot the details. What happens if some of the directories involved
>are not readable or not searchable? What happens if some parent
>directory was overmounted so that there is no absolute pathname
>in the system that refers to the same place as your relative pathname?

>From my reading from the source code, it would fail if it fails to find
the pathname, e.g., whem the pathname desn't exist, getcwd() fails,
chdir() fails (the very old implementation uses chdir() to the pathname or
its dirname and runs getcwd()) Later implementation use resolvepath()
(since 1997) and resolvepath() returns a relative pathname if resolvepat
does't find the root) and then combnes the outut with getcwd() removing
one component for each ".." in front of the pathname.

If either of the calls fail, realpath will fail and if it succeeds i returns
a absolute pathname.

Casper