The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


lstat - get symbolic link status


#include <sys/stat.h>

int lstat(const char *path, struct stat *buf);


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.


Upon successful completion, lstat() returns 0. Otherwise, it returns -1 and sets errno to indicate the error.


The lstat() function will fail if:
A component of the path prefix denies search permission.
An error occurred while reading from the file system.
Too many symbolic links were encountered in resolving path.
The length of a pathname exceeds {PATH_MAX}, or pathname component is longer than {NAME_MAX}.
A component of the path prefix is not a directory.
A component of path does not name an existing file or path is an empty string.
The file size in bytes or the number of blocks allocated to the file or the file serial number cannot be represented correctly in the structure pointed to by buf.

The lstat() function may fail if:

Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.
One of the members is too large to store into the structure pointed to by the buf argument.








fstat(), readlink(), stat(), symlink(), <sys/stat.h>.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]