Copyright (c) 1983, 1991, 1993 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the fol...
NAMEreadlink readlinkat - read value of a symbolic link
SYNOPSISIn 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
DESCRIPTIONThe 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 VALUESThe 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
ERRORSThe 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.