mirror of https://github.com/mkerrisk/man-pages
138 lines
4.3 KiB
Plaintext
138 lines
4.3 KiB
Plaintext
|
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||
|
.TH "LSTAT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||
|
.\" lstat
|
||
|
.SH NAME
|
||
|
lstat \- get symbolic link status
|
||
|
.SH SYNOPSIS
|
||
|
.LP
|
||
|
\fB#include <sys/stat.h>
|
||
|
.br
|
||
|
.sp
|
||
|
int lstat(const char *restrict\fP \fIpath\fP\fB, struct stat *restrict\fP
|
||
|
\fIbuf\fP\fB);
|
||
|
.br
|
||
|
\fP
|
||
|
.SH DESCRIPTION
|
||
|
.LP
|
||
|
The \fIlstat\fP() function shall be equivalent to \fIstat\fP(), except
|
||
|
when \fIpath\fP
|
||
|
refers to a symbolic link. In that case \fIlstat\fP() shall return
|
||
|
information about the link, while \fIstat\fP() shall return information
|
||
|
about the file the link references.
|
||
|
.LP
|
||
|
For symbolic links, the \fIst_mode\fP member shall contain meaningful
|
||
|
information when used with the file type macros, and the
|
||
|
\fIst_size\fP member shall contain the length of the pathname contained
|
||
|
in the symbolic link. File mode bits and the contents of
|
||
|
the remaining members of the \fBstat\fP structure are unspecified.
|
||
|
The value returned in the \fIst_size\fP member is the length
|
||
|
of the contents of the symbolic link, and does not count any trailing
|
||
|
null.
|
||
|
.SH RETURN VALUE
|
||
|
.LP
|
||
|
Upon successful completion, \fIlstat\fP() shall return 0. Otherwise,
|
||
|
it shall return -1 and set \fIerrno\fP to indicate the
|
||
|
error.
|
||
|
.SH ERRORS
|
||
|
.LP
|
||
|
The \fIlstat\fP() function shall fail if:
|
||
|
.TP 7
|
||
|
.B EACCES
|
||
|
A component of the path prefix denies search permission.
|
||
|
.TP 7
|
||
|
.B EIO
|
||
|
An error occurred while reading from the file system.
|
||
|
.TP 7
|
||
|
.B ELOOP
|
||
|
A loop exists in symbolic links encountered during resolution of the
|
||
|
\fIpath\fP argument.
|
||
|
.TP 7
|
||
|
.B ENAMETOOLONG
|
||
|
The length of a pathname exceeds {PATH_MAX} or a pathname component
|
||
|
is longer than {NAME_MAX}.
|
||
|
.TP 7
|
||
|
.B ENOTDIR
|
||
|
A component of the path prefix is not a directory.
|
||
|
.TP 7
|
||
|
.B ENOENT
|
||
|
A component of \fIpath\fP does not name an existing file or \fIpath\fP
|
||
|
is an empty string.
|
||
|
.TP 7
|
||
|
.B EOVERFLOW
|
||
|
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 \fIbuf\fP.
|
||
|
.sp
|
||
|
.LP
|
||
|
The \fIlstat\fP() function may fail if:
|
||
|
.TP 7
|
||
|
.B ELOOP
|
||
|
More than {SYMLOOP_MAX} symbolic links were encountered during resolution
|
||
|
of the \fIpath\fP argument.
|
||
|
.TP 7
|
||
|
.B ENAMETOOLONG
|
||
|
As a result of encountering a symbolic link in resolution of the \fIpath\fP
|
||
|
argument, the length of the substituted pathname
|
||
|
string exceeded {PATH_MAX}.
|
||
|
.TP 7
|
||
|
.B EOVERFLOW
|
||
|
One of the members is too large to store into the structure pointed
|
||
|
to by the \fIbuf\fP argument.
|
||
|
.sp
|
||
|
.LP
|
||
|
\fIThe following sections are informative.\fP
|
||
|
.SH EXAMPLES
|
||
|
.SS Obtaining Symbolic Link Status Information
|
||
|
.LP
|
||
|
The following example shows how to obtain status information for a
|
||
|
symbolic link named \fB/modules/pass1\fP. The structure
|
||
|
variable \fIbuffer\fP is defined for the \fBstat\fP structure. If
|
||
|
the \fIpath\fP argument specified the filename for the file
|
||
|
pointed to by the symbolic link ( \fB/home/cnd/mod1\fP), the results
|
||
|
of calling the function would be the same as those returned
|
||
|
by a call to the \fIstat\fP() function.
|
||
|
.sp
|
||
|
.RS
|
||
|
.nf
|
||
|
|
||
|
\fB#include <sys/stat.h>
|
||
|
.sp
|
||
|
|
||
|
struct stat buffer;
|
||
|
int status;
|
||
|
\&...
|
||
|
status = lstat("/modules/pass1", &buffer);
|
||
|
\fP
|
||
|
.fi
|
||
|
.RE
|
||
|
.SH APPLICATION USAGE
|
||
|
.LP
|
||
|
None.
|
||
|
.SH RATIONALE
|
||
|
.LP
|
||
|
The \fIlstat\fP() function is not required to update the time-related
|
||
|
fields if the named file is not a symbolic link. While
|
||
|
the \fIst_uid\fP, \fIst_gid\fP, \fIst_atime\fP, \fIst_mtime\fP, and
|
||
|
\fIst_ctime\fP members of the \fBstat\fP structure may
|
||
|
apply to a symbolic link, they are not required to do so. No functions
|
||
|
in IEEE\ Std\ 1003.1-2001 are required to maintain
|
||
|
any of these time fields.
|
||
|
.SH FUTURE DIRECTIONS
|
||
|
.LP
|
||
|
None.
|
||
|
.SH SEE ALSO
|
||
|
.LP
|
||
|
\fIfstat\fP() , \fIreadlink\fP() , \fIstat\fP()
|
||
|
, \fIsymlink\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||
|
\fI<sys/stat.h>\fP
|
||
|
.SH COPYRIGHT
|
||
|
Portions of this text are reprinted and reproduced in electronic form
|
||
|
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||
|
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||
|
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||
|
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||
|
event of any discrepancy between this version and the original IEEE and
|
||
|
The Open Group Standard, the original IEEE and The Open Group Standard
|
||
|
is the referee document. The original Standard can be obtained online at
|
||
|
http://www.opengroup.org/unix/online.html .
|