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

📄 syscalls_13.html

📁 Linux系统调用
💻 HTML
字号:
<!-- This HTML file has been created by texi2html 1.29
     from syscalls.texi on 4 June 1994 -->

<TITLE>Syscall specifications of Linux - fstat</TITLE>
<P>Go to the <A HREF="syscalls_12.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_12.html">previous</A>, <A HREF="syscalls_14.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_14.html">next</A> section.<P>
<H2><A NAME="SEC13" HREF="syscalls_toc.html#SEC13" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_toc.html#SEC13">fstat, stat and lstat</A></H2>
<P>
<H3>SYNOPSIS</H3>
<P>
<CODE>int fstat(int <VAR>fd</VAR>, struct stat *<VAR>buf</VAR>);</CODE>
<P>
<CODE>int stat(char *<VAR>path</VAR>, struct stat *<VAR>buf</VAR>);</CODE>
<P>
<CODE>int lstat(char *<VAR>path</VAR>, struct stat *<VAR>buf</VAR>);</CODE>
<P>
<H3>PARAMETERS</H3>
<P>
<VAR>fd</VAR>: [in] the file descriptor we want to get the information from.
<P>
<VAR>path</VAR>: [in] the file path we want to get the information from.
<P>
<VAR>buf</VAR>: [out] points to the buffer that will contain the information.
<P>
<H3>DESCRIPTION</H3>
<P>
Those calls return a <CODE>stat</CODE> structure in <VAR>buf</VAR> with the
following format:
<P>
<PRE>
struct stat {
        dev_t           st_dev;       /* device */
        unsigned short  __pad1;       /* padding */
        ino_t           st_ino;       /* inode
        umode_t         st_mode;      /* access mode */
        nlink_t         st_nlink;     /* number of hard links */
        uid_t           st_uid;       /* uid */
        gid_t           st_gid;       /* gid */
        dev_t           st_rdev;      /* device type */
        unsigned short  __pad2;       /* padding */
        off_t           st_size;      /* size (in bytes) */
        unsigned long   st_blksize;   /* block size */
        unsigned long   st_blocks;    /* number of allocated blocks */
        time_t          st_atime;     /* last access time */
        unsigned long   __unused1;    /* unused */
        time_t          st_mtime;     /* last modification time */
        unsigned long   __unused2;    /* unused */
        time_t          st_ctime;     /* last change time */
        unsigned long   __unused3;    /* unused */
        unsigned long   __unused4;    /* unused */
        unsigned long   __unused5;    /* unused */
};
</PRE>
<P>
The change time is for modifications to the inode, whereas the
modification time is for modifications to the content of the file.
<P>
<CODE>fstat</CODE> gets the information from a file descriptor. <CODE>stat</CODE> and
<CODE>lstat</CODE> get the information from a file path. However, <CODE>lstat</CODE>
used on a link will give get the information from the link itself
instead of the file pointed by the link.
<P>
<STRONG>Note</STRONG>: the kernel contains a older stats functions. However, it
would seem they are no longer used. (Maybe only by very old binaries.)
<P>
<H3>RETURN VALUE</H3>
<P>
On success zero is returned. On error, -1 is returned and <CODE>errno</CODE> is
set to one of the following values:
<P>
for <CODE>stat</CODE> or <CODE>lstat</CODE>:
<P>
<UL>
<LI><CODE>EFAULT</CODE>, <CODE>ENAMETOOLONG</CODE>, <CODE>ENOMEM</CODE>, <CODE>ENOENT</CODE>,
<CODE>ENOTDIR</CODE>, <CODE>EACCESS</CODE>.
</UL>
<P>
for <CODE>fstat</CODE>:
<P>
<UL>
<LI><CODE>EBADFS</CODE>, <CODE>EFAULT</CODE>
</UL>
<P>
<P>Go to the <A HREF="syscalls_12.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_12.html">previous</A>, <A HREF="syscalls_14.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_14.html">next</A> section.<P>

⌨️ 快捷键说明

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