Reads the contents of a symbolic link.
#include <unistd.h>
int readlink ( Path, Buffer, BufferSize)
const char *Path;
char *Buffer;
size_t BufferSize;
The readlink subroutine copies the contents of the symbolic link named by the Path parameter in the buffer specified in the Buffer parameter. The BufferSize parameter indicates the size of the buffer in bytes. If the actual length of the symbolic link is less than the number of bytes specified in the BufferSize parameter, the string copied into the buffer will be null-terminated. If the actual length of the symbolic link is greater than the number of bytes specified in the Buffersize parameter, an error is returned. The length of a symbolic link cannot exceed 1023 characters or the value of the PATH_MAX constant. PATH_MAX is defined in the limits.h file.
Upon successful completion, the readlink subroutine returns a count of the number of characters placed in the buffer (not including any terminating null character). If the readlink subroutine is unsuccessful, the buffer is not modified, a value of -1 is returned, and the errno global variable is set to indicate the error.
The readlink
subroutine fails if one or both of the following are true:
The readlink subroutine can also fail due to additional errors. See "Base Operating System Error Codes for Services that Require Path-Name Resolution" for a list of additional error codes.
The readlink subroutine can also fail due to additional errors. See Appendix A,"Base Operating System Error Codes for Services That Require Path-Name Resolution" on page A-1 for a list of additional error codes.
If Network File System (NFS) is
installed on the system, the readlink subroutine can also fail if
the following is true:
ETIMEDOUT | The connection timed out. |
These subroutines are part of Base Operating System (BOS) Runtime.
This subroutine is part of Base Operating System (BOS) Runtime.
The ln command.
The link subroutine, statx, stat, fstatx, fstat, fullstat, or ffullstat (statx, stat, lstat, fstatx, fstat, fullstat, ffullstat, stat64, lstat64, or fstat64 Subroutine) subroutine, symlink (symlink Subroutine) subroutine, unlink (unlink Subroutine) subroutine.
Files, Directories, and File Systems for Programmers in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.