History

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.

Miklos Szeredi committed 6 years ago

Commit 581701b1 parent 44a3b874 files · +21 −4Browse files

Unified · Split

4 files
  1. fs/stat.c +0 −1
  2. include/uapi/linux/stat.h +10 −1
  3. samples/vfs/test-statx.c +1 −1
  4. tools/include/uapi/linux/stat.h +10 −1
fs/stat.c+0−1
@@ -70,7 +70,6 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, · 69 unmodified lines
70 70
71 memset(stat, 0, sizeof(*stat));71 memset(stat, 0, sizeof(*stat));
72 stat->result_mask |= STATX_BASIC_STATS;72 stat->result_mask |= STATX_BASIC_STATS;
73 request_mask &= STATX_ALL;
74 query_flags &= KSTAT_QUERY_FLAGS;73 query_flags &= KSTAT_QUERY_FLAGS;
75 74
76 /* allow the fs to override these if it really wants to */75 /* allow the fs to override these if it really wants to */
include/uapi/linux/stat.h+10−1
@@ -148,9 +148,18 @@ struct statx { · 147 unmodified lines
148#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */148#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
149#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */149#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
150#define STATX_BTIME 0x00000800U /* Want/got stx_btime */150#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
151#define STATX_ALL 0x00000fffU /* All currently supported flags */151
152#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */152#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
153 153
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
154/*163/*
155 * Attributes to be found in stx_attributes and masked in stx_attributes_mask.164 * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
156 *165 *
samples/vfs/test-statx.c+1−1
@@ -216,7 +216,7 @@ int main(int argc, char **argv) · 215 unmodified lines
216 struct statx stx;216 struct statx stx;
217 int ret, raw = 0, atflag = AT_SYMLINK_NOFOLLOW;217 int ret, raw = 0, atflag = AT_SYMLINK_NOFOLLOW;
218 218
219 unsigned int mask = STATX_ALL;219 unsigned int mask = STATX_BASIC_STATS | STATX_BTIME;
220 220
221 for (argv++; *argv; argv++) {221 for (argv++; *argv; argv++) {
222 if (strcmp(*argv, "-F") == 0) {222 if (strcmp(*argv, "-F") == 0) {
tools/include/uapi/linux/stat.h+10−1
@@ -148,9 +148,18 @@ struct statx { · 147 unmodified lines
148#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */148#define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
149#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */149#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
150#define STATX_BTIME 0x00000800U /* Want/got stx_btime */150#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
151#define STATX_ALL 0x00000fffU /* All currently supported flags */151
152#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */152#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
153 153
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
154/*163/*
155 * Attributes to be found in stx_attributes and masked in stx_attributes_mask.164 * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
156 *165 *

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t