4 * this code is protected by the GNU affero GPLv3
5 * author:Sylvain BERTRAND
9 * for the "old" stat syscall which could be arch specific, should use the
10 * "new" statx which is "arch independant"
12 #include <ulinux/arch/stat.h>
14 #define ULINUX_AT_CWD -100
16 /*----------------------------------------------------------------------------*/
17 #define ULINUX_S_IFMT 00170000
18 #define ULINUX_S_IFSOCK 0140000
19 #define ULINUX_S_IFLNK 0120000
20 #define ULINUX_S_IFREG 0100000
21 #define ULINUX_S_IFBLK 0060000
22 #define ULINUX_S_IFDIR 0040000
23 #define ULINUX_S_IFCHR 0020000
24 #define ULINUX_S_IFIFO 0010000
26 #define ULINUX_S_ISUID 0004000
27 #define ULINUX_S_ISGID 0002000
28 #define ULINUX_S_ISVTX 0001000
30 #define ULINUX_S_IRWXU 00700
31 #define ULINUX_S_IRUSR 00400
32 #define ULINUX_S_IWUSR 00200
33 #define ULINUX_S_IXUSR 00100
35 #define ULINUX_S_IRWXG 00070
36 #define ULINUX_S_IRGRP 00040
37 #define ULINUX_S_IWGRP 00020
38 #define ULINUX_S_IXGRP 00010
40 #define ULINUX_S_IRWXO 00007
41 #define ULINUX_S_IROTH 00004
42 #define ULINUX_S_IWOTH 00002
43 #define ULINUX_S_IXOTH 00001
44 /*----------------------------------------------------------------------------*/
46 #define ULINUX_S_IRWXUGO (ULINUX_S_IRWXU|ULINUX_S_IRWXG|ULINUX_S_IRWXO)
47 #define ULINUX_S_IALLUGO (ULINUX_S_ISUID|ULINUX_S_ISGID|ULINUX_S_ISVTX\
49 #define ULINUX_S_IRUGO (ULINUX_S_IRUSR|ULINUX_S_IRGRP|ULINUX_S_IROTH)
50 #define ULINUX_S_IWUGO (ULINUX_S_IWUSR|ULINUX_S_IWGRP|ULINUX_S_IWOTH)
51 #define ULINUX_S_IXUGO (ULINUX_S_IXUSR|ULINUX_S_IXGRP|ULINUX_S_IXOTH)
53 /*============================================================================*/
54 /* statx syscall to prefer than stat syscall on not too old kernels */
57 * Timestamp structure for the timestamps in struct statx.
59 * tv_sec holds the number of seconds before (negative) or after (positive)
60 * 00:00:00 1st January 1970 UTC.
62 * tv_nsec holds a number of nanoseconds (0..999,999,999) after the tv_sec time.
64 * __reserved is held in case we need a yet finer resolution.
66 struct ulinux_statx_timestamp
{
69 ulinux_s32 __reserved
;
73 * Structures for the extended file attribute retrieval system call
76 * The caller passes a mask of what they're specifically interested in as a
77 * parameter to statx(). What statx() actually got will be indicated in
78 * st_mask upon return.
80 * For each bit in the mask argument:
82 * - if the datum is not supported:
84 * - the bit will be cleared, and
86 * - the datum will be set to an appropriate fabricated value if one is
87 * available (eg. CIFS can take a default uid and gid), otherwise
89 * - the field will be cleared;
91 * - otherwise, if explicitly requested:
93 * - the datum will be synchronised to the server if AT_STATX_FORCE_SYNC is
94 * set or if the datum is considered out of date, and
96 * - the field will be filled in and the bit will be set;
98 * - otherwise, if not requested, but available in approximate form without any
99 * effort, it will be filled in anyway, and the bit will be set upon return
100 * (it might not be up to date, however, and no attempt will be made to
101 * synchronise the internal state first);
103 * - otherwise the field and the bit will be cleared before returning.
105 * Items in STATX_BASIC_STATS may be marked unavailable on return, but they
106 * will have values installed for compatibility purposes so that stat() and
107 * co. can be emulated in userspace.
109 struct ulinux_statx
{
111 ulinux_u32 mask
; /* What results were written [uncond] */
112 ulinux_u32 blksize
; /* Preferred general I/O size [uncond] */
113 ulinux_u64 attributes
; /* Flags conveying information about the file [uncond] */
115 ulinux_u32 nlink
; /* Number of hard links */
116 ulinux_u32 uid
; /* User ID of owner */
117 ulinux_u32 gid
; /* Group ID of owner */
118 ulinux_u16 mode
; /* File mode */
119 ulinux_u16 __spare0
[1];
121 ulinux_u64 ino
; /* Inode number */
122 ulinux_u64 size
; /* File size */
123 ulinux_u64 blocks
; /* Number of 512-byte blocks allocated */
124 ulinux_u64 attributes_mask
; /* Mask to show what's supported in stx_attributes */
126 struct ulinux_statx_timestamp atime
; /* Last access time */
127 struct ulinux_statx_timestamp btime
; /* File creation time */
128 struct ulinux_statx_timestamp ctime
; /* Last attribute change time */
129 struct ulinux_statx_timestamp mtime
; /* Last data modification time */
131 ulinux_u32 rdev_major
; /* Device ID of special file [if bdev/cdev] */
132 ulinux_u32 rdev_minor
;
133 ulinux_u32 dev_major
; /* ID of device containing file [uncond] */
134 ulinux_u32 dev_minor
;
136 ulinux_u64 __spare2
[14]; /* Spare space for future expansion */
141 * Flags to be stx_mask
143 * Query request/result mask for statx() and struct statx::stx_mask.
145 * These bits should be set in the mask argument of statx() to request
146 * particular items when calling statx().
148 #define ULINUX_STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */
149 #define ULINUX_STATX_MODE 0x00000002U /* Want/got stx_mode & ~S_IFMT */
150 #define ULINUX_STATX_NLINK 0x00000004U /* Want/got stx_nlink */
151 #define ULINUX_STATX_UID 0x00000008U /* Want/got stx_uid */
152 #define ULINUX_STATX_GID 0x00000010U /* Want/got stx_gid */
153 #define ULINUX_STATX_ATIME 0x00000020U /* Want/got stx_atime */
154 #define ULINUX_STATX_MTIME 0x00000040U /* Want/got stx_mtime */
155 #define ULINUX_STATX_CTIME 0x00000080U /* Want/got stx_ctime */
156 #define ULINUX_STATX_INO 0x00000100U /* Want/got stx_ino */
157 #define ULINUX_STATX_SIZE 0x00000200U /* Want/got stx_size */
158 #define ULINUX_STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
159 #define ULINUX_STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
160 #define ULINUX_STATX_BTIME 0x00000800U /* Want/got stx_btime */
161 #define ULINUX_STATX_ALL 0x00000fffU /* All currently supported flags */
162 #define ULINUX_STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
165 * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
167 * These give information about the features or the state of a file that might
168 * be of use to ordinary userspace programs such as GUIs or ls rather than
171 * Note that the flags marked [I] correspond to generic FS_IOC_FLAGS
172 * semantically. Where possible, the numerical value is picked to correspond
175 #define ULINUX_STATX_ATTR_COMPRESSED 0x00000004 /* [I] File is compressed by the fs */
176 #define ULINUX_STATX_ATTR_IMMUTABLE 0x00000010 /* [I] File is marked immutable */
177 #define ULINUX_STATX_ATTR_APPEND 0x00000020 /* [I] File is append-only */
178 #define ULINUX_STATX_ATTR_NODUMP 0x00000040 /* [I] File is not to be dumped */
179 #define ULINUX_STATX_ATTR_ENCRYPTED 0x00000800 /* [I] File requires key to decrypt in fs */
181 #define ULINUX_STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */