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
82#if __STDC_VERSION__ >= 201112L
89#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) && !defined(CONFIG_PICOLIBC)
94#define _TIMESPEC_DECLARED
95#define __timespec_defined
99#if !defined(_UID_T_DECLARED) && !defined(__uid_t_defined)
100typedef unsigned short uid_t;
101#define _UID_T_DECLARED
102#define __uid_t_defined
105#if !(defined(_STAT_DECLARED) || defined(__stat_defined)) || defined(__DOXYGEN__)
114#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
121#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
126#define _STAT_DECLARED
127#define __stat_defined
130#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
132#define S_IFMT ZVFS_MODE_IFMT
134#define S_IFBLK ZVFS_MODE_IFBLK
136#define S_IFCHR ZVFS_MODE_IFCHR
138#define S_IFIFO ZVFS_MODE_IFIFO
140#define S_IFREG ZVFS_MODE_IFREG
142#define S_IFDIR ZVFS_MODE_IFDIR
144#define S_IFLNK ZVFS_MODE_IFLNK
146#define S_IFSOCK ZVFS_MODE_IFSOCK
148#define S_IFSHM ZVFS_MODE_IFSHM
152#define S_IRWXU ZVFS_S_IRWXU
154#define S_IRUSR ZVFS_S_IRUSR
156#define S_IWUSR ZVFS_S_IWUSR
158#define S_IXUSR ZVFS_S_IXUSR
160#define S_IRWXG ZVFS_S_IRWXG
162#define S_IRGRP ZVFS_S_IRGRP
164#define S_IWGRP ZVFS_S_IWGRP
166#define S_IXGRP ZVFS_S_IXGRP
168#define S_IRWXO ZVFS_S_IRWXO
170#define S_IROTH ZVFS_S_IROTH
172#define S_IWOTH ZVFS_S_IWOTH
174#define S_IXOTH ZVFS_S_IXOTH
176#define S_ISUID ZVFS_S_ISUID
178#define S_ISGID ZVFS_S_ISGID
179#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
181#define S_ISVTX ZVFS_S_ISVTX
189#define S_ISBLK(m) (((m) & ZVFS_MODE_IFMT) == ZVFS_MODE_IFBLK)
191#define S_ISCHR(m) (((m) & ZVFS_MODE_IFMT) == ZVFS_MODE_IFCHR)
193#define S_ISDIR(m) (((m) & ZVFS_MODE_IFMT) == ZVFS_MODE_IFDIR)
195#define S_ISFIFO(m) (((m) & ZVFS_MODE_IFMT) == ZVFS_MODE_IFIFO)
197#define S_ISREG(m) (((m) & ZVFS_MODE_IFMT) == ZVFS_MODE_IFREG)
199#define S_ISLNK(m) (((m) & ZVFS_MODE_IFMT) == ZVFS_MODE_IFLNK)
201#define S_ISSOCK(m) (((m) & ZVFS_MODE_IFMT) == ZVFS_MODE_IFSOCK)
204#define S_TYPEISMQ(buf) (0)
206#define S_TYPEISSEM(buf) (0)
208#define S_TYPEISSHM(st) (((st)->st_mode & ZVFS_MODE_IFMT) == ZVFS_MODE_IFSHM)
210#if defined(_POSIX_TYPED_MEMORY_OBJECTS) || defined(__DOXYGEN__)
212#define S_TYPEISTMO(buf) (0)
229int fstatat(
int fd,
const char *ZRESTRICT path,
struct stat *ZRESTRICT buf,
int flag);
233int lstat(
const char *ZRESTRICT path,
struct stat *ZRESTRICT buf);
242#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
248TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_SHADOW);
250int stat(
const char *ZRESTRICT path,
struct stat *ZRESTRICT buf);
251TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_SHADOW);
int mode_t
File permission bits 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.
blksize_t st_blksize
Preferred I/O block size.
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).
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>)