Skip to content

WIP: glocalfile: Remove the concept of the required mask

Simon McVittie requested to merge wip/smcv/statx-no-required-mask into main

This follows on from !1648 (merged), and is currently completely untested. I'm not sure whether we want all of these commits, or just the first one, or what. Thoughts?

/cc @andreldm @pwithnall @sdroege @oholy

  • glocalfile: Remove the concept of the required mask

    It is not actually guaranteed that any of the flags in the returned stx_mask will be set by statx(): for example, if the filesystem has no concept of POSIX user and group IDs (like FAT), the kernel could validly clear the STATX_UID and STATX_GID bits in the returned stx_mask. Linux 5.8 does not appear to do this in practice, even for FAT, but the statx(2) man page suggests that it perhaps should.

    However, what is guaranteed is that for the STATX_BASIC_STATS (those that correspond to what is in the traditional struct stat), even if the bit in stx_mask is cleared, there will be something in the corresponding struct field (in practice the same harmless value that traditional stat() would have placed in the struct stat). Rely on those compatibility values being reasonable, and don't second-guess the kernel.

  • glocalfileoutputstream: Don't rely on compat fields in struct statx

    If the kernel has told us that certain fields in the struct statx are meaningless (a non-representable type, or no meaningful link count, or no meaningful uid, or similar) then we shouldn't try to copy their placeholder values onto the new file.

    (This commit is incomplete.)

  • glocalfile: Only copy meaningful fields from struct statx to GFileInfo

    At least in theory, the Linux kernel can now tell us which fields in struct statx have meaningful values (although in practice it doesn't seem to unset any of the STATX_BASIC_STATS bits except STATX_ATIME, even on FAT filesystems where the uid and gid are not meaningful).

Edited by Simon McVittie

Merge request reports