convert dirname to realpath in case dirname is symlink