Skip to content

Commit 581701b

Browse files
author
Miklos Szeredi
committed
uapi: deprecate STATX_ALL
Constants of the *_ALL type can be actively harmful due to the fact that developers will usually fail to consider the possible effects of future changes to the definition. Deprecate STATX_ALL in the uapi, while no damage has been done yet. We could keep something like this around in the kernel, but there's actually no point, since all filesystems should be explicitly checking flags that they support and not rely on the VFS masking unknown ones out: a flag could be known to the VFS, yet not known to the filesystem. Cc: David Howells <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Miklos Szeredi <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 44a3b87 commit 581701b

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

Diff for: fs/stat.c

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
7070

7171
memset(stat, 0, sizeof(*stat));
7272
stat->result_mask |= STATX_BASIC_STATS;
73-
request_mask &= STATX_ALL;
7473
query_flags &= KSTAT_QUERY_FLAGS;
7574

7675
/* allow the fs to override these if it really wants to */

Diff for: include/uapi/linux/stat.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,18 @@ struct statx {
148148
#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
149149
#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
150150
#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
151-
#define STATX_ALL 0x00000fffU /* All currently supported flags */
151+
152152
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
153153

154+
#ifndef __KERNEL__
155+
/*
156+
* This is deprecated, and shall remain the same value in the future. To avoid
157+
* confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME)
158+
* instead.
159+
*/
160+
#define STATX_ALL 0x00000fffU
161+
#endif
162+
154163
/*
155164
* Attributes to be found in stx_attributes and masked in stx_attributes_mask.
156165
*

Diff for: samples/vfs/test-statx.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int main(int argc, char **argv)
216216
struct statx stx;
217217
int ret, raw = 0, atflag = AT_SYMLINK_NOFOLLOW;
218218

219-
unsigned int mask = STATX_ALL;
219+
unsigned int mask = STATX_BASIC_STATS | STATX_BTIME;
220220

221221
for (argv++; *argv; argv++) {
222222
if (strcmp(*argv, "-F") == 0) {

Diff for: tools/include/uapi/linux/stat.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,18 @@ struct statx {
148148
#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
149149
#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
150150
#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
151-
#define STATX_ALL 0x00000fffU /* All currently supported flags */
151+
152152
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
153153

154+
#ifndef __KERNEL__
155+
/*
156+
* This is deprecated, and shall remain the same value in the future. To avoid
157+
* confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME)
158+
* instead.
159+
*/
160+
#define STATX_ALL 0x00000fffU
161+
#endif
162+
154163
/*
155164
* Attributes to be found in stx_attributes and masked in stx_attributes_mask.
156165
*

0 commit comments

Comments
 (0)