Clean up readlink() return type The return type of readlink() per POSIX is ssize_t, but most existing callers use int, so fix that. Also fix the return type of the Windows implementation to match.
In _pglstat64(), we neglected to handle the case where the output buffer is not large enough and the result would be truncated. This case actually can't happen, because the Windows pgreadlink() implementation doesn't ever return that case, but adding this seems good for consistency with _pgstat64(), which already had this check, and in case pgreadlink() ever changes in this regard. Some callers of readlink(), in particular _pglstat64(), assume that errno == EINVAL means that the file was not a symlink. But Windows pgreadlink() also sets EINVAL in other cases, in particular if the buffer was too small. This could result in incorrect behavior, so pick a different errno. (There might be other cases where EINVAL is set inappropriately, but they are outside the theme of this patch.) Reviewed-by: Heikki Linnakangas <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/302222eddc3967d11c11708a59bdafd6d51da556 Modified Files -------------- src/backend/access/transam/xlog.c | 2 +- src/backend/backup/basebackup.c | 2 +- src/backend/catalog/pg_tablespace.c | 2 +- src/bin/initdb/findtimezone.c | 2 +- src/bin/pg_combinebackup/pg_combinebackup.c | 2 +- src/bin/pg_rewind/file_ops.c | 2 +- src/include/port.h | 2 +- src/include/port/win32_port.h | 2 +- src/port/dirmod.c | 14 ++++++++++++-- src/port/win32stat.c | 7 ++++++- 10 files changed, 26 insertions(+), 11 deletions(-)
