readlink()

read symbolic link 

Function


SYNOPSIS

#include <unistd.h>

int readlink(const char *path, char *buf, size_t bufsize);


DESCRIPTION

The readlink() function places a copy of the symbolic link referenced by path in buffer buf. If no error occurs, the contents of the link are null-terminated when returned.


PARAMETERS

path 

Is the path of symbolic link to be read.

buf 

Is the buffer where the contents of the symbolic link are to be returned.

bufsize 

Is the size of buf, in bytes.


RETURN VALUES

On success, readlink() returns the number of characters passed in buf. On failure, it returns -1 and sets errno to one of the following values:

EACCES 

Search permission is denied on a component of path

EFAULT 

buf or path is an invalid pointer.

EINVAL 

The path argument names a file that is not a symbolic link.

EINVAL 

The path argument contains an invalid character.

ENAMETOOLONG 

The length of path exceeds PATH_MAX, or a path name component is longer than NAME_MAX.

ENOENT 

path points to an empty string, or is the name of a file that does not exist.

ENOSYS 

The file system does not support symbolic links.


CONFORMANCE

UNIX 98, with exceptions.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

Symbolic links are only supported on 8.1/2012R2/2016/2019/2022 on local NTFS-5 file systems. On all other supported platforms, symlink() and readlink() fail. In addition, symbolic links can only point to directories and not to an ordinary file.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
chown(), lchown(), link(), lstat(), open(), stat(), symlink(), unlink()


PTC MKS Toolkit 10.4 Documentation Build 39.