HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

readlink

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Reads the value of a symbolic link.

Syntax

   #include <unistd.h>

   init readlink(const char *path, char *buf, size_t bufsiz);

Parameters

path

The pathname of a file.

buf

Points to the region of memory where confstr() stores the string value of the variable indicated by name.

len

Is the maximum number of characters that can be placed in buf. If this is not enough to hold the complete string value of name, confstr() truncates the string value to len-1 characters and appends a null terminator (the

0 character).

Return Values

Upon successful completion, the readlink() function will return the number of bytes placed in the buffer when bufsiz is greater than zero, or the number of bytes contained in the symbolic link when bufsiz is equal to zero. If the return value is equal to bufsiz, the buffer need not contain the entire contents of the symbolic link; for bufsiz can be used to determine the size of the contents of the symbolic link. If the readlink() function is unsuccessful, a value of -1 will be returned and errno will be set to indicate the error.

Description

The readlink function will place the contents of the symbolic link, path, in the buffer buf, which has size bufsiz. The contents of the returned symbolic link will not include a null terminator. As a special case, if the value of bufsiz is 0, no change will occur to the buffer buf and readlink() will return the number of bytes contained in the symbolic link.

Implementation Considerations

None.

Errors

If an error occurs, errno is set to one of the following values:

EACCESCAUSE

One of the following:

  • The calling process does not have search permission to a component of the pathname.

  • The calling process does not have execute permission to the file.

 ACTION

One of the following:

  • Make sure that the calling process has search permission to all components of the pathname.

  • Make sure that the calling process has execute permission to the file.

ENAMETOOLONGCAUSE

One of the following:

  • The length of the pathname exceeds the {PATH_MAX} limit (defined in the file <limits.h>).

  • A component of the pathname is longer than {NAME_MAX} (defined in <limits.h>), and {_POSIX_NO_TRUNC} is in effect for that directory.

 ACTION Make sure that both the component's length and the full pathname length do not exceed the {NAME_MAX} or {PATH_MAX} limits.
ENOTDIRCAUSE A component of the pathname is not a directory.
 ACTION Specify a valid pathname.
ELOOPCAUSE A loop exists in symbolic links encountered during resolution of the path argument. This error may be returned if more than {POSIX_SYMLOOP} symbolic links are encountered during resolution of the path argument.
 ACTION Make sure that there is not a loop in the symbolic links that loops more than POSIX_SYMLOOP.
ENOENTCAUSE a component of the pathname for the executable file does not exist, ot pathname points to an empty string.
 ACTION Specify a valid pathname.

See Also

stat(), lstat(), symlink()

Feedback to webmaster