Commit 3209f68b authored by David Howells's avatar David Howells Committed by Al Viro

statx: Include a mask for stx_attributes in struct statx

Include a mask in struct stat to indicate which bits of stx_attributes the
filesystem actually supports.

This would also be useful if we add another system call that allows you to
do a 'bulk attribute set' and pass in a statx struct with the masks
appropriately set to say what you want to set.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 47071aee
...@@ -5413,6 +5413,12 @@ int ext4_getattr(const struct path *path, struct kstat *stat, ...@@ -5413,6 +5413,12 @@ int ext4_getattr(const struct path *path, struct kstat *stat,
if (flags & EXT4_NODUMP_FL) if (flags & EXT4_NODUMP_FL)
stat->attributes |= STATX_ATTR_NODUMP; stat->attributes |= STATX_ATTR_NODUMP;
stat->attributes_mask |= (STATX_ATTR_APPEND |
STATX_ATTR_COMPRESSED |
STATX_ATTR_ENCRYPTED |
STATX_ATTR_IMMUTABLE |
STATX_ATTR_NODUMP);
generic_fillattr(inode, stat); generic_fillattr(inode, stat);
return 0; return 0;
} }
......
...@@ -527,6 +527,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) ...@@ -527,6 +527,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer)
tmp.stx_ino = stat->ino; tmp.stx_ino = stat->ino;
tmp.stx_size = stat->size; tmp.stx_size = stat->size;
tmp.stx_blocks = stat->blocks; tmp.stx_blocks = stat->blocks;
tmp.stx_attributes_mask = stat->attributes_mask;
tmp.stx_atime.tv_sec = stat->atime.tv_sec; tmp.stx_atime.tv_sec = stat->atime.tv_sec;
tmp.stx_atime.tv_nsec = stat->atime.tv_nsec; tmp.stx_atime.tv_nsec = stat->atime.tv_nsec;
tmp.stx_btime.tv_sec = stat->btime.tv_sec; tmp.stx_btime.tv_sec = stat->btime.tv_sec;
......
...@@ -26,6 +26,7 @@ struct kstat { ...@@ -26,6 +26,7 @@ struct kstat {
unsigned int nlink; unsigned int nlink;
uint32_t blksize; /* Preferred I/O size */ uint32_t blksize; /* Preferred I/O size */
u64 attributes; u64 attributes;
u64 attributes_mask;
#define KSTAT_ATTR_FS_IOC_FLAGS \ #define KSTAT_ATTR_FS_IOC_FLAGS \
(STATX_ATTR_COMPRESSED | \ (STATX_ATTR_COMPRESSED | \
STATX_ATTR_IMMUTABLE | \ STATX_ATTR_IMMUTABLE | \
......
...@@ -114,7 +114,7 @@ struct statx { ...@@ -114,7 +114,7 @@ struct statx {
__u64 stx_ino; /* Inode number */ __u64 stx_ino; /* Inode number */
__u64 stx_size; /* File size */ __u64 stx_size; /* File size */
__u64 stx_blocks; /* Number of 512-byte blocks allocated */ __u64 stx_blocks; /* Number of 512-byte blocks allocated */
__u64 __spare1[1]; __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
/* 0x40 */ /* 0x40 */
struct statx_timestamp stx_atime; /* Last access time */ struct statx_timestamp stx_atime; /* Last access time */
struct statx_timestamp stx_btime; /* File creation time */ struct statx_timestamp stx_btime; /* File creation time */
...@@ -155,7 +155,7 @@ struct statx { ...@@ -155,7 +155,7 @@ struct statx {
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
/* /*
* Attributes to be found in stx_attributes * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
* *
* These give information about the features or the state of a file that might * These give information about the features or the state of a file that might
* be of use to ordinary userspace programs such as GUIs or ls rather than * be of use to ordinary userspace programs such as GUIs or ls rather than
......
...@@ -141,8 +141,8 @@ static void dump_statx(struct statx *stx) ...@@ -141,8 +141,8 @@ static void dump_statx(struct statx *stx)
if (stx->stx_mask & STATX_BTIME) if (stx->stx_mask & STATX_BTIME)
print_time(" Birth: ", &stx->stx_btime); print_time(" Birth: ", &stx->stx_btime);
if (stx->stx_attributes) { if (stx->stx_attributes_mask) {
unsigned char bits; unsigned char bits, mbits;
int loop, byte; int loop, byte;
static char attr_representation[64 + 1] = static char attr_representation[64 + 1] =
...@@ -160,14 +160,18 @@ static void dump_statx(struct statx *stx) ...@@ -160,14 +160,18 @@ static void dump_statx(struct statx *stx)
printf("Attributes: %016llx (", stx->stx_attributes); printf("Attributes: %016llx (", stx->stx_attributes);
for (byte = 64 - 8; byte >= 0; byte -= 8) { for (byte = 64 - 8; byte >= 0; byte -= 8) {
bits = stx->stx_attributes >> byte; bits = stx->stx_attributes >> byte;
mbits = stx->stx_attributes_mask >> byte;
for (loop = 7; loop >= 0; loop--) { for (loop = 7; loop >= 0; loop--) {
int bit = byte + loop; int bit = byte + loop;
if (bits & 0x80) if (!(mbits & 0x80))
putchar('.'); /* Not supported */
else if (bits & 0x80)
putchar(attr_representation[63 - bit]); putchar(attr_representation[63 - bit]);
else else
putchar('-'); putchar('-'); /* Not set */
bits <<= 1; bits <<= 1;
mbits <<= 1;
} }
if (byte) if (byte)
putchar(' '); putchar(' ');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment