HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
l
lstat(2) lstat(2)
NAME
lstat() - get symbolic link status
SYNOPSIS
#include <sys/stat.h>
int lstat(const char *path, struct stat *buf);
DESCRIPTION
The lstat() function has the same effect as
stat(), except when path refers to a symbolic link. In that
case
lstat() returns information about the link, while
stat() returns information about the file the
link references.
For symbolic links, the st_mode member will contain meaningful information when used with the file type
macros, and the st_size member will contain the length of the pathname contained in the symbolic link. File
mode bits and the contents of the remaining members of the
stat structure are unspecified. The value
returned in the st_size member is the length of the contents of the symbolic link, and does not count any
trailing null.
RETURN VALUE
Upon successful completion,
lstat() returns 0. Otherwise, it returns −1 and sets errno to indicate the
error.
ERRORS
The
lstat() function will fail if:
[EACCES] A component of the path prefix denies search permission.
[EIO] An error occurred while reading from the file system.
[ELOOP] Too many symbolic links were encountered in resolving path.
[ENAMETOOLONG] The length of a pathname exceeds
{PATH_MAX} , or pathname component
is longer than
{NAME_MAX} .
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] A component of path does not name an existing file or path is an empty
string.
[EOVERFLOW] The file size in bytes or the number of blocks allocated to the file cannot be
represented correctly in the structure pointed to by buf.
The lstat() function may fail if:
[ENAMETOOLONG] Pathname resolution of a symbolic link produced an intermediate result
whose length exceeds {PATH_MAX}.
SEE ALSO
fstat(2), readlink(2), stat(2), symlink(2)
CHANGE HISTORY
First released in Issue 4, Version 2.
HP-UX 11i Version 1: September 2005 − 1 − Hewlett-Packard Company Section 2−−141