]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - io/statx.h
xfs_scrub_all: simplify cleanup of run_killable
[thirdparty/xfsprogs-dev.git] / io / statx.h
CommitLineData
959ef981
DC
1// SPDX-License-Identifier: GPL-2.0
2
12caa872
ES
3#ifndef XFS_IO_STATX_H
4#define XFS_IO_STATX_H
5
6#include <unistd.h>
7#include <sys/syscall.h>
8
b61fdaec
ES
9#ifndef AT_EMPTY_PATH
10#define AT_EMPTY_PATH 0x1000
11#endif
12
12caa872
ES
13#ifndef AT_STATX_SYNC_TYPE
14#define AT_STATX_SYNC_TYPE 0x6000 /* Type of synchronisation required from statx() */
15#define AT_STATX_SYNC_AS_STAT 0x0000 /* - Do whatever stat() does */
16#define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */
17#define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */
18#endif
19
20#ifndef AT_NO_AUTOMOUNT
21#define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */
22#endif
23
24#ifndef __NR_statx
4a7aa05a 25# if defined(__i386__) || defined(__powerpc__)
12caa872 26# define __NR_statx 383
12caa872 27# elif defined (__x86_64__)
dc6b7f74
ES
28# if defined (__ILP32__)
29# define __NR_statx (__X32_SYSCALL_BIT + 332)
30# else
31# define __NR_statx 332
32# endif
12caa872
ES
33# endif
34#endif
35
868d0cce
ES
36
37#ifndef STATX_TYPE
38/* Pick up kernel definitions if glibc didn't already provide them */
39#include <linux/stat.h>
40#endif
41
12caa872 42#ifndef STATX_TYPE
868d0cce 43/* Local definitions if glibc & kernel headers didn't already provide them */
12caa872
ES
44
45/*
46 * Timestamp structure for the timestamps in struct statx.
47 *
48 * tv_sec holds the number of seconds before (negative) or after (positive)
49 * 00:00:00 1st January 1970 UTC.
50 *
51 * tv_nsec holds a number of nanoseconds before (0..-999,999,999 if tv_sec is
52 * negative) or after (0..999,999,999 if tv_sec is positive) the tv_sec time.
53 *
54 * Note that if both tv_sec and tv_nsec are non-zero, then the two values must
55 * either be both positive or both negative.
56 *
57 * __reserved is held in case we need a yet finer resolution.
58 */
59struct statx_timestamp {
60 __s64 tv_sec;
61 __s32 tv_nsec;
62 __s32 __reserved;
63};
64
65/*
66 * Structures for the extended file attribute retrieval system call
67 * (statx()).
68 *
69 * The caller passes a mask of what they're specifically interested in as a
70 * parameter to statx(). What statx() actually got will be indicated in
71 * st_mask upon return.
72 *
73 * For each bit in the mask argument:
74 *
75 * - if the datum is not supported:
76 *
77 * - the bit will be cleared, and
78 *
79 * - the datum will be set to an appropriate fabricated value if one is
80 * available (eg. CIFS can take a default uid and gid), otherwise
81 *
82 * - the field will be cleared;
83 *
84 * - otherwise, if explicitly requested:
85 *
86 * - the datum will be synchronised to the server if AT_STATX_FORCE_SYNC is
87 * set or if the datum is considered out of date, and
88 *
89 * - the field will be filled in and the bit will be set;
90 *
91 * - otherwise, if not requested, but available in approximate form without any
92 * effort, it will be filled in anyway, and the bit will be set upon return
93 * (it might not be up to date, however, and no attempt will be made to
94 * synchronise the internal state first);
95 *
96 * - otherwise the field and the bit will be cleared before returning.
97 *
98 * Items in STATX_BASIC_STATS may be marked unavailable on return, but they
99 * will have values installed for compatibility purposes so that stat() and
100 * co. can be emulated in userspace.
101 */
102struct statx {
103 /* 0x00 */
104 __u32 stx_mask; /* What results were written [uncond] */
105 __u32 stx_blksize; /* Preferred general I/O size [uncond] */
106 __u64 stx_attributes; /* Flags conveying information about the file [uncond] */
107 /* 0x10 */
108 __u32 stx_nlink; /* Number of hard links */
109 __u32 stx_uid; /* User ID of owner */
110 __u32 stx_gid; /* Group ID of owner */
111 __u16 stx_mode; /* File mode */
112 __u16 __spare0[1];
113 /* 0x20 */
114 __u64 stx_ino; /* Inode number */
115 __u64 stx_size; /* File size */
116 __u64 stx_blocks; /* Number of 512-byte blocks allocated */
ec5002a8 117 __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
12caa872
ES
118 /* 0x40 */
119 struct statx_timestamp stx_atime; /* Last access time */
120 struct statx_timestamp stx_btime; /* File creation time */
121 struct statx_timestamp stx_ctime; /* Last attribute change time */
122 struct statx_timestamp stx_mtime; /* Last data modification time */
123 /* 0x80 */
124 __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
125 __u32 stx_rdev_minor;
126 __u32 stx_dev_major; /* ID of device containing file [uncond] */
127 __u32 stx_dev_minor;
128 /* 0x90 */
129 __u64 __spare2[14]; /* Spare space for future expansion */
130 /* 0x100 */
131};
132
133/*
134 * Flags to be stx_mask
135 *
136 * Query request/result mask for statx() and struct statx::stx_mask.
137 *
138 * These bits should be set in the mask argument of statx() to request
139 * particular items when calling statx().
140 */
141#define STATX_TYPE 0x00000001U /* Want/got stx_mode & S_IFMT */
142#define STATX_MODE 0x00000002U /* Want/got stx_mode & ~S_IFMT */
143#define STATX_NLINK 0x00000004U /* Want/got stx_nlink */
144#define STATX_UID 0x00000008U /* Want/got stx_uid */
145#define STATX_GID 0x00000010U /* Want/got stx_gid */
146#define STATX_ATIME 0x00000020U /* Want/got stx_atime */
147#define STATX_MTIME 0x00000040U /* Want/got stx_mtime */
148#define STATX_CTIME 0x00000080U /* Want/got stx_ctime */
149#define STATX_INO 0x00000100U /* Want/got stx_ino */
150#define STATX_SIZE 0x00000200U /* Want/got stx_size */
151#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
152#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
153#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
154#define STATX_ALL 0x00000fffU /* All currently supported flags */
155#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
156
157/*
158 * Attributes to be found in stx_attributes
159 *
160 * These give information about the features or the state of a file that might
161 * be of use to ordinary userspace programs such as GUIs or ls rather than
162 * specialised tools.
163 *
164 * Note that the flags marked [I] correspond to generic FS_IOC_FLAGS
165 * semantically. Where possible, the numerical value is picked to correspond
166 * also.
167 */
168#define STATX_ATTR_COMPRESSED 0x00000004 /* [I] File is compressed by the fs */
169#define STATX_ATTR_IMMUTABLE 0x00000010 /* [I] File is marked immutable */
170#define STATX_ATTR_APPEND 0x00000020 /* [I] File is append-only */
171#define STATX_ATTR_NODUMP 0x00000040 /* [I] File is not to be dumped */
172#define STATX_ATTR_ENCRYPTED 0x00000800 /* [I] File requires key to decrypt in fs */
173
174#define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */
175
176#endif /* STATX_TYPE */
177#endif /* XFS_IO_STATX_H */