What is the difference between
ioctl commands? What flags do both return?
In the Linux context,
FS_IOC_FSGETXATTR both retrieve inode flags.
GETFLAGS is the older
ioctl, and comes originally from
ext2 (again, in Linux); it manipulates a 32-bit value and has thus limited expansion capabilities — there aren’t many unused bits available.
FSGETXATTR comes from XFS, and was recently (2016) moved from XFS to the shared VFS layer. It uses a data structure,
struct fsxattr, which allows for more values and more expansion.
Both of these, and the meanings of the data they return, are defined in
GETFLAGS flags are additionally documented in
ioctl_iflags(2). Common values between the two correspond mostly to
GETFLAGS flags which were historically supported by XFS: “append only”, “no atime updates”, “no dump”, “immutable”, and “synchronous updates”.
Note that in both cases support varies from one file system to another, and some flags aren’t actually supported at all.
FS_IOC_GETFLAGS is an interface to access BSD style file flags. It just uses a much worse interface than *BSD, since you need to open the file in order to get access. *BSD has these informations in
struct stat, so if you like to get the related information in /dev/ entries on Linux, you may cause a tape drive to rewind it's medium.
FS_IOC_FSGETXATTRis a similar but apparently incompatible interface from XFS that seems to be supported by ext4 as well since September 2015.
Conclusion: both interfaces are badly designed since they need to open the file in order to get access. The maintainers do not seem to care about their interfaces since they do not inform important users like
star which is able to back up and restore the flags from the