#ifndef _SYS_STAT_H
#define _SYS_STAT_H
#include <sys/feature_tests.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#include <sys/time_impl.h>
#else
#include <sys/time_std_impl.h>
#endif
#define _ST_FSTYPSZ 16
#if defined(_KERNEL)
#if defined(_LP64)
struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
blksize_t st_blksize;
blkcnt_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
};
struct stat64 {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
blksize_t st_blksize;
blkcnt_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
};
#else
struct stat {
dev_t st_dev;
long st_pad1[3];
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
long st_pad2[2];
off_t st_size;
long st_pad3;
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
blksize_t st_blksize;
blkcnt_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
long st_pad4[8];
};
struct stat64 {
dev_t st_dev;
long st_pad1[3];
ino64_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
long st_pad2[2];
off64_t st_size;
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
blksize_t st_blksize;
blkcnt64_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
long st_pad4[8];
};
#endif
#else
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname fstat fstat64
#pragma redefine_extname stat stat64
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
defined(_ATFILE_SOURCE)
#pragma redefine_extname fstatat fstatat64
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
#pragma redefine_extname lstat lstat64
#endif
#else
#define fstat fstat64
#define stat stat64
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
defined(_ATFILE_SOURCE)
#define fstatat fstatat64
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
#define lstat lstat64
#endif
#endif
#endif
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname fstat64 fstat
#pragma redefine_extname stat64 stat
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
defined(_ATFILE_SOURCE)
#pragma redefine_extname fstatat64 fstatat
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
#pragma redefine_extname lstat64 lstat
#endif
#else
#define fstat64 fstat
#define stat64 stat
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
defined(_ATFILE_SOURCE)
#define fstatat64 fstatat
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
#define lstat64 lstat
#endif
#endif
#endif
#if defined(_LP64)
struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
#else
_timestruc_t st_atim;
_timestruc_t st_mtim;
_timestruc_t st_ctim;
#endif
blksize_t st_blksize;
blkcnt_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
};
#else
struct stat {
dev_t st_dev;
long st_pad1[3];
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
long st_pad2[2];
off_t st_size;
#if _FILE_OFFSET_BITS != 64
long st_pad3;
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
#else
_timestruc_t st_atim;
_timestruc_t st_mtim;
_timestruc_t st_ctim;
#endif
blksize_t st_blksize;
blkcnt_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
long st_pad4[8];
};
#endif
#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
!defined(__PRAGMA_REDEFINE_EXTNAME))
#if defined(_LP64)
struct stat64 {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
#else
_timestruc_t st_atim;
_timestruc_t st_mtim;
_timestruc_t st_ctim;
#endif
blksize_t st_blksize;
blkcnt_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
};
#else
struct stat64 {
dev_t st_dev;
long st_pad1[3];
ino64_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
long st_pad2[2];
off64_t st_size;
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
#else
_timestruc_t st_atim;
_timestruc_t st_mtim;
_timestruc_t st_ctim;
#endif
blksize_t st_blksize;
blkcnt64_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
long st_pad4[8];
};
#endif
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
#else
#define st_atime st_atim.__tv_sec
#define st_mtime st_mtim.__tv_sec
#define st_ctime st_ctim.__tv_sec
#endif
#endif
#if defined(_SYSCALL32)
struct stat32 {
dev32_t st_dev;
int32_t st_pad1[3];
ino32_t st_ino;
mode32_t st_mode;
nlink32_t st_nlink;
uid32_t st_uid;
gid32_t st_gid;
dev32_t st_rdev;
int32_t st_pad2[2];
off32_t st_size;
int32_t st_pad3;
timestruc32_t st_atim;
timestruc32_t st_mtim;
timestruc32_t st_ctim;
int32_t st_blksize;
blkcnt32_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
int32_t st_pad4[8];
};
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack(4)
#endif
struct stat64_32 {
dev32_t st_dev;
int32_t st_pad1[3];
ino64_t st_ino;
mode32_t st_mode;
nlink32_t st_nlink;
uid32_t st_uid;
gid32_t st_gid;
dev32_t st_rdev;
int32_t st_pad2[2];
off64_t st_size;
timestruc32_t st_atim;
timestruc32_t st_mtim;
timestruc32_t st_ctim;
int32_t st_blksize;
blkcnt64_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
int32_t st_pad4[8];
};
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack()
#endif
#endif
#define S_IFMT 0xF000
#define S_IAMB 0x1FF
#define S_IFIFO 0x1000
#define S_IFCHR 0x2000
#define S_IFDIR 0x4000
#define S_IFNAM 0x5000
#define S_INSEM 0x1
#define S_INSHD 0x2
#define S_IFBLK 0x6000
#define S_IFREG 0x8000
#define S_IFLNK 0xA000
#define S_IFSOCK 0xC000
#define S_IFDOOR 0xD000
#define S_IFPORT 0xE000
#define S_ISUID 0x800
#define S_ISGID 0x400
#define S_ISVTX 0x200
#define S_IREAD 00400
#define S_IWRITE 00200
#define S_IEXEC 00100
#define S_ENFMT S_ISGID
#define S_IRWXU 00700
#define S_IRUSR 00400
#define S_IWUSR 00200
#define S_IXUSR 00100
#define S_IRWXG 00070
#define S_IRGRP 00040
#define S_IWGRP 00020
#define S_IXGRP 00010
#define S_IRWXO 00007
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
#define S_ISFIFO(mode) (((mode)&0xF000) == 0x1000)
#define S_ISCHR(mode) (((mode)&0xF000) == 0x2000)
#define S_ISDIR(mode) (((mode)&0xF000) == 0x4000)
#define S_ISBLK(mode) (((mode)&0xF000) == 0x6000)
#define S_ISREG(mode) (((mode)&0xF000) == 0x8000)
#define S_ISLNK(mode) (((mode)&0xF000) == 0xa000)
#define S_ISSOCK(mode) (((mode)&0xF000) == 0xc000)
#define S_ISDOOR(mode) (((mode)&0xF000) == 0xd000)
#define S_ISPORT(mode) (((mode)&0xF000) == 0xe000)
#define S_TYPEISMQ(_buf) (0)
#define S_TYPEISSEM(_buf) (0)
#define S_TYPEISSHM(_buf) (0)
#if defined(__i386) || (defined(__i386_COMPAT) && defined(_KERNEL))
#define _R3_MKNOD_VER 1
#define _MKNOD_VER 2
#define _R3_STAT_VER 1
#define _STAT_VER 2
#endif
#if defined(__EXTENSIONS__) || \
(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
#define UTIME_NOW -1L
#define UTIME_OMIT -2L
#endif
#if !defined(_KERNEL) || defined(_BOOT)
#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
defined(_XPG4_2) || defined(__EXTENSIONS__)
extern int fchmod(int, mode_t);
#endif
extern int chmod(const char *, mode_t);
extern int mkdir(const char *, mode_t);
extern int mkfifo(const char *, mode_t);
extern mode_t umask(mode_t);
#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
!defined(__PRAGMA_REDEFINE_EXTNAME))
extern int fstat64(int, struct stat64 *);
extern int stat64(const char *_RESTRICT_KYWD, struct stat64 *_RESTRICT_KYWD);
extern int lstat64(const char *_RESTRICT_KYWD, struct stat64 *_RESTRICT_KYWD);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) || \
defined(_ATFILE_SOURCE)
extern int fstatat64(int, const char *, struct stat64 *, int);
#endif
#endif
#if defined(__EXTENSIONS__) || defined(_ATFILE_SOURCE) || \
(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
extern int mkdirat(int, const char *, mode_t);
extern int mkfifoat(int, const char *, mode_t);
extern int mknodat(int, const char *, mode_t, dev_t);
extern int fchmodat(int, const char *, mode_t, int);
extern int futimens(int, const struct timespec[2]);
extern int utimensat(int, const char *, const struct timespec[2], int);
#endif
#include <sys/stat_impl.h>
#endif
#ifdef __cplusplus
}
#endif
#endif