⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lstat.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>lstat</title></head><body bgcolor="white"><basefont size="3"> <a name="lstat"></a> <a name="tag_03_355"></a><!-- lstat --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_355_01"></a>NAME</h4><blockquote>lstat - get symbolic link status</blockquote><h4><a name="tag_03_355_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/sys/stat.h.html">sys/stat.h</a>&gt;<br><br> int lstat(const char *restrict</tt> <i>path</i><tt>, struct stat *restrict</tt> <i>buf</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_355_03"></a>DESCRIPTION</h4><blockquote><p>The <i>lstat</i>() function shall be equivalent to <a href="../functions/stat.html"><i>stat</i>()</a>, except when <i>path</i>refers to a symbolic link. In that case <i>lstat</i>() shall return information about the link, while <a href="../functions/stat.html"><i>stat</i>()</a> shall return information about the file the link references.</p><p>For symbolic links, the <i>st_mode</i> member shall contain meaningful information when used with the file type macros, and the<i>st_size</i> member shall contain the length of the pathname contained in the symbolic link. File mode bits and the contents ofthe remaining members of the <b>stat</b> structure are unspecified. The value returned in the <i>st_size</i> member is the lengthof the contents of the symbolic link, and does not count any trailing null.</p></blockquote><h4><a name="tag_03_355_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>lstat</i>() shall return 0. Otherwise, it shall return -1 and set <i>errno</i> to indicate theerror.</p></blockquote><h4><a name="tag_03_355_05"></a>ERRORS</h4><blockquote><p>The <i>lstat</i>() function shall fail if:</p><dl compact><dt>[EACCES]</dt><dd>A component of the path prefix denies search permission.</dd><dt>[EIO]</dt><dd>An error occurred while reading from the file system.</dd><dt>[ELOOP]</dt><dd>A loop exists in symbolic links encountered during resolution of the <i>path</i> argument.</dd><dt>[ENAMETOOLONG]</dt><dd>The length of a pathname exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.</dd><dt>[ENOTDIR]</dt><dd>A component of the path prefix is not a directory.</dd><dt>[ENOENT]</dt><dd>A component of <i>path</i> does not name an existing file or <i>path</i> is an empty string.</dd><dt>[EOVERFLOW]</dt><dd>The file size in bytes or the number of blocks allocated to the file or the file serial number cannot be represented correctlyin the structure pointed to by <i>buf</i>.</dd></dl><p>The <i>lstat</i>() function may fail if:</p><dl compact><dt>[ELOOP]</dt><dd>More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the <i>path</i> argument.</dd><dt>[ENAMETOOLONG]</dt><dd>As a result of encountering a symbolic link in resolution of the <i>path</i> argument, the length of the substituted pathnamestring exceeded {PATH_MAX}.</dd><dt>[EOVERFLOW]</dt><dd>One of the members is too large to store into the structure pointed to by the <i>buf</i> argument.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_355_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_355_06_01"></a>Obtaining Symbolic Link Status Information</h5><p>The following example shows how to obtain status information for a symbolic link named <b>/modules/pass1</b>. The structurevariable <i>buffer</i> is defined for the <b>stat</b> structure. If the <i>path</i> argument specified the filename for the filepointed to by the symbolic link ( <b>/home/cnd/mod1</b>), the results of calling the function would be the same as those returnedby a call to the <a href="../functions/stat.html"><i>stat</i>()</a> function.</p><pre><tt>#include &lt;sys/stat.h&gt;<br>struct stat buffer;int status;...status = lstat("/modules/pass1", &amp;buffer);</tt></pre></blockquote><h4><a name="tag_03_355_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_355_08"></a>RATIONALE</h4><blockquote><p>The <i>lstat</i>() function is not required to update the time-related fields if the named file is not a symbolic link. Whilethe <i>st_uid</i>, <i>st_gid</i>, <i>st_atime</i>, <i>st_mtime</i>, and <i>st_ctime</i> members of the <b>stat</b> structure mayapply to a symbolic link, they are not required to do so. No functions in IEEE&nbsp;Std&nbsp;1003.1-2001 are required to maintainany of these time fields.</p></blockquote><h4><a name="tag_03_355_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_355_10"></a>SEE ALSO</h4><blockquote><p><a href="fstat.html"><i>fstat</i>()</a> , <a href="readlink.html"><i>readlink</i>()</a> , <a href="stat.html"><i>stat</i>()</a>, <a href="symlink.html"><i>symlink</i>()</a> , the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/sys/stat.h.html"><i>&lt;sys/stat.h&gt;</i></a></p></blockquote><h4><a name="tag_03_355_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4, Version 2.</p></blockquote><h4><a name="tag_03_355_12"></a>Issue 5</h4><blockquote><p>Moved from X/OPEN UNIX extension to BASE.</p><p>Large File Summit extensions are added.</p></blockquote><h4><a name="tag_03_355_13"></a>Issue 6</h4><blockquote><p>The following changes were made to align with the IEEE&nbsp;P1003.1a draft standard:</p><ul><li><p>This function is now mandatory.</p></li><li><p>The [ELOOP] optional error condition is added.</p></li></ul><p>The <b>restrict</b> keyword is added to the <i>lstat</i>() prototype for alignment with the ISO/IEC&nbsp;9899:1999 standard.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -