#ifndef _SYS_STAT_H_
#define _SYS_STAT_H_
#include <sys/featuretest.h>
#include <sys/types.h>
#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
defined(_NETBSD_SOURCE)
#include <sys/time.h>
#endif
struct stat {
dev_t st_dev;
mode_t st_mode;
ino_t st_ino;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
defined(_NETBSD_SOURCE)
struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
struct timespec st_birthtim;
#else
time_t st_atime;
long st_atimensec;
time_t st_mtime;
long st_mtimensec;
time_t st_ctime;
long st_ctimensec;
time_t st_birthtime;
long st_birthtimensec;
#endif
off_t st_size;
blkcnt_t st_blocks;
blksize_t st_blksize;
uint32_t st_flags;
uint32_t st_gen;
uint32_t st_spare[2];
};
#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
defined(_NETBSD_SOURCE)
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
#define st_birthtime st_birthtim.tv_sec
#endif
#if defined(_NETBSD_SOURCE)
#define st_atimespec st_atim
#define st_atimensec st_atim.tv_nsec
#define st_mtimespec st_mtim
#define st_mtimensec st_mtim.tv_nsec
#define st_ctimespec st_ctim
#define st_ctimensec st_ctim.tv_nsec
#define st_birthtimespec st_birthtim
#define st_birthtimensec st_birthtimespec.tv_nsec
#endif
#define S_ISUID 0004000
#define S_ISGID 0002000
#if defined(_NETBSD_SOURCE)
#define S_ISTXT 0001000
#endif
#define S_IRWXU 0000700
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
#if defined(_NETBSD_SOURCE)
#define S_IREAD S_IRUSR
#define S_IWRITE S_IWUSR
#define S_IEXEC S_IXUSR
#endif
#define S_IRWXG 0000070
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IXGRP 0000010
#define S_IRWXO 0000007
#define S_IROTH 0000004
#define S_IWOTH 0000002
#define S_IXOTH 0000001
#define _S_IFMT 0170000
#define _S_IFIFO 0010000
#define _S_IFCHR 0020000
#define _S_IFDIR 0040000
#define _S_IFBLK 0060000
#define _S_IFREG 0100000
#define _S_IFLNK 0120000
#define _S_ISVTX 0001000
#define _S_IFSOCK 0140000
#define _S_IFWHT 0160000
#define _S_ARCH1 0200000
#define _S_ARCH2 0400000
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
#define S_IFMT _S_IFMT
#define S_IFIFO _S_IFIFO
#define S_IFCHR _S_IFCHR
#define S_IFDIR _S_IFDIR
#define S_IFBLK _S_IFBLK
#define S_IFREG _S_IFREG
#define S_IFLNK _S_IFLNK
#define S_ISVTX _S_ISVTX
#endif
#if ((_XOPEN_SOURCE - 0) >= 600) || defined(_NETBSD_SOURCE)
#define S_IFSOCK _S_IFSOCK
#endif
#if defined(_NETBSD_SOURCE)
#define S_IFWHT _S_IFWHT
#define S_ARCH1 _S_ARCH1
#define S_ARCH2 _S_ARCH2
#endif
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
#define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
#if ((_POSIX_C_SOURCE - 0) >= 200112L) || defined(_XOPEN_SOURCE) || \
defined(_NETBSD_SOURCE)
#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
#endif
#if ((_POSIX_C_SOURCE - 0) >= 200112L) || ((_XOPEN_SOURCE - 0) >= 600) || \
defined(_NETBSD_SOURCE)
#define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK)
#endif
#if defined(_NETBSD_SOURCE)
#define S_ISWHT(m) (((m) & _S_IFMT) == _S_IFWHT)
#endif
#if defined(_NETBSD_SOURCE)
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
#define S_BLKSIZE 512
#define UF_SETTABLE 0x0000ffff
#define UF_NODUMP 0x00000001
#define UF_IMMUTABLE 0x00000002
#define UF_APPEND 0x00000004
#define UF_OPAQUE 0x00000008
#define SF_SETTABLE 0xffff0000
#define SF_ARCHIVED 0x00010000
#define SF_IMMUTABLE 0x00020000
#define SF_APPEND 0x00040000
#define SF_SNAPSHOT 0x00200000
#define SF_LOG 0x00400000
#define SF_SNAPINVAL 0x00800000
#ifdef _KERNEL
#define OPAQUE (UF_OPAQUE)
#define APPEND (UF_APPEND | SF_APPEND)
#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
#endif
#endif
#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
defined(_NETBSD_SOURCE)
#define UTIME_NOW ((1 << 30) - 1)
#define UTIME_OMIT ((1 << 30) - 2)
#endif
#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <sys/cdefs.h>
__BEGIN_DECLS
int chmod(const char *, mode_t);
int mkdir(const char *, mode_t);
int mkfifo(const char *, mode_t);
#ifndef __LIBC12_SOURCE__
int stat(const char *, struct stat *) __RENAME(__stat50);
int fstat(int, struct stat *) __RENAME(__fstat50);
#endif
mode_t umask(mode_t);
#if (_POSIX_C_SOURCE - 0) >= 200112L || defined(_XOPEN_SOURCE) || \
defined(_NETBSD_SOURCE)
#ifndef __LIBC12_SOURCE__
int lstat(const char *, struct stat *) __RENAME(__lstat50);
#endif
#endif
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
int fchmod(int, mode_t);
#ifndef __LIBC12_SOURCE__
int mknod(const char *, mode_t, dev_t) __RENAME(__mknod50);
#endif
#endif
#if defined(_NETBSD_SOURCE)
int chflags(const char *, unsigned long);
int fchflags(int, unsigned long);
int lchflags(const char *, unsigned long);
int lchmod(const char *, mode_t);
#endif
#ifndef __LIBC12_SOURCE__
#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
defined(_NETBSD_SOURCE)
int fchmodat(int, const char *, mode_t, int);
int fstatat(int, const char *, struct stat *, int);
int mkdirat(int, const char *, mode_t);
int mkfifoat(int, const char *, mode_t);
int mknodat(int, const char *, mode_t, dev_t);
int utimensat(int, const char *, const struct timespec [2], int);
#endif
#ifdef _NETBSD_SOURCE
int utimens(const char *, const struct timespec [2]);
int lutimens(const char *, const struct timespec [2]);
#endif
#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
defined(_NETBSD_SOURCE)
int futimens(int, const struct timespec [2]);
#endif
#endif
__END_DECLS
#endif
#endif