17#ifndef ZEPHYR_INCLUDE_ZEPHYR_POSIX_SYS_STAT_H_
18#define ZEPHYR_INCLUDE_ZEPHYR_POSIX_SYS_STAT_H_
22#include <zephyr/toolchain.h>
23#include <zephyr/sys/fdtable.h>
29#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__)
32#if !defined(_BLKCNT_T_DECLARED) && !defined(__blkcnt_t_defined)
34#define _BLKCNT_T_DECLARED
35#define __blkcnt_t_defined
38#if !defined(_BLKSIZE_T_DECLARED) && !defined(__blksize_t_defined)
39typedef unsigned long blksize_t;
40#define _BLKSIZE_T_DECLARED
41#define __blksize_t_defined
44#if !defined(_DEV_T_DECLARED) && !defined(__dev_t_defined)
46#define _DEV_T_DECLARED
47#define __dev_t_defined
50#if !defined(_GID_T_DECLARED) && !defined(__gid_t_defined)
51typedef unsigned short gid_t;
52#define _GID_T_DECLARED
53#define __gid_t_defined
56#if !defined(_INO_T_DECLARED) && !defined(__ino_t_defined)
58#define _INO_T_DECLARED
59#define __ino_t_defined
62#if !defined(_MODE_T_DECLARED) && !defined(__mode_t_defined)
64#define _MODE_T_DECLARED
65#define __mode_t_defined
68#if !defined(_NLINK_T_DECLARED) && !defined(__nlink_t_defined)
69typedef unsigned short nlink_t;
70#define _NLINK_T_DECLARED
71#define __nlink_t_defined
74#if !defined(_OFF_T_DECLARED) && !defined(__off_t_defined)
76#define _OFF_T_DECLARED
77#define __off_t_defined
83#if __STDC_VERSION__ >= 201112L
90#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) && !defined(CONFIG_PICOLIBC)
95#define _TIMESPEC_DECLARED
96#define __timespec_defined
100#if !defined(_UID_T_DECLARED) && !defined(__uid_t_defined)
101typedef unsigned short uid_t;
102#define _UID_T_DECLARED
103#define __uid_t_defined
106#if !(defined(_STAT_DECLARED) || defined(__stat_defined)) || defined(__DOXYGEN__)
115#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
122#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
127#define _STAT_DECLARED
128#define __stat_defined
132#define S_IFMT ZVFS_MODE_IFMT
134#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
136#define S_IFBLK ZVFS_MODE_IFBLK
138#define S_IFCHR ZVFS_MODE_IFCHR
140#define S_IFIFO ZVFS_MODE_IFIFO
142#define S_IFREG ZVFS_MODE_IFREG
144#define S_IFDIR ZVFS_MODE_IFDIR
146#define S_IFLNK ZVFS_MODE_IFLNK
148#define S_IFSOCK ZVFS_MODE_IFSOCK
150#define S_IFSHM ZVFS_MODE_IFSHM
154#define S_IRWXU ZVFS_S_IRWXU
156#define S_IRUSR ZVFS_S_IRUSR
158#define S_IWUSR ZVFS_S_IWUSR
160#define S_IXUSR ZVFS_S_IXUSR
162#define S_IRWXG ZVFS_S_IRWXG
164#define S_IRGRP ZVFS_S_IRGRP
166#define S_IWGRP ZVFS_S_IWGRP
168#define S_IXGRP ZVFS_S_IXGRP
170#define S_IRWXO ZVFS_S_IRWXO
172#define S_IROTH ZVFS_S_IROTH
174#define S_IWOTH ZVFS_S_IWOTH
176#define S_IXOTH ZVFS_S_IXOTH
178#define S_ISUID ZVFS_S_ISUID
180#define S_ISGID ZVFS_S_ISGID
181#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
183#define S_ISVTX ZVFS_S_ISVTX
187#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
188#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
190#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
192#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
194#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
196#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
198#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
200#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
203#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
205#define S_TYPEISMQ(buf) (0)
207#define S_TYPEISSEM(buf) (0)
209#define S_TYPEISSHM(st) (((st)->st_mode & S_IFMT) == S_IFSHM)
212#if defined(_POSIX_TYPED_MEMORY_OBJECTS) || defined(__DOXYGEN__)
214#define S_TYPEISTMO(buf) (0)
231int fstatat(
int fd,
const char *ZRESTRICT path,
struct stat *ZRESTRICT buf,
int flag);
235int lstat(
const char *ZRESTRICT path,
struct stat *ZRESTRICT buf);
244#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
250TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_SHADOW);
252int stat(
const char *ZRESTRICT path,
struct stat *ZRESTRICT buf);
253TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_SHADOW);
int mode_t
File permission bits type.
long off_t
File offset type.
int utimensat(int fd, const char *path, const struct timespec times[2], int flag)
Set file access and modification times relative to a directory descriptor.
mode_t umask(mode_t cmask)
Set the file mode creation mask.
int mkdir(const char *path, mode_t mode)
Create a directory.
int mkfifoat(int fd, const char *path, mode_t mode)
Create a FIFO special file relative to a directory descriptor.
int fchmod(int fildes, mode_t mode)
Change the mode of an open file.
int lstat(const char *ZRESTRICT path, struct stat *ZRESTRICT buf)
Get status of a file (does not follow symbolic links).
int futimens(int fildes, const struct timespec times[2])
Set file access and modification times of an open file (nanosecond resolution).
int chmod(const char *path, mode_t mode)
Change the mode of a file.
int fstat(int fildes, struct stat *buf)
Get status of an open file.
int mkdirat(int fd, const char *path, mode_t mode)
Create a directory relative to a directory descriptor.
int mkfifo(const char *path, mode_t mode)
Create a FIFO special file.
int fstatat(int fd, const char *ZRESTRICT path, struct stat *ZRESTRICT buf, int flag)
Get status of a file relative to a directory descriptor.
int fchmodat(int fd, const char *path, mode_t mode, int flag)
Change the mode of a file relative to a directory descriptor.
clock_t times(struct tms *buf)
Get the process and child process times.
int mknodat(int fd, const char *path, mode_t mode, dev_t dev)
Create a special or regular file relative to a directory descriptor (XSI).
int mknod(const char *path, mode_t mode, dev_t dev)
Create a special or regular file (XSI extension).
File status information returned by stat(), fstat(), and lstat().
off_t st_size
File size in bytes (regular files).
nlink_t st_nlink
Number of hard links.
blkcnt_t st_blocks
Number of 512-byte blocks allocated.
uid_t st_uid
User ID of the file owner.
mode_t st_mode
File type and permission bits (S_IF* and S_I* constants).
blkcnt_t st_blksize
Preferred I/O block size.
struct timespec st_mtim
Time of last data modification.
struct timespec st_atim
Time of last access.
struct timespec st_ctim
Time of last status change.
ino_t st_ino
File serial number (inode).
dev_t st_rdev
Device ID (for character/block special files).
gid_t st_gid
Group ID of the file's group.
dev_t st_dev
Device ID of the device containing the file.
Time value with nanosecond resolution.
long tv_nsec
Nanoseconds [0, 999999999].
POSIX time-of-day types and functions (<sys/time.h>)