readlinkat.2freebsd

Langue: en

Version: 338367 (ubuntu - 24/10/10)

Section: 2 (Appels système)


BSD mandoc

NAME

readlink readlinkat - read value of a symbolic link

LIBRARY

Lb libc

SYNOPSIS

In unistd.h Ft ssize_t Fn readlink const char *restrict path char *restrict buf size_t bufsiz Ft ssize_t Fo readlinkat Fa int fd const char *restrict path char *restrict buf size_t bufsize Fc  

DESCRIPTION

The Fn readlink system call places the contents of the symbolic link Fa path in the buffer Fa buf , which has size Fa bufsiz . The Fn readlink system call does not append a NUL character to Fa buf .

The Fn readlinkat system call is equivalent to Fn readlink except in the case where Fa path specifies a relative path. In this case the symbolic link whose content is read relative to the directory associated with the file descriptor Fa fd instead of the current working directory. If Fn readlinkat is passed the special value AT_FDCWD in the Fa fd parameter, the current working directory is used and the behavior is identical to a call to Fn readlink .

RETURN VALUES

The call returns the count of characters placed in the buffer if it succeeds, or a -1 if an error occurs, placing the error code in the global variable errno

ERRORS

The Fn readlink system call will fail if:
Bq Er ENOTDIR
A component of the path prefix is not a directory.
Bq Er ENAMETOOLONG
A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.
Bq Er ENOENT
The named file does not exist.
Bq Er EACCES
Search permission is denied for a component of the path prefix.
Bq Er ELOOP
Too many symbolic links were encountered in translating the pathname.
Bq Er EINVAL
The named file is not a symbolic link.
Bq Er EIO
An I/O error occurred while reading from the file system.
Bq Er EFAULT
The Fa buf argument extends outside the process's allocated address space.

In addition to the errors returned by the Fn readlink , the Fn readlinkat may fail if:

Bq Er EBADF
The Fa path argument does not specify an absolute path and the Fa fd argument is neither AT_FDCWD nor a valid file descriptor open for searching.
Bq Er ENOTDIR
The Fa path argument is not an absolute path and Fa fd is neither AT_FDCWD nor a file descriptor associated with a directory.

SEE ALSO

lstat(2), stat(2), symlink(2), symlink(7)

STANDARDS

The Fn readlinkat system call follows The Open Group Extended API Set 2 specification.

HISTORY

The Fn readlink system call appeared in BSD 4.2 The Fn readlinkat system call appeared in Fx 8.0 .