Implement fs::realpath

This can be used to strip all symlinks from a pathname. This is then used to
close #3632.