fixed readlink call so it works on BSD utils