Common Linux features Linux 常见功能 

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:
Linux 操作系统实现了带有额外接口的 POSIX 标准接口和 API。其中许多已经在其他文件系统中变得常见。下面列出的一些接口是相对较新添加的,被认为对用户很有趣:

birth/origin inode time 创建/起源 inode 时间

a timestamp associated with an inode of when it was created, cannot be changed and requires the statx syscall to be read
与 inode 关联的时间戳,表示 inode 创建的时间,无法更改,需要使用 statx 系统调用才能读取

statx

an extended version of the stat syscall that provides extensible interface to read more information that are not available in original stat
一个扩展版本的 stat 系统调用,提供了可扩展的接口,用于读取原始 stat 中不可用的更多信息

fallocate modes fallocate 模式

the fallocate syscall allows to manipulate file extents
fallocate 系统调用允许操作文件范围

Supported modes: 支持的模式:

  • keep size (FALLOC_FL_KEEP_SIZE)
    保持大小(FALLOC_FL_KEEP_SIZE)

  • hole punching (FALLOC_FL_PUNCH_HOLE)
    孔洞打孔(FALLOC_FL_PUNCH_HOLE)

  • zero range (FALLOC_FL_ZERO_RANGE)
    零范围(FALLOC_FL_ZERO_RANGE)

FIEMAP

an ioctl that enumerates file extents, related tool is filefrag
一个列举文件范围的 ioctl,相关工具是 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
另一个文件系统标识,可用于挂载或更好地识别,可以通过 ioctl 或命令 btrfs filesystem label 进行设置或读取

O_TMPFILE

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/)
open() 系统调用的模式,创建一个没有关联目录条目的文件,这使得其他进程无法看到它,因此可以安全地用作临时文件(https://lwn.net/Articles/619146/)

xattr, acl 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(8))
扩展属性(xattr)是与文件关联的键值对列表,通常存储与安全性、访问控制列表(ACL)或属性(btrfs-property(8))相关的附加元数据

cross-rename 交叉重命名

mode of renameat2 syscall that can atomically swap 2 directory entries (files/directories/subvolumes/symlinks) within the same filesystem
renameat2 系统调用的一种模式,可以在同一文件系统内原子地交换 2 个目录条目(文件/目录/子卷/符号链接)

File attributes, XFLAGS
文件属性,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:
btrfs 文件系统支持设置文件属性或标志。请注意,存在旧接口和新接口,名称可能会令人困惑。以下列表应该澄清这一点:

  • attributes: chattr(1) or lsattr(1) utilities (the ioctls are FS_IOC_GETFLAGS and FS_IOC_SETFLAGS), due to the ioctl names the attributes are also called flags
    属性:chattr(1)或 lsattr(1)实用程序(ioctl 为 FS_IOC_GETFLAGS 和 FS_IOC_SETFLAGS),由于 ioctl 的名称,这些属性也被称为标志

  • 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
    xflags:用于与之前的区分,它是扩展标志,具有可调整的位,类似于属性,但是可扩展的,并且将来会添加新的位(ioctl 是 FS_IOC_FSGETXATTR 和 FS_IOC_FSSETXATTR,但它们与也称为 xattrs 的扩展属性无关),没有标准工具来更改位,xfs_io(8) 中有支持,命令为 xfs_io -c chattr

Attributes 属性

a

append only, new writes are always written at the end of the file
仅追加,新写入始终写入文件末尾

A

no atime updates 不更新访问时间

c

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.
当在目录上设置时,所有新创建的文件将继承此属性。此属性不能与‘m’同时设置。

C

no copy-on-write, file data modifications are done in-place
不进行写时复制,文件数据修改直接在原地进行

When set on a directory, all newly created files will inherit this attribute.
当设置在目录上时,所有新创建的文件都将继承此属性。

Note 注意

Due to implementation limitations, this flag can be set/unset only on empty files.
由于实现限制,此标志只能在空文件上设置/取消设置。

d

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
不转储,与 dump(8) 等第三方工具一起使用时是有意义的,在 BTRFS 上,属性可以设置/取消,但不进行其他特殊处理

D

synchronous directory updates, for more details search open(2) for O_SYNC and O_DSYNC
同步目录更新,有关更多详细信息,请搜索 open(2) 查找 O_SYNC 和 O_DSYNC

i

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)
不可变,即使对于 root 用户,只要设置了此属性,也不允许对文件数据和元数据进行更改(显然例外是取消属性)

m

no compression, permanently turn off compression on the given file. Any compression mount options will not affect this file. (chattr(1) support added in 1.46.2)
不压缩,在给定文件上永久关闭压缩。任何压缩挂载选项都不会影响此文件。(在 1.46.2 中添加了 chattr(1)支持)

When set on a directory, all newly created files will inherit this attribute. This attribute cannot be set with c at the same time.
当设置在目录上时,所有新创建的文件将继承此属性。此属性不能与 c 同时设置。

S

synchronous updates, for more details search open(2) for O_SYNC and O_DSYNC
同步更新,更多细节请搜索 open(2)中的 O_SYNC 和 O_DSYNC。

No other attributes are supported. For the complete list please refer to the chattr(1) manual page.
不支持其他属性。有关完整列表,请参阅 chattr(1) 手册页。

XFLAGS

There’s an overlap of letters assigned to the bits with the attributes, this list refers to what xfs_io(8) provides:
位与属性具有重叠的字母分配,此列表指的是 xfs_io(8) 提供的内容:

i

immutable, same as the attribute
不可变,与属性相同

a

append only, same as the attribute
仅追加,与属性相同

s

synchronous updates, same as the attribute S
同步更新,与属性 S 相同

A

no atime updates, same as the attribute
不更新访问时间,与属性相同

d

no dump, same as the attribute
不转储,与属性相同