fileutil: avoid using PATH_MAX

Use the dynamically allocated buffer returned by realpath instead of
using PATH_MAX which is not defined on platforms like Hurd.