---
name: "stat"
section: "3type"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/stat/3type"
---

# stat(3type)

file status

## NAME

stat - file status

## LIBRARY

Standard C library (*libc*)

## SYNOPSIS

```
#include <sys/stat.h>
```

**struct stat {**     **dev\_t      st\_dev;**      /\* ID of device containing file \*/     **ino\_t      st\_ino;**      /\* Inode number \*/     **mode\_t     st\_mode;**     /\* File type and mode \*/     **nlink\_t    st\_nlink;**    /\* Number of hard links \*/     **uid\_t      st\_uid;**      /\* User ID of owner \*/     **gid\_t      st\_gid;**      /\* Group ID of owner \*/     **dev\_t      st\_rdev;**     /\* Device ID (if special file) \*/     **off\_t      st\_size;**     /\* Total size, in bytes \*/     **blksize\_t  st\_blksize;**  /\* Block size for filesystem I/O \*/     **blkcnt\_t   st\_blocks;**   /\* Number of 512 B blocks allocated \*/\
     /\* Since POSIX.1-2008, this structure supports nanosecond\
        precision for the following timestamp fields.\
        For the details before POSIX.1-2008, see HISTORY.  \*/     **struct timespec  st\_atim;**  /\* Time of last access \*/     **struct timespec  st\_mtim;**  /\* Time of last modification \*/     **struct timespec  st\_ctim;**  /\* Time of last status change \*/ **#define st\_atime  st\_atim.tv\_sec**  /\* Backward compatibility \*/ **#define st\_mtime  st\_mtim.tv\_sec** **#define st\_ctime  st\_ctim.tv\_sec** **};**

Feature Test Macro Requirements for glibc (see [**feature\_test\_macros**(7)](/feature_test_macros/7.md)):

*.st\_atim*, *.st\_mtim*, *.st\_ctim*:

```
    Since glibc 2.12:
        _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
    glibc 2.19 and earlier:
        _BSD_SOURCE || _SVID_SOURCE
```

## DESCRIPTION

Describes information about a file.

The fields are as follows:

- *.st\_dev*

  This field describes the device on which this file resides. (The [**major**(3)](/major/3.md) and [**minor**(3)](/minor/3.md) macros may be useful to decompose the device ID in this field.)

- *.st\_ino*

  This field contains the file's inode number in the filesystem on *.st\_dev*. If [**stat**(2)](/stat/2.md) was called on the mount point, then *.st\_ino* differs from *.d\_ino* returned by [**readdir**(3)](/readdir/3.md) for the corresponding directory entry in the parent directory. In this case, *.st\_ino* is the inode number of the root directory of the mounted filesystem, while *.d\_ino* is the inode number of the mount point in the parent filesystem.

- *.st\_mode*

  This field contains the file type and mode. See [**inode**(7)](/inode/7.md) for further information.

- *.st\_nlink*

  This field contains the number of hard links to the file.

- *.st\_uid*

  This field contains the user ID of the owner of the file.

- *.st\_gid*

  This field contains the ID of the group owner of the file.

- *.st\_rdev*

  This field describes the device that this file (inode) represents.

- *.st\_size*

  This field gives the size of the file (if it is a regular file or a symbolic link) in bytes. The size of a symbolic link is the length of the pathname it contains, without a terminating null byte.

- *.st\_blksize*

  This field gives the "preferred" block size for efficient filesystem I/O.

- *.st\_blocks*

  This field indicates the number of blocks allocated to the file, in 512-byte units. (This may be smaller than *.st\_size*/512 when the file has holes.)

- *.st\_atime*

  This is the time of the last access of file data.

- *.st\_mtime*

  This is the time of last modification of file data.

- *.st\_ctime*

  This is the file's last status change timestamp (time of last change to the inode).

For further information on the above fields, see [**inode**(7)](/inode/7.md).

## STANDARDS

POSIX.1-2024.

## HISTORY

- *stat*

  POSIX.1-1988.

- *.st\_rdev* *.st\_blksize* *.st\_blocks*

  SUSv1, POSIX.1-2001 XSI.

Initially, SUSv1 specified *.st\_blksize* and *.st\_blocks* with type *long*. This was remedied in SUSv2.

Old kernels and old standards did not support nanosecond timestamp fields. Instead, there were three timestamp fields —*.st\_atime*, *.st\_mtime*, and *.st\_ctime*— typed as *time\_t* that recorded timestamps with one-second precision.

Since Linux 2.5.48, the *stat* structure supports nanosecond resolution for the three file timestamp fields. The nanosecond components of each timestamp are available via names of the form *.st\_atim.tv\_nsec*, if suitable test macros are defined. Nanosecond timestamps were standardized in POSIX.1-2008, and, starting with glibc 2.12, glibc exposes the nanosecond component names if **\_POSIX\_C\_SOURCE** is defined with the value 200809L or greater, or **\_XOPEN\_SOURCE** is defined with the value 700 or greater. Up to and including glibc 2.19, the definitions of the nanoseconds components are also defined if **\_BSD\_SOURCE** or **\_SVID\_SOURCE** is defined. If none of the aforementioned macros are defined, then the nanosecond values are exposed with names of the form *.st\_atimensec*.

## NOTES

The following header also provides this type: *\<ftw.h\>*.

## SEE ALSO

[**stat**(2)](/stat/2.md), [**inode**(7)](/inode/7.md)
