#include <sys/stat.h>
sys/stat.h
structostat
XXX So deprecated, it would make your head spin
The old stat structure. In fact, this is not used by the kernel at all,
and should not be used by user space, and should be removed from this
header file entirely (along with the unused cvtstat() prototype in
vnode_internal.h).
| __uint16_t | st_dev | inode's device |
| ino_t | st_ino | inode's number |
| mode_t | st_mode | inode protection mode |
| nlink_t | st_nlink | number of hard links |
| __uint16_t | st_uid | user ID of the file's owner |
| __uint16_t | st_gid | group ID of the file's group |
| __uint16_t | st_rdev | device type |
| __int32_t | st_size | file size, in bytes |
| struct timespec | st_atimespec | time of last access |
| struct timespec | st_mtimespec | time of last data modification |
| struct timespec | st_ctimespec | time of last file status change |
| __int32_t | st_blksize | optimal blocksize for I/O |
| __int32_t | st_blocks | blocks allocated for file |
| __uint32_t | st_flags | user defined flags for file |
| __uint32_t | st_gen | file generation number |
structstat
| dev_t | st_dev | [XSI] ID of device containing file |
| mode_t | st_mode | [XSI] Mode of file (see below) |
| nlink_t | st_nlink | [XSI] Number of hard links |
| __darwin_ino64_t | st_ino | [XSI] File serial number |
| uid_t | st_uid | [XSI] User ID of the file |
| gid_t | st_gid | [XSI] Group ID of the file |
| dev_t | st_rdev | [XSI] Device ID |
| struct timespec | st_atimespec | |
| struct timespec | st_mtimespec | |
| struct timespec | st_ctimespec | |
| struct timespec | st_birthtimespec | |
| off_t | st_size | [XSI] file size, in bytes |
| blkcnt_t | st_blocks | [XSI] blocks allocated for file |
| blksize_t | st_blksize | [XSI] optimal blocksize for I/O |
| __uint32_t | st_flags | user defined flags for file |
| __uint32_t | st_gen | file generation number |
| __int32_t | st_lspare | RESERVED: DO NOT USE! |
| __int64_t[2] | st_qspare | RESERVED: DO NOT USE! |
macrost_atime
#define st_atime st_atimespec.tv_sec
macrost_mtime
#define st_mtime st_mtimespec.tv_sec
macrost_ctime
#define st_ctime st_ctimespec.tv_sec
macrost_birthtime
#define st_birthtime st_birthtimespec.tv_sec
macroS_ISBLK
[XSI] The following macros shall be provided to test whether a file is
of the specified type. The value m supplied to the macros is the value
of st_mode from a stat structure. The macro shall evaluate to a non-zero
value if the test is true; 0 if the test is false.
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
block special
macroS_TYPEISMQ
[XSI] The implementation may implement message queues, semaphores, or
shared memory objects as distinct file types. The following macros
shall be provided to test whether a file is of the specified type.
The value of the buf argument supplied to the macros is a pointer to
a stat structure. The macro shall evaluate to a non-zero value if
the specified object is implemented as a distinct file type and the
specified file type is contained in the stat structure referenced by
buf. Otherwise, the macro shall evaluate to zero.
NOTE: The current implementation does not do this, although
this may change in future revisions, and co currently only
provides these macros to ensure source compatability with
implementations which do.
#define S_TYPEISMQ(buf) (0)
Test for a message queue
macroS_TYPEISTMO
[TYM] The implementation may implement typed memory objects as distinct
file types, and the following macro shall test whether a file is of the
specified type. The value of the buf argument supplied to the macros is
a pointer to a stat structure. The macro shall evaluate to a non-zero
value if the specified object is implemented as a distinct file type and
the specified file type is contained in the stat structure referenced by
buf. Otherwise, the macro shall evaluate to zero.
NOTE: The current implementation does not do this, although
this may change in future revisions, and co currently only
provides this macro to ensure source compatability with
implementations which do.
#define S_TYPEISTMO(buf) (0)
Test for a typed memory object
macroUF_SETTABLE
Definitions of flags stored in file flags word.
Super-user and owner changeable flags.
#define UF_SETTABLE 0x0000ffff
mask of owner changeable flags
macroUF_TRACKED
UF_TRACKED is used for dealing with document IDs. We no longer issue
notifications for deletes or renames for files which have UF_TRACKED set.
#define UF_TRACKED 0x00000040
macroUF_HIDDEN
Bits 0x0100 through 0x4000 are currently undefined.
#define UF_HIDDEN 0x00008000
hint that this item should not be
macroSF_SUPPORTED
displayed in a GUI
Super-user changeable flags.
#define SF_SUPPORTED 0x009f0000
mask of superuser supported flags
macroSF_DATALESS
Synthetic flags.
These are read-only. We keep them out of SF_SUPPORTED so that
attempts to set them will fail.
#define SF_DATALESS 0x40000000
file is dataless object
macroEF_MAY_SHARE_BLOCKS
Extended flags ("EF") returned by ATTR_CMNEXT_EXT_FLAGS from getattrlist/getattrlistbulk
#define EF_MAY_SHARE_BLOCKS 0x00000001
file may share blocks with another file
macroEF_SHARES_ALL_BLOCKS
#define EF_SHARES_ALL_BLOCKS 0x00000040
file shares all of its blocks with another file
functionchmod
__DARWIN_ALIAS(chmod) int chmod(const char *, mode_t)
[XSI]
man page · June 4, 1993
chmod(2) — change mode of filefunctionfchmod
__DARWIN_ALIAS(fchmod) int fchmod(int, mode_t)
man page · June 4, 1993
fchmod(2) — change mode of filefunctionfstat
__DARWIN_INODE64(fstat) int fstat(int, struct stat *)
man page · May 15, 2008
fstat(2) — get file statusfunctionlstat
__DARWIN_INODE64(lstat) int lstat(const char *, struct stat *)
man page · May 15, 2008
lstat(2) — get file statusfunctionmkdir
int mkdir(const char *, mode_t)
man page · December 11, 1993
mkdir(2) — make a directory filefunctionstat
__DARWIN_INODE64(stat)
int stat(const char *, struct stat *)man page · May 15, 2008
stat(2) — get file statusfunctionmknod
int mknod(const char *, mode_t, dev_t)
man page · June 4, 1993
mknod(2) — make a special file nodefunctionfchmodat
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) int fchmodat(int, const char *, mode_t, int)
man page · June 4, 1993
fchmodat(2) — change mode of filefunctionfstatat
__DARWIN_INODE64(fstatat) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) int fstatat(int, const char *, struct stat *, int)
man page · May 15, 2008
fstatat(2) — get file statusfunctionmkdirat
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) int mkdirat(int, const char *, mode_t)
man page · December 11, 1993
mkdirat(2) — make a directory filefunctionmkfifoat
__API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0), watchos(9.0)) int mkfifoat(int, const char *, mode_t)
man page · June 4, 1993
mkfifoat(2) — make a fifo filefunctionmknodat
__API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0), watchos(9.0)) int mknodat(int, const char *, mode_t, dev_t)
man page · June 4, 1993
mknodat(2) — make a special file nodemacroUTIME_NOW
#define UTIME_NOW -1
macroUTIME_OMIT
#define UTIME_OMIT -2
functionfutimens
__API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)) int futimens(int __fd, const struct timespec __times[2])
man page · January 17, 2016
futimens(2) — set file access and modification timesfunctionutimensat
__API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)) int utimensat(int __fd, const char *__path, const struct timespec __times[2], int __flag)
man page · January 17, 2016
utimensat(2) — set file access and modification timesfunctionchflags
int chflags(const char *, __uint32_t)
man page · June 9, 1993
chflags(2) — set file flagsfunctionfchmodx_np
int fchmodx_np(int, filesec_t)
functionlchflags
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) int lchflags(const char *, __uint32_t)
man page · Feb 6, 2023
lchflags(3) — set file flagsfunctionlchmod
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0) int lchmod(const char *, mode_t)
man page · Oct 31, 2005
lchmod(3) — change mode of filefunctionmkfifox_np
int mkfifox_np(const char *, filesec_t)