📄 stat.h.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><sys/stat.h></title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../../jscript/dotcode.js"></script><basefont size="3"> <a name="<sys/stat.h>"></a> <a name="tag_13_62"></a><!-- <sys/stat.h> --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_13_62_01"></a>NAME</h4><blockquote>sys/stat.h - data returned by the stat() function</blockquote><h4><a name="tag_13_62_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><tt>#include <sys/stat.h></tt></p></blockquote><h4><a name="tag_13_62_03"></a>DESCRIPTION</h4><blockquote><p>The <i><sys/stat.h></i> header shall define the structure of the data returned by the functions <a href="../../functions/fstat.html"><i>fstat</i>()</a>, <a href="../../functions/lstat.html"><i>lstat</i>()</a>, and <a href="../../functions/stat.html"><i>stat</i>()</a>.</p><p>The <b>stat</b> structure shall contain at least the following members:</p><pre><tt>dev_t st_dev </tt> Device ID of device containing file. <tt>ino_t st_ino </tt> File serial number. <tt>mode_t st_mode </tt> Mode of file (see below). <tt>nlink_t st_nlink </tt> Number of hard links to the file. <tt>uid_t st_uid </tt> User ID of file. <tt>gid_t st_gid </tt> Group ID of file. <tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../../images/opt-start.gif" alt="[Option Start]" border="0">dev_t st_rdev </tt> Device ID (if file is character or block special). <tt><img src="../../images/opt-end.gif" alt="[Option End]" border="0">off_t st_size </tt> For regular files, the file size in bytes. <tt> </tt> For symbolic links, the length in bytes of the <tt> </tt> pathname contained in the symbolic link. <tt><sup>[<a href="javascript:open_code('SHM')">SHM</a>]</sup><img src="../../images/opt-start.gif" alt="[Option Start]" border="0"> </tt> For a shared memory object, the length in bytes. <tt><img src="../../images/opt-end.gif" alt="[Option End]" border="0"><sup>[<a href="javascript:open_code('TYM')">TYM</a>]</sup><img src="../../images/opt-start.gif" alt="[Option Start]" border="0"> </tt> For a typed memory object, the length in bytes. <tt><img src="../../images/opt-end.gif" alt="[Option End]" border="0"> </tt> For other file types, the use of this field is <tt> </tt> unspecified. <tt>time_t st_atime </tt> Time of last access. <tt>time_t st_mtime </tt> Time of last data modification. <tt>time_t st_ctime </tt> Time of last status change. <tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../../images/opt-start.gif" alt="[Option Start]" border="0">blksize_t st_blksize</tt> A file system-specific preferred I/O block size for <tt> </tt> this object. In some file system types, this may <tt> </tt> vary from file to file. <tt>blkcnt_t st_blocks </tt> Number of blocks allocated for this object. <tt><img src="../../images/opt-end.gif" alt="[Option End]" border="0"></tt></pre><p>The <i>st_ino</i> and <i>st_dev</i> fields taken together uniquely identify the file within the system. The <b>blkcnt_t</b>,<b>blksize_t</b>, <b>dev_t</b>, <b>ino_t</b>, <b>mode_t</b>, <b>nlink_t</b>, <b>uid_t</b>, <b>gid_t</b>, <b>off_t</b>, and<b>time_t</b> types shall be defined as described in <a href="../sys/types.h.html#tag_13_67"><i><sys/types.h></i></a> . Timesshall be given in seconds since the Epoch.</p><p>Unless otherwise specified, the structure members <i>st_mode</i>, <i>st_ino</i>, <i>st_dev</i>, <i>st_uid</i>, <i>st_gid</i>,<i>st_atime</i>, <i>st_ctime</i>, and <i>st_mtime</i> shall have meaningful values for all file types defined inIEEE Std 1003.1-2001.</p><p>For symbolic links, the <i>st_mode</i> member shall contain meaningful information, which can be used with the file type macrosdescribed below, that take a <i>mode</i> argument. The <i>st_size</i> member shall contain the length, in bytes, of the pathnamecontained in the symbolic link. File mode bits and the contents of the remaining members of the <b>stat</b> structure areunspecified. The value returned in the <i>st_size</i> field shall be the length of the contents of the symbolic link, and shall notcount a trailing null if one is present.</p><p>The following symbolic names for the values of type <b>mode_t</b> shall also be defined.</p><p>File type:</p><dl compact><dt>S_IFMT</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../../images/opt-start.gif" alt="[Option Start]" border="0"> Type of file. <dl compact><dt>S_IFBLK</dt><dd>Block special.</dd><dt>S_IFCHR</dt><dd>Character special.</dd><dt>S_IFIFO</dt><dd>FIFO special.</dd><dt>S_IFREG</dt><dd>Regular.</dd><dt>S_IFDIR</dt><dd>Directory.</dd><dt>S_IFLNK</dt><dd>Symbolic link.</dd><dt>S_IFSOCK</dt><dd>Socket. <img src="../../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></dd></dl><p>File mode bits:</p><dl compact><dt>S_IRWXU</dt><dd>Read, write, execute/search by owner. <dl compact><dt>S_IRUSR</dt><dd>Read permission, owner.</dd><dt>S_IWUSR</dt><dd>Write permission, owner.</dd><dt>S_IXUSR</dt><dd>Execute/search permission, owner.</dd></dl></dd><dt>S_IRWXG</dt><dd>Read, write, execute/search by group. <dl compact><dt>S_IRGRP</dt><dd>Read permission, group.</dd><dt>S_IWGRP</dt><dd>Write permission, group.</dd><dt>S_IXGRP</dt><dd>Execute/search permission, group.</dd></dl></dd><dt>S_IRWXO</dt><dd>Read, write, execute/search by others. <dl compact><dt>S_IROTH</dt><dd>Read permission, others.</dd><dt>S_IWOTH</dt><dd>Write permission, others.</dd><dt>S_IXOTH</dt><dd>Execute/search permission, others.</dd></dl></dd><dt>S_ISUID</dt><dd>Set-user-ID on execution.</dd><dt>S_ISGID</dt><dd>Set-group-ID on execution.</dd><dt>S_ISVTX</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../../images/opt-start.gif" alt="[Option Start]" border="0"> On directories, restricted deletion flag. <img src="../../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p>The bits defined by S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH, S_ISUID, S_ISGID, <sup>[<ahref="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../../images/opt-start.gif" alt="[Option Start]" border="0"> andS_ISVTX <img src="../../images/opt-end.gif" alt="[Option End]" border="0"> shall be unique.</p><p>S_IRWXU is the bitwise-inclusive OR of S_IRUSR, S_IWUSR, and S_IXUSR.</p><p>S_IRWXG is the bitwise-inclusive OR of S_IRGRP, S_IWGRP, and S_IXGRP.</p><p>S_IRWXO is the bitwise-inclusive OR of S_IROTH, S_IWOTH, and S_IXOTH.</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -