Re: realpath(3) bugs

Andries E. Brouwer
2012-05-05T00:06:19Z

On Fri, May 4, 2012 at 11:22 PM, <Casper.Dik-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> wrote:

>> For some reason, many of the realpath() manual pages (BSD, Linux) have
>> words to the following effect:
>>
>> Solaris may return a relative pathname when the path argument is relative.
>>
>> I have looked through the Solaris source files and have found no
>> such bug reported or fixed; the implementation from at least 1997 and
>> beyond certainly doesn't have this problem and even the older versions
>> prepend getcwd() or chdir() to dirname and run getcwd() in that
>> directory.
>>
>> realpath() existed in Solaris 2.0 as it came from SVr4.0 and even at that
>> time i t returned the full, non-relative path.

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:

.Sh CAVEATS
This implementation of
.Fn realpath
differs slightly from the Solaris implementation. The
.Bx 4.4
version always returns absolute pathnames, whereas the
Solaris implementation will, under certain circumstances,
return a relative
.Fa resolved_path
when given a relative
.Fa pathname .

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?

Andries