readlink(2) CLIX readlink(2)
NAME
readlink - Reads the value of a symbolic link
LIBRARY
Berkeley Software Distribution Library (libbsd.a)
SYNOPSIS
int readlink(
char *path ,
char *buf ,
int bufsize );
PARAMETERS
path Points to the pathname of a symbolic link.
buf Points to location where the file will be placed.
bufsize Specifies the size of buf.
DESCRIPTION
The readlink() function places the contents of the symbolic link name in
the buffer buf with size bufsize. The contents of the link are not null
terminated when returned. Read, write, or execute permission of the named
file is not required, but all directories listed in the pathname leading
to the file must be searchable.
EXAMPLES
char linkbuf[BUFSIZE];
name_len = readlink(symlink_name, linkbuf, BUFSIZE);
if (name_len == -1)
perror("readlink failed");
RETURN VALUES
Upon successful completion the count of characters placed, in the buffer
is returned. Otherwise, a value of -1 is returned and errno is set to
indicate the error.
ERRORS
The readlink() function fails if one or more of the following is true:
[ENOTDIR] A component of the path prefix is not a directory.
2/94 - Intergraph Corporation 1
readlink(2) CLIX readlink(2)
[ENOENT] The named file does not exist, or too many symbolic links
were in the path.
[EACCES] Search permission is denied for a component of the path
prefix.
[EFAULT] Either buf or path points to an invalid address.
[EINVAL] The path parameter does not refer to a symbolic link file.
[EINTR] A signal was caught during the readlink() function.
[ENOLINK] The path parameter points to a remote machine and the link
to that machine is no longer active.
[EMULTIHOP] Components of path require hopping to multiple remote
machines.
RELATED INFORMATION
Functions: lstat(2), symlink(2), stat(2)
2 Intergraph Corporation - 2/94