getcwd: on Solaris, work better if ancestors are inaccessible