43.html
来自「linux 0.11中文版 有注释」· HTML 代码 · 共 82 行
HTML
82 行
<html>
<head>
<title>include/sys/stat.h</title>
<meta name='robots' content='noindex,nofollow'>
<meta name='generator' content='GLOBAL-5.4.1'>
</head>
<body text='#191970' bgcolor='#f5f5dc' vlink='gray'>
<a name='TOP'><h2><a href='../mains.html'>root</a>/<a href='../files/99.html'>include</a>/<a href='../files/102.html'>sys</a>/stat.h</h2>
<i><font color='green'>/* [<][>][^][v][top]<a href='#BOTTOM'>[bottom]</a><a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</font></i>
<hr>
<h2><a href='../J/43.html' title='Multiple included from 12 places.'>INCLUDED FROM</a></h2>
<hr>
<pre>
<a name='L1'><font color='darkred'>#ifndef</font> <a href='../S/43.html#L2' title='Defined at 2 in include/sys/stat.h.'>_SYS_STAT_H</a>
<a name='L2'><font color='darkred'>#define</font> <a href='../S/43.html#L1' title='Refered from 1 in include/sys/stat.h.'>_SYS_STAT_H</a>
<a name='L3'>
<a name='L4'><font color='darkred'>#include</font> <<a href='45.html'>sys/types.h</a>>
<a name='L5'>
<a name='L6'><b>struct</b> stat
<a name='L7'><font color='red'>{</font>
<a name='L8'> <a href='../S/45.html#L26' title='Defined at 26 in include/sys/types.h.'>dev_t</a> st_dev; <i><font color='green'>// 含有文件的设备号。</font></i>
<a name='L9'> <a href='../S/45.html#L27' title='Defined at 27 in include/sys/types.h.'>ino_t</a> st_ino; <i><font color='green'>// 文件i 节点号。</font></i>
<a name='L10'> <a href='../S/45.html#L29' title='Defined at 29 in include/sys/types.h.'>umode_t</a> st_mode; <i><font color='green'>// 文件属性(见下面)。</font></i>
<a name='L11'> <a href='../S/45.html#L30' title='Defined at 30 in include/sys/types.h.'>nlink_t</a> st_nlink; <i><font color='green'>// 指定文件的连接数。</font></i>
<a name='L12'> <a href='../S/45.html#L24' title='Defined at 24 in include/sys/types.h.'>uid_t</a> st_uid; <i><font color='green'>// 文件的用户(标识)号。</font></i>
<a name='L13'> <a href='../S/45.html#L25' title='Defined at 25 in include/sys/types.h.'>gid_t</a> st_gid; <i><font color='green'>// 文件的组号。</font></i>
<a name='L14'> <a href='../S/45.html#L26' title='Defined at 26 in include/sys/types.h.'>dev_t</a> st_rdev; <i><font color='green'>// 设备号(如果文件是特殊的字符文件或块文件)。</font></i>
<a name='L15'> <a href='../S/45.html#L32' title='Defined at 32 in include/sys/types.h.'>off_t</a> st_size; <i><font color='green'>// 文件大小(字节数)(如果文件是常规文件)。</font></i>
<a name='L16'> <a href='../D/1080.html' title='Multiple defined in 2 places.'>time_t</a> st_atime; <i><font color='green'>// 上次(最后)访问时间。</font></i>
<a name='L17'> <a href='../D/1080.html' title='Multiple defined in 2 places.'>time_t</a> st_mtime; <i><font color='green'>// 最后修改时间。</font></i>
<a name='L18'> <a href='../D/1080.html' title='Multiple defined in 2 places.'>time_t</a> st_ctime; <i><font color='green'>// 最后节点修改时间。</font></i>
<a name='L19'><font color='red'>}</font>;
<a name='L20'>
<a name='L21'><i><font color='green'>// 以下这些是st_mode 值的符号名称。</font></i>
<a name='L22'><i><font color='green'>// 文件类型:</font></i>
<a name='L23'><font color='darkred'>#define</font> <a href='../R/244.html' title='Multiple refered from 5 places.'>S_IFMT</a> 00170000 <i><font color='green'>// 文件类型(8 进制表示)。</font></i>
<a name='L24'><font color='darkred'>#define</font> <a href='../S/43.html#L34' title='Refered from 34 in include/sys/stat.h.'>S_IFREG</a> 0100000 <i><font color='green'>// 常规文件。</font></i>
<a name='L25'><font color='darkred'>#define</font> <a href='../S/43.html#L37' title='Refered from 37 in include/sys/stat.h.'>S_IFBLK</a> 0060000 <i><font color='green'>// 块特殊(设备)文件,如磁盘dev/fd0。</font></i>
<a name='L26'><font color='darkred'>#define</font> <a href='../S/43.html#L35' title='Refered from 35 in include/sys/stat.h.'>S_IFDIR</a> 0040000 <i><font color='green'>// 目录文件。</font></i>
<a name='L27'><font color='darkred'>#define</font> <a href='../S/43.html#L36' title='Refered from 36 in include/sys/stat.h.'>S_IFCHR</a> 0020000 <i><font color='green'>// 字符设备文件。</font></i>
<a name='L28'><font color='darkred'>#define</font> <a href='../S/43.html#L38' title='Refered from 38 in include/sys/stat.h.'>S_IFIFO</a> 0010000 <i><font color='green'>// FIFO 特殊文件。</font></i>
<a name='L29'><i><font color='green'>// 文件属性位:</font></i>
<a name='L30'><font color='darkred'>#define</font> <a href='../S/8.html#L330' title='Refered from 330 in fs/exec.c.'>S_ISUID</a> 0004000 <i><font color='green'>// 执行时设置用户ID(set-user-ID)。</font></i>
<a name='L31'><font color='darkred'>#define</font> <a href='../S/8.html#L331' title='Refered from 331 in fs/exec.c.'>S_ISGID</a> 0002000 <i><font color='green'>// 执行时设置组ID。</font></i>
<a name='L32'><font color='darkred'>#define</font> <a href='../R/252.html' title='Multiple refered from 2 places.'>S_ISVTX</a> 0001000 <i><font color='green'>// 对于目录,受限删除标志。</font></i>
<a name='L33'>
<a name='L34'><font color='darkred'>#define</font> <a href='../R/250.html' title='Multiple refered from 4 places.'>S_ISREG</a>(m) (((m) & <a href='../S/43.html#L23' title='Defined at 23 in include/sys/stat.h.'>S_IFMT</a>) == <a href='../S/43.html#L24' title='Defined at 24 in include/sys/stat.h.'>S_IFREG</a>) <i><font color='green'>// 测试是否常规文件。</font></i>
<a name='L35'><font color='darkred'>#define</font> <a href='../R/248.html' title='Multiple refered from 10 places.'>S_ISDIR</a>(m) (((m) & <a href='../S/43.html#L23' title='Defined at 23 in include/sys/stat.h.'>S_IFMT</a>) == <a href='../S/43.html#L26' title='Defined at 26 in include/sys/stat.h.'>S_IFDIR</a>) <i><font color='green'>// 是否目录文件。</font></i>
<a name='L36'><font color='darkred'>#define</font> <a href='../R/247.html' title='Multiple refered from 5 places.'>S_ISCHR</a>(m) (((m) & <a href='../S/43.html#L23' title='Defined at 23 in include/sys/stat.h.'>S_IFMT</a>) == <a href='../S/43.html#L27' title='Defined at 27 in include/sys/stat.h.'>S_IFCHR</a>) <i><font color='green'>// 是否字符设备文件。</font></i>
<a name='L37'><font color='darkred'>#define</font> <a href='../R/246.html' title='Multiple refered from 8 places.'>S_ISBLK</a>(m) (((m) & <a href='../S/43.html#L23' title='Defined at 23 in include/sys/stat.h.'>S_IFMT</a>) == <a href='../S/43.html#L25' title='Defined at 25 in include/sys/stat.h.'>S_IFBLK</a>) <i><font color='green'>// 是否块设备文件。</font></i>
<a name='L38'><font color='darkred'>#define</font> S_ISFIFO(m) (((m) & <a href='../S/43.html#L23' title='Defined at 23 in include/sys/stat.h.'>S_IFMT</a>) == <a href='../S/43.html#L28' title='Defined at 28 in include/sys/stat.h.'>S_IFIFO</a>) <i><font color='green'>// 是否FIFO 特殊文件。</font></i>
<a name='L39'>
<a name='L40'><font color='darkred'>#define</font> S_IRWXU 00700 <i><font color='green'>// 宿主可以读、写、执行/搜索。</font></i>
<a name='L41'><font color='darkred'>#define</font> S_IRUSR 00400 <i><font color='green'>// 宿主读许可。</font></i>
<a name='L42'><font color='darkred'>#define</font> S_IWUSR 00200 <i><font color='green'>// 宿主写许可。</font></i>
<a name='L43'><font color='darkred'>#define</font> S_IXUSR 00100 <i><font color='green'>// 宿主执行/搜索许可。</font></i>
<a name='L44'>
<a name='L45'><font color='darkred'>#define</font> S_IRWXG 00070 <i><font color='green'>// 组成员可以读、写、执行/搜索。</font></i>
<a name='L46'><font color='darkred'>#define</font> S_IRGRP 00040 <i><font color='green'>// 组成员读许可。</font></i>
<a name='L47'><font color='darkred'>#define</font> S_IWGRP 00020 <i><font color='green'>// 组成员写许可。</font></i>
<a name='L48'><font color='darkred'>#define</font> S_IXGRP 00010 <i><font color='green'>// 组成员执行/搜索许可。</font></i>
<a name='L49'>
<a name='L50'><font color='darkred'>#define</font> S_IRWXO 00007 <i><font color='green'>// 其他人读、写、执行/搜索许可。</font></i>
<a name='L51'><font color='darkred'>#define</font> S_IROTH 00004 <i><font color='green'>// 其他人读许可。</font></i>
<a name='L52'><font color='darkred'>#define</font> S_IWOTH 00002 <i><font color='green'>// 其他人写许可。</font></i>
<a name='L53'><font color='darkred'>#define</font> S_IXOTH 00001 <i><font color='green'>// 其他人执行/搜索许可。</font></i>
<a name='L54'>
<a name='L55'><b>extern</b> <b>int</b> chmod (<b>const</b> <b>char</b> *_path, <a href='../S/45.html#L28' title='Defined at 28 in include/sys/types.h.'>mode_t</a> mode); <i><font color='green'>// 修改文件属性。</font></i>
<a name='L56'><b>extern</b> <b>int</b> fstat (<b>int</b> fildes, <b>struct</b> stat *stat_buf); <i><font color='green'>// 取指定文件句柄的文件状态信息。</font></i>
<a name='L57'><b>extern</b> <b>int</b> mkdir (<b>const</b> <b>char</b> *_path, <a href='../S/45.html#L28' title='Defined at 28 in include/sys/types.h.'>mode_t</a> mode); <i><font color='green'>// 创建目录。</font></i>
<a name='L58'><b>extern</b> <b>int</b> mkfifo (<b>const</b> <b>char</b> *_path, <a href='../S/45.html#L28' title='Defined at 28 in include/sys/types.h.'>mode_t</a> mode); <i><font color='green'>// 创建管道文件。</font></i>
<a name='L59'><b>extern</b> <b>int</b> stat (<b>const</b> <b>char</b> *filename, <b>struct</b> stat *stat_buf); <i><font color='green'>// 取指定文件名的文件状态信息。</font></i>
<a name='L60'><b>extern</b> <a href='../S/45.html#L28' title='Defined at 28 in include/sys/types.h.'>mode_t</a> umask (<a href='../S/45.html#L28' title='Defined at 28 in include/sys/types.h.'>mode_t</a> mask); <i><font color='green'>// 设置属性屏蔽码。</font></i>
<a name='L61'>
<a name='L62'><font color='darkred'>#endif</font>
</pre>
<hr>
<a name='BOTTOM'>
<i><font color='green'>/* [<][>][^][v]<a href='#TOP'>[top]</a>[bottom]<a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</font></i>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?