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: David Howells <[email protected]>
Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
David Howells 2017-03-31 18:32:17 +01:00 • committed by Al Viro
commit 3209f68b3c
5 changed files with 18 additions and 6 deletions

View file

@ -141,8 +141,8 @@ static void dump_statx(struct statx *stx)
if (stx->stx_mask & STATX_BTIME)
print_time(" Birth: ", &stx->stx_btime);
if (stx->stx_attributes) {
unsigned char bits;
if (stx->stx_attributes_mask) {
unsigned char bits, mbits;
int loop, byte;
static char attr_representation[64 + 1] =
@ -160,14 +160,18 @@ static void dump_statx(struct statx *stx)
printf("Attributes: %016llx (", stx->stx_attributes);
for (byte = 64 - 8; byte >= 0; byte -= 8) {
bits = stx->stx_attributes >> byte;
mbits = stx->stx_attributes_mask >> byte;
for (loop = 7; loop >= 0; loop--) {
int bit = byte + loop;
if (bits & 0x80)
if (!(mbits & 0x80))
putchar('.'); /* Not supported */
else if (bits & 0x80)
putchar(attr_representation[63 - bit]);
else
putchar('-');
putchar('-'); /* Not set */
bits <<= 1;
mbits <<= 1;
}
if (byte)
putchar(' ');