]> git.baikalelectronics.ru Git - kernel.git/commitdiff
uapi: deprecate STATX_ALL
authorMiklos Szeredi <mszeredi@redhat.com>
Thu, 14 May 2020 14:44:24 +0000 (16:44 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Thu, 14 May 2020 14:44:24 +0000 (16:44 +0200)
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 <dhowells@redhat.com>
Cc: linux-api@vger.kernel.org
Cc: linux-man@vger.kernel.org
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/stat.c
include/uapi/linux/stat.h
samples/vfs/test-statx.c
tools/include/uapi/linux/stat.h

index 030008796479aa135964995e4fe8a1fad91ede37..a6709e7ba71d406226e4fdfef97dfe229ee8b703 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -70,7 +70,6 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
 
        memset(stat, 0, sizeof(*stat));
        stat->result_mask |= STATX_BASIC_STATS;
-       request_mask &= STATX_ALL;
        query_flags &= KSTAT_QUERY_FLAGS;
 
        /* allow the fs to override these if it really wants to */
index ad80a5c885d598231ccf207ac48d2d908eaf1b85..d1192783139a5dfff66bd0f7d9b9ee52fc717002 100644 (file)
@@ -148,9 +148,18 @@ struct statx {
 #define STATX_BLOCKS           0x00000400U     /* Want/got stx_blocks */
 #define STATX_BASIC_STATS      0x000007ffU     /* The stuff in the normal stat struct */
 #define STATX_BTIME            0x00000800U     /* Want/got stx_btime */
-#define STATX_ALL              0x00000fffU     /* All currently supported flags */
+
 #define STATX__RESERVED                0x80000000U     /* Reserved for future struct statx expansion */
 
+#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              0x00000fffU
+#endif
+
 /*
  * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
  *
index a3d68159fb5105482fdda5819fdf7ee7d0e8ad3f..76c577ea4fd8b602878aab8b961b20bc2f3fe607 100644 (file)
@@ -216,7 +216,7 @@ int main(int argc, char **argv)
        struct statx stx;
        int ret, raw = 0, atflag = AT_SYMLINK_NOFOLLOW;
 
-       unsigned int mask = STATX_ALL;
+       unsigned int mask = STATX_BASIC_STATS | STATX_BTIME;
 
        for (argv++; *argv; argv++) {
                if (strcmp(*argv, "-F") == 0) {
index ad80a5c885d598231ccf207ac48d2d908eaf1b85..d1192783139a5dfff66bd0f7d9b9ee52fc717002 100644 (file)
@@ -148,9 +148,18 @@ struct statx {
 #define STATX_BLOCKS           0x00000400U     /* Want/got stx_blocks */
 #define STATX_BASIC_STATS      0x000007ffU     /* The stuff in the normal stat struct */
 #define STATX_BTIME            0x00000800U     /* Want/got stx_btime */
-#define STATX_ALL              0x00000fffU     /* All currently supported flags */
+
 #define STATX__RESERVED                0x80000000U     /* Reserved for future struct statx expansion */
 
+#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              0x00000fffU
+#endif
+
 /*
  * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
  *