linux/include/uapi/linux/stat.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _UAPI_LINUX_STAT_H
#define _UAPI_LINUX_STAT_H

#include <linux/types.h>

#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)

#define S_IFMT
#define S_IFSOCK
#define S_IFLNK
#define S_IFREG
#define S_IFBLK
#define S_IFDIR
#define S_IFCHR
#define S_IFIFO
#define S_ISUID
#define S_ISGID
#define S_ISVTX

#define S_ISLNK(m)
#define S_ISREG(m)
#define S_ISDIR(m)
#define S_ISCHR(m)
#define S_ISBLK(m)
#define S_ISFIFO(m)
#define S_ISSOCK(m)

#define S_IRWXU
#define S_IRUSR
#define S_IWUSR
#define S_IXUSR

#define S_IRWXG
#define S_IRGRP
#define S_IWGRP
#define S_IXGRP

#define S_IRWXO
#define S_IROTH
#define S_IWOTH
#define S_IXOTH

#endif

/*
 * Timestamp structure for the timestamps in struct statx.
 *
 * tv_sec holds the number of seconds before (negative) or after (positive)
 * 00:00:00 1st January 1970 UTC.
 *
 * tv_nsec holds a number of nanoseconds (0..999,999,999) after the tv_sec time.
 *
 * __reserved is held in case we need a yet finer resolution.
 */
struct statx_timestamp {};

/*
 * Structures for the extended file attribute retrieval system call
 * (statx()).
 *
 * The caller passes a mask of what they're specifically interested in as a
 * parameter to statx().  What statx() actually got will be indicated in
 * st_mask upon return.
 *
 * For each bit in the mask argument:
 *
 * - if the datum is not supported:
 *
 *   - the bit will be cleared, and
 *
 *   - the datum will be set to an appropriate fabricated value if one is
 *     available (eg. CIFS can take a default uid and gid), otherwise
 *
 *   - the field will be cleared;
 *
 * - otherwise, if explicitly requested:
 *
 *   - the datum will be synchronised to the server if AT_STATX_FORCE_SYNC is
 *     set or if the datum is considered out of date, and
 *
 *   - the field will be filled in and the bit will be set;
 *
 * - otherwise, if not requested, but available in approximate form without any
 *   effort, it will be filled in anyway, and the bit will be set upon return
 *   (it might not be up to date, however, and no attempt will be made to
 *   synchronise the internal state first);
 *
 * - otherwise the field and the bit will be cleared before returning.
 *
 * Items in STATX_BASIC_STATS may be marked unavailable on return, but they
 * will have values installed for compatibility purposes so that stat() and
 * co. can be emulated in userspace.
 */
struct statx {};

/*
 * Flags to be stx_mask
 *
 * Query request/result mask for statx() and struct statx::stx_mask.
 *
 * These bits should be set in the mask argument of statx() to request
 * particular items when calling statx().
 */
#define STATX_TYPE
#define STATX_MODE
#define STATX_NLINK
#define STATX_UID
#define STATX_GID
#define STATX_ATIME
#define STATX_MTIME
#define STATX_CTIME
#define STATX_INO
#define STATX_SIZE
#define STATX_BLOCKS
#define STATX_BASIC_STATS
#define STATX_BTIME
#define STATX_MNT_ID
#define STATX_DIOALIGN
#define STATX_MNT_ID_UNIQUE
#define STATX_SUBVOL
#define STATX_WRITE_ATOMIC

#define STATX__RESERVED

#ifndef __KERNEL__
/*
 * This is deprecated, and shall remain the same value in the future.  To avoid
 * confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME)
 * instead.
 */
#define STATX_ALL
#endif

/*
 * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
 *
 * These give information about the features or the state of a file that might
 * be of use to ordinary userspace programs such as GUIs or ls rather than
 * specialised tools.
 *
 * Note that the flags marked [I] correspond to the FS_IOC_SETFLAGS flags
 * semantically.  Where possible, the numerical value is picked to correspond
 * also.  Note that the DAX attribute indicates that the file is in the CPU
 * direct access state.  It does not correspond to the per-inode flag that
 * some filesystems support.
 *
 */
#define STATX_ATTR_COMPRESSED
#define STATX_ATTR_IMMUTABLE
#define STATX_ATTR_APPEND
#define STATX_ATTR_NODUMP
#define STATX_ATTR_ENCRYPTED
#define STATX_ATTR_AUTOMOUNT
#define STATX_ATTR_MOUNT_ROOT
#define STATX_ATTR_VERITY
#define STATX_ATTR_DAX
#define STATX_ATTR_WRITE_ATOMIC


#endif /* _UAPI_LINUX_STAT_H */