Add Readlink() implementation
Closed this issue · 0 comments
We found some underlying readlink(2) implementations to be failing on CentOS 5.10 (libc 2.5), sometimes returning a wrong number of bytes written to the buffer (see readlink()
's manual page). Used from C programs the error was not noticeable, cause we've also found the correct substring to be followed by a zero byte, thus effectively terminating the string for C. But Go doesn't care about zeros; there's no special string termination byte. Hence, os.Readlink()
just continues till the indicated number of bytes and you end up including lots of garbage in the result. Even though readlink()
is not required by POSIX to terminate the result with zero, for our usage it's worth attempting to work around this issue by looking if one is present anyway.