Common Linux features
The Linux operating system implements a POSIX standard interfaces and API with additional interfaces. Many of them have become common in other filesystems. The ones listed below have been added relatively recently and are considered interesting for users:
- birth/origin inode time
a timestamp associated with an inode of when it was created, cannot be changed and requires the statx syscall to be read
an extended version of the stat syscall that provides extensible interface to read more information that are not available in original stat
- fallocate modes
the fallocate syscall allows to manipulate file extents
keep size (FALLOC_FL_KEEP_SIZE)
hole punching (FALLOC_FL_PUNCH_HOLE)
zero range (FALLOC_FL_ZERO_RANGE)
an ioctl that enumerates file extents, related tool is filefrag
- filesystem label
another filesystem identification, could be used for mount or for better recognition, can be set or read by an ioctl or by command btrfs filesystem label
mode of open() syscall that creates a file with no associated directory entry, which makes it impossible to be seen by other processes and is thus safe to be used as a temporary file (https://lwn.net/Articles/619146/)
- xattr, acl
extended attributes (xattr) is a list of key=value pairs associated with a file, usually storing additional metadata related to security, access control list in particular (ACL) or properties (btrfs property)
mode of renameat2 syscall that can atomically swap 2 directory entries (files/directories/subvolumes/symlinks) within the same filesystem
File attributes, XFLAGS
The btrfs filesystem supports setting file attributes or flags. Note there are old and new interfaces, with confusing names. The following list should clarify that:
lsattr(1)utilities (the ioctls are FS_IOC_GETFLAGS and FS_IOC_SETFLAGS), due to the ioctl names the attributes are also called flags
xflags: to distinguish from the previous, it’s extended flags, with tunable bits similar to the attributes but extensible and new bits will be added in the future (the ioctls are FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR but they are not related to extended attributes that are also called xattrs), there’s no standard tool to change the bits, there’s support in
xfs_io(8)as command xfs_io -c chattr
append only, new writes are always written at the end of the file
no atime updates
compress data, all data written after this attribute is set will be compressed. Please note that compression is also affected by the mount options or the parent directory attributes.
When set on a directory, all newly created files will inherit this attribute. This attribute cannot be set with ‘m’ at the same time.
no copy-on-write, file data modifications are done in-place
When set on a directory, all newly created files will inherit this attribute.
Due to implementation limitations, this flag can be set/unset only on empty files.
no dump, makes sense with 3rd party tools like
dump(8), on BTRFS the attribute can be set/unset but no other special handling is done
synchronous directory updates, for more details search
open(2)for O_SYNC and O_DSYNC
immutable, no file data and metadata changes allowed even to the root user as long as this attribute is set (obviously the exception is unsetting the attribute)
no compression, permanently turn off compression on the given file. Any compression mount options will not affect this file. (
chattrsupport added in 1.46.2)
When set on a directory, all newly created files will inherit this attribute. This attribute cannot be set with c at the same time.
synchronous updates, for more details search
open(2)for O_SYNC and O_DSYNC
No other attributes are supported. For the complete list please refer to the
chattr(1) manual page.
There’s an overlap of letters assigned to the bits with the attributes, this list
refers to what
immutable, same as the attribute
append only, same as the attribute
synchronous updates, same as the attribute S
no atime updates, same as the attribute
no dump, same as the attribute