lstat

Retrieves symbolic link status.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <sys/stat.h>
   
  int lstat (
     const char   *path,
     struct stat  *buf);
  

Parameters

path

(IN) Points to a string containing the path of the directory or file for which status is to be obtained.

buf

(OUT) Points to the structure containing information about the file.

Return Values

If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

1

ENOENT

A component specified in path does not name an existing file or directory, or path is an empty string.

6

EACCES

Search permission is denied for a component of specified in path.

65

ENAMETOOLONG

The length of the path parameter exceeds {PATH_MAX} or a path component is longer than {NAME_MAX}.

105

ENOCONTEXT

The calling thread has no context.

Remarks

If the path refers to a symbolic link, lstat returns information about the link. If the path is the path to a file or directory, lstat is equivalent to stat. On NetWare, lstat is always equivalent to stat because NetWare does not currently support links.

The sys/stat.h header file contains definitions for the stat structure and the fields are described in stat.

See Also