btrfs-ioctl(2)

NAME 名称 

btrfs-ioctl - documentation for the ioctl interface to btrfs
btrfs-ioctl - btrfs ioctl 接口的文档

DESCRIPTION 描述 

The ioctl() system call is a way how to request custom actions performed on a filesystem beyond the standard interfaces (like syscalls). An ioctl is specified by a number and an associated data structure that implement a feature, usually not available in other filesystems. The number of ioctls grows over time and in some cases get promoted to a VFS-level ioctl once other filesystems adopt the functionality. Backward compatibility is maintained and a formerly private ioctl number could become available on the VFS level.
ioctl() 系统调用是一种请求在文件系统上执行自定义操作的方式,超出了标准接口(如系统调用)的范围。ioctl 由一个数字和一个关联的数据结构指定,实现一个通常在其他文件系统中不可用的功能。ioctl 的数量随着时间增长,在某些情况下,一旦其他文件系统采用该功能,它们可能会被提升为 VFS 级别的 ioctl。向后兼容性得到维护,以前私有的 ioctl 可能会在 VFS 级别上变为可用。

DATA STRUCTURES AND DEFINITIONS
数据结构和定义

struct btrfs_ioctl_vol_args {
        __s64 fd;
        char name[BTRFS_PATH_NAME_MAX + 1];
};
#define BTRFS_SUBVOL_RDONLY                  (1ULL << 1)
#define BTRFS_SUBVOL_QGROUP_INHERIT          (1ULL << 2)
#define BTRFS_DEVICE_SPEC_BY_ID              (1ULL << 3)
#define BTRFS_SUBVOL_SPEC_BY_ID              (1ULL << 4)

struct btrfs_ioctl_vol_args_v2 {
        __s64 fd;
        __u64 transid;
        __u64 flags;
        union {
                struct {
                        __u64 size;
                        struct btrfs_qgroup_inherit __user *qgroup_inherit;
                };
                __u64 unused[4];
        };
        union {
                char name[BTRFS_SUBVOL_NAME_MAX + 1];
                __u64 devid;
                __u64 subvolid;
        };
};
struct btrfs_ioctl_get_subvol_info_args {
        /* Id of this subvolume */
        __u64 treeid;

        /* Name of this subvolume, used to get the real name at mount point */
        char name[BTRFS_VOL_NAME_MAX + 1];

        /*
         * Id of the subvolume which contains this subvolume.
         * Zero for top-level subvolume or a deleted subvolume.
         */
        __u64 parent_id;

        /*
         * Inode number of the directory which contains this subvolume.
         * Zero for top-level subvolume or a deleted subvolume
         */
        __u64 dirid;

        /* Latest transaction id of this subvolume */
        __u64 generation;

        /* Flags of this subvolume */
        __u64 flags;

        /* UUID of this subvolume */
        __u8 uuid[BTRFS_UUID_SIZE];

        /*
         * UUID of the subvolume of which this subvolume is a snapshot.
         * All zero for a non-snapshot subvolume.
         */
        __u8 parent_uuid[BTRFS_UUID_SIZE];

        /*
         * UUID of the subvolume from which this subvolume was received.
         * All zero for non-received subvolume.
         */
        __u8 received_uuid[BTRFS_UUID_SIZE];

        /* Transaction id indicating when change/create/send/receive happened */
        __u64 ctransid;
        __u64 otransid;
        __u64 stransid;
        __u64 rtransid;
        /* Time corresponding to c/o/s/rtransid */
        struct btrfs_ioctl_timespec ctime;
        struct btrfs_ioctl_timespec otime;
        struct btrfs_ioctl_timespec stime;
        struct btrfs_ioctl_timespec rtime;

        /* Must be zero */
        __u64 reserved[8];
};
#define BTRFS_QGROUP_INHERIT_SET_LIMITS         (1ULL << 0)

struct btrfs_qgroup_inherit {
        __u64 flags;
        __u64 num_qgroups;
        __u64 num_ref_copies;
        __u64 num_excl_copies;
        struct btrfs_qgroup_limit lim;
        __u64 qgroups[];
};
#define BTRFS_QGROUP_LIMIT_MAX_RFER             (1ULL << 0)
#define BTRFS_QGROUP_LIMIT_MAX_EXCL             (1ULL << 1)
#define BTRFS_QGROUP_LIMIT_RSV_RFER             (1ULL << 2)
#define BTRFS_QGROUP_LIMIT_RSV_EXCL             (1ULL << 3)
#define BTRFS_QGROUP_LIMIT_RFER_CMPR            (1ULL << 4)
#define BTRFS_QGROUP_LIMIT_EXCL_CMPR            (1ULL << 5)

struct btrfs_qgroup_limit {
        __u64 flags;
        __u64 max_rfer;
        __u64 max_excl;
        __u64 rsv_rfer;
        __u64 rsv_excl;
};
/* Request information about checksum type and size */
#define BTRFS_FS_INFO_FLAG_CSUM_INFO                    (1U << 0)
/* Request information about filesystem generation */
#define BTRFS_FS_INFO_FLAG_GENERATION                   (1U << 1)
/* Request information about filesystem metadata UUID */
#define BTRFS_FS_INFO_FLAG_METADATA_UUID                (1U << 2)

struct btrfs_ioctl_fs_info_args {
        __u64 max_id;                           /* out */
        __u64 num_devices;                      /* out */
        __u8 fsid[BTRFS_FSID_SIZE];             /* out */
        __u32 nodesize;                         /* out */
        __u32 sectorsize;                       /* out */
        __u32 clone_alignment;                  /* out */
        /* See BTRFS_FS_INFO_FLAG_* */
        __u16 csum_type;                        /* out */
        __u16 csum_size;                        /* out */
        __u64 flags;                            /* in/out */
        __u64 generation;                       /* out */
        __u8 metadata_uuid[BTRFS_FSID_SIZE];    /* out */
        __u8 reserved[944];                     /* pad to 1k */
};
#define BTRFS_INO_LOOKUP_PATH_MAX               4080

struct btrfs_ioctl_ino_lookup_args {
        __u64 treeid;
        __u64 objectid;
        char name[BTRFS_INO_LOOKUP_PATH_MAX];
};

Constant name 常量名称

Value

BTRFS_UUID_SIZE

16

BTRFS_FSID_SIZE

16

BTRFS_SUBVOL_NAME_MAX

4039

BTRFS_PATH_NAME_MAX

4087

BTRFS_VOL_NAME_MAX

255

BTRFS_LABEL_SIZE

256

BTRFS_FIRST_FREE_OBJECTID

256

OVERVIEW 概述

The ioctls are defined by a number and associated with a data structure that contains further information. All ioctls use file descriptor (fd) as a reference point, it could be the filesystem or a directory inside the filesystem.
ioctls 由一个数字定义,并与包含进一步信息的数据结构相关联。所有 ioctls 都使用文件描述符(fd)作为参考点,它可以是文件系统或文件系统中的目录。

An ioctl can be used in the following schematic way:
一个 ioctl 可以以以下示意方式使用:

struct btrfs_ioctl_args args;

memset(&args, 0, sizeof(args));
args.key = value;
ret = ioctl(fd, BTRFS_IOC_NUMBER, &args);

The ‘fd’ is the entry point to the filesystem and for most ioctls it does not matter which file or directory is that. Where it matters it’s explicitly mentioned. The ‘args’ is the associated data structure for the request. It’s strongly recommended to initialize the whole structure to zeros as this is future-proof when the ioctl gets further extensions. Not doing that could lead to mismatch of old userspace and new kernel versions, or vice versa. The ‘BTRFS_IOC_NUMBER’ is says which operation should be done on the given arguments. Some ioctls take a specific data structure, some of them share a common one, no argument structure ioctls exist too.
“fd” 是文件系统的入口点,对于大多数 ioctls 来说,文件或目录是什么并不重要。在重要的情况下会明确说明。 “args” 是请求的关联数据结构。强烈建议将整个结构初始化为零,因为这样在 ioctl 进一步扩展时是未来兼容的。不这样做可能导致旧用户空间和新内核版本不匹配,反之亦然。 “BTRFS_IOC_NUMBER” 表示应对给定参数执行哪种操作。一些 ioctls 需要特定的数据结构,其中一些共享一个通用的数据结构,也有一些不需要参数结构的 ioctls。

The library libbtrfsutil wraps a few ioctls for convenience. Using raw ioctls is not discouraged but may be cumbersome though it does not need additional library dependency. Backward compatibility is guaranteed and incompatible changes usually lead to a new version of the ioctl. Enhancements of existing ioctls can happen and depend on additional flags to be set. Zeroed unused space is commonly understood as a mechanism to communicate the compatibility between kernel and userspace and thus zeroing is really important. In exceptional cases this is not enough and further flags need to be passed to distinguish between zero as implicit unused initialization and a valid zero value. Such cases are documented.
libbtrfsutil 库封装了一些 ioctl 以方便使用。虽然不鼓励使用原始 ioctl,但可能会很麻烦,尽管它不需要额外的库依赖。向后兼容性得到保证,不兼容的更改通常会导致一个新版本的 ioctl。现有 ioctl 的增强可能会发生,并取决于要设置的附加标志。清零未使用空间通常被理解为内核和用户空间之间通信兼容性的机制,因此清零非常重要。在特殊情况下,这是不够的,需要传递更多的标志来区分零作为隐式未使用初始化和有效零值。这些情况已记录。

File descriptors of regular files are obtained by int fd = open(), directories opened as DIR *dir = opendir() can be converted to the corresponding file descriptor by fd = dirfd(dir).
普通文件的文件描述符通过 int fd = open() 获得,以 DIR *dir = opendir() 打开的目录可以通过 fd = dirfd(dir) 转换为相应的文件描述符。

LIST OF IOCTLS IOCTL 列表 

Name

Description

Data

BTRFS_IOC_SNAP_CREATE

(obsolete) create a snapshot of a subvolume
(已过时)创建子卷的快照

struct btrfs_ioctl_vol_args
结构体 btrfs_ioctl_vol_args

BTRFS_IOC_DEFRAG

BTRFS_IOC_RESIZE

BTRFS_IOC_SCAN_DEV

scan and register a given device path with filesystem module
扫描并向文件系统模块注册给定的设备路径

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构

BTRFS_IOC_SYNC

Sync the filesystem, possibly process queued up work
同步文件系统,可能处理排队的工作

NULL

BTRFS_IOC_CLONE

BTRFS_IOC_ADD_DEV

add a device to the filesystem by path
通过路径向文件系统添加设备

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构

BTRFS_IOC_RM_DEV

delete a device from the filesystem by path
通过路径从文件系统中删除设备

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构

BTRFS_IOC_BALANCE

BTRFS_IOC_CLONE_RANGE

BTRFS_IOC_SUBVOL_CREATE

(obsolete) create a subvolume
(过时) 创建一个子卷

struct btrfs_ioctl_vol_args
结构体 btrfs_ioctl_vol_args

BTRFS_IOC_SNAP_DESTROY

(obsolete) delete a subvolume
(过时) 删除一个子卷

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构

BTRFS_IOC_DEFRAG_RANGE

BTRFS_IOC_TREE_SEARCH

BTRFS_IOC_TREE_SEARCH_V2

BTRFS_IOC_INO_LOOKUP

resolve inode number to path, or lookup containing subvolume id
将 inode 号解析为路径,或查找包含的子卷 id

struct btrfs_ioctl_ino_lookup_args
btrfs_ioctl_ino_lookup_args 结构

BTRFS_IOC_DEFAULT_SUBVOL

set the default subvolume id
设置默认子卷 ID

uint64_t

BTRFS_IOC_SPACE_INFO

BTRFS_IOC_START_SYNC

BTRFS_IOC_WAIT_SYNC

BTRFS_IOC_SNAP_CREATE_V2

create a snapshot of a subvolume
创建子卷的快照

struct btrfs_ioctl_vol_args_v2
结构 btrfs_ioctl_vol_args_v2

BTRFS_IOC_SUBVOL_CREATE_V2

create a subvolume 创建一个子卷

struct btrfs_ioctl_vol_args_v2
结构体 btrfs_ioctl_vol_args_v2

BTRFS_IOC_SUBVOL_GETFLAGS

get flags of a subvolume
获取子卷的标志

uint64_t

BTRFS_IOC_SUBVOL_SETFLAGS

set flags of a subvolume
设置子卷的标志

uint64_t

BTRFS_IOC_SCRUB

BTRFS_IOC_SCRUB_CANCEL

BTRFS_IOC_SCRUB_PROGRESS

BTRFS_IOC_DEV_INFO

BTRFS_IOC_FS_INFO

get information about filesystem (device count, fsid, …)
获取文件系统信息(设备计数,fsid,…)

struct btrfs_ioctl_fs_info_args
结构体 btrfs_ioctl_fs_info_args

BTRFS_IOC_BALANCE_V2

BTRFS_IOC_BALANCE_CTL

BTRFS_IOC_BALANCE_PROGRESS

BTRFS_IOC_INO_PATHS

BTRFS_IOC_LOGICAL_INO

BTRFS_IOC_SET_RECEIVED_SUBVOL

BTRFS_IOC_SEND

BTRFS_IOC_DEVICES_READY

BTRFS_IOC_QUOTA_CTL

BTRFS_IOC_QGROUP_ASSIGN

BTRFS_IOC_QGROUP_CREATE

BTRFS_IOC_QGROUP_LIMIT

BTRFS_IOC_QUOTA_RESCAN

BTRFS_IOC_QUOTA_RESCAN_STATUS

BTRFS_IOC_QUOTA_RESCAN_WAIT

BTRFS_IOC_GET_FSLABEL

read filesystem label 读取文件系统标签

char buffer[BTRFS_LABEL_SIZE]

BTRFS_IOC_SET_FSLABEL

set the filesystem label 设置文件系统标签

char buffer[BTRFS_LABEL_SIZE]
char 缓冲区[BTRFS_LABEL_SIZE]

BTRFS_IOC_GET_DEV_STATS

BTRFS_IOC_DEV_REPLACE

BTRFS_IOC_FILE_EXTENT_SAME

BTRFS_IOC_GET_FEATURES

BTRFS_IOC_SET_FEATURES

BTRFS_IOC_GET_SUPPORTED_FEATURES

BTRFS_IOC_RM_DEV_V2

BTRFS_IOC_LOGICAL_INO_V2

BTRFS_IOC_GET_SUBVOL_INFO

get information about a subvolume
获取有关子卷的信息

struct btrfs_ioctl_get_subvol_info_args
结构 btrfs_ioctl_get_subvol_info_args

BTRFS_IOC_GET_SUBVOL_ROOTREF

BTRFS_IOC_INO_LOOKUP_USER

BTRFS_IOC_SNAP_DESTROY_V2

destroy a (snapshot or regular) subvolume
销毁快照或常规子卷

struct btrfs_ioctl_vol_args_v2
结构 btrfs_ioctl_vol_args_v2

DETAILED DESCRIPTION 详细描述 

BTRFS_IOC_SNAP_CREATE

Note 注意

obsoleted by BTRFS_IOC_SNAP_CREATE_V2
由 BTRFS_IOC_SNAP_CREATE_V2 废弃

(since: 3.0, obsoleted: 4.0) Create a snapshot of a subvolume.
(自:3.0,废弃:4.0) 创建子卷的快照。

Field

Description

ioctl fd

file descriptor of the parent directory of the new subvolume
新子卷的父目录文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构

args.fd

file descriptor of any directory inside the subvolume to snapshot, must be on the same filesystem
任何子卷内部目录的文件描述符,必须在同一文件系统上

args.name

name of the subvolume, although the buffer can be almost 4KiB, the file size is limited by Linux VFS to 255 characters and must not contain a slash (‘/’)
子卷的名称,尽管缓冲区几乎可以达到 4KiB,但文件大小受 Linux VFS 限制为 255 个字符,且不能包含斜杠('/')

BTRFS_IOC_SCAN_DEV BTRFS_IOC_SCAN_DEV

Scan and register a given device in the filesystem module, which can be later used for automatic device and filesystem association at mount time. This operates on the control device, not files from a mounted filesystem. Can be safely called repeatedly with same device path.
扫描并在文件系统模块中注册给定设备,以便在挂载时自动将设备与文件系统关联。这在控制设备上操作,而不是在已挂载的文件系统中的文件上。可以安全地重复使用相同的设备路径调用。

Field

Description

ioctl fd

file descriptor of the control device /dev/btrfs-control
控制设备的文件描述符 /dev/btrfs-control

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构体

args.fd

ignored

args.name

full path of the device
设备的完整路径

BTRFS_IOC_SYNC

Sync the filesystem data as would sync() syscall do, additionally wake up the internal transaction thread that may trigger actions like subvolume cleaning or queued defragmentation.
将文件系统数据同步,就像 sync() 系统调用一样,另外唤醒可能触发操作的内部事务线程,如子卷清理或排队碎片整理。

Field

Description

ioctl fd

file descriptor of any file or directory in the filesystem
文件系统中任何文件或目录的文件描述符

ioctl args ioctl 参数

NULL

BTRFS_IOC_ADD_DEV

Add a given block device to the filesystem. Unlike the command btrfs device add there’s are no safety checks (like existence of another filesystem on the device), device preparataion (like TRIM or zone reset), so use it with care.
将给定的块设备添加到文件系统中。与命令 btrfs device add 不同,此命令没有安全检查(如设备上是否存在另一个文件系统)、设备准备(如 TRIM 或区域重置),因此请谨慎使用。

This is a filesystem-exclusive operation and it will fail if there’s another one already running, with one exception, when there’s a paused balance.
这是一个文件系统专属操作,如果已经有另一个文件系统在运行,则操作将失败,唯一的例外是当存在暂停的平衡操作时。

Required permissions: CAP_SYS_ADMIN
需要的权限:CAP_SYS_ADMIN

Field

Description

ioctl fd ioctl 文件描述符

file descriptor of any file or directory in the filesystem
文件系统中任何文件或目录的文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args
结构体 btrfs_ioctl_vol_args

args.fd

ignored

args.name

full path of the block device to be added
要添加的块设备的完整路径

BTRFS_IOC_RM_DEV

Remove a device from the filesystem specified by it’s path, or cancel a running device deletion by special path cancel.
从由其路径指定的文件系统中删除设备,或通过特殊路径 cancel 取消正在运行的设备删除。

This is a filesystem-exclusive operation and it will fail if there’s another one already running.
这是一个文件系统专属操作,如果已经有另一个操作正在运行,它将失败。

Required permissions: CAP_SYS_ADMIN
需要的权限:CAP_SYS_ADMIN

Field

Description

ioctl fd ioctl 文件描述符

file descriptor of any file or directory in the filesystem
文件系统中任何文件或目录的文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构体

args.fd

ignored

args.name

full path of the block device to be deleted or string “cancel”
要删除的块设备的完整路径或字符串“cancel”

BTRFS_IOC_SUBVOL_CREATE

Note 注意

obsoleted by BTRFS_IOC_SUBVOL_CREATE_V2
被 BTRFS_IOC_SUBVOL_CREATE_V2 废弃

(since: 3.0, obsoleted: 4.0) Create a subvolume.
(自版本 3.0 起,废弃于 4.0) 创建一个子卷。

Field

Description

ioctl fd

file descriptor of the parent directory of the new subvolume
新子卷的父目录文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构

args.fd

ignored

args.name

name of the subvolume, although the buffer can be almost 4KiB, the file size is limited by Linux VFS to 255 characters and must not contain a slash (‘/’)
快照卷的名称,尽管缓冲区几乎可以达到 4KiB,但文件大小受 Linux VFS 限制为 255 个字符,且不能包含斜杠('/')

BTRFS_IOC_SNAP_DESTROY BTRFS_IOC_SNAP_DESTROY

Note 注意

obsoleted by BTRFS_IOC_SNAP_DESTROY_V2
由 BTRFS_IOC_SNAP_DESTROY_V2 废弃

(since: 2.6.33, obsoleted: 5.7) Delete a subvolume.
(自 2.6.33 起,废弃:5.7) 删除子卷。

Field

Description

ioctl fd ioctl 文件描述符

file descriptor of the parent directory of the new subvolume
新子卷的父目录的文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args
btrfs_ioctl_vol_args 结构体

args.fd

ignored

args.name

name of the subvolume, although the buffer can be almost 4KiB, the file size is limited by Linux VFS to 255 characters and must not contain a slash (‘/’)
子卷的名称,尽管缓冲区几乎可以达到 4KiB,但文件大小受 Linux VFS 限制为 255 个字符,且不能包含斜杠('/')

BTRFS_IOC_INO_LOOKUP BTRFS_IOC_INO_LOOKUP

Resolve inode number to a path (requires CAP_SYS_ADMIN), or read a containing subvolume id of the given file (unrestricted, special case). The size of the path name buffer is shorter than PATH_MAX (4096), it’s possible that the path is trimmed due to that. Also implemented by btrfs inspect-internal rootid.
将 inode 号解析为路径(需要 CAP_SYS_ADMIN 权限),或读取给定文件的包含子卷 id(无限制,特殊情况)。路径名缓冲区的大小小于 PATH_MAX(4096),可能会由于此原因而被修剪。也可通过 btrfs inspect-internal rootid 实现。

The general case needs CAP_SYS_ADMIN and can resolve any file to its path. The special case for reading the containing subvolume is not restricted:
通用情况需要 CAP_SYS_ADMIN 并且可以将任何文件解析为其路径。读取包含的子卷的特殊情况没有限制:

struct btrfs_ioctl_ino_lookup_args args;

fd = open("file", ...);
args.treeid = 0;
args.objectid = BTRFS_FIRST_FREE_OBJECTID;
ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
/* args.treeid now contains the subvolume id */

Field

Description

ioctl fd ioctl 文件描述符

file descriptor of the file or directory to lookup the subvolumeid
要查找子卷的文件或目录的文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_ino_lookup_args
结构体 btrfs_ioctl_ino_lookup_args

args.treeid

subvolume id against which the path should be resolved (needs CAP_SYS_ADMIN), or 0 so the subvolume containing fd will be used
应该解析路径的子卷 ID(需要 CAP_SYS_ADMIN),或者为 0,这样将使用包含 fd 的子卷

args.objectid

inode number to lookup, INODE_REF_KEY with that key.objectid, or BTRFS_FIRST_FREE_OBJECTID as special case to read only the tree id and clear the args.name buffer
要查找的 inode 编号,使用该键的 INODE_REF_KEY.objectid,或者作为特殊情况的 BTRFS_FIRST_FREE_OBJECTID,以仅读取树 ID 并清除 args.name 缓冲区

args.name

path relative to the toplevel subvolume, or empty string
相对于顶层子卷的路径,或空字符串

BTRFS_IOC_DEFAULT_SUBVOL

Set the given subvolume id as the default one when mounting the filesystem without subvol=path or subvolid=id options.
将给定的子卷 ID 设置为在没有 subvol=path 或 subvolid=id 选项的情况下挂载文件系统时的默认子卷。

Field

Description

ioctl fd ioctl 文件描述符

file descriptor of the directory inside which to create the new snapshot
用于创建新快照的目录的文件描述符

ioctl args ioctl 参数

numeric value of subvolume to become default (uint64_t)
要成为默认子卷的数值(uint64_t)

BTRFS_IOC_SNAP_CREATE_V2

Create a snapshot of a subvolume.
创建子卷的快照。

Field

Description

ioctl fd ioctl 文件描述符

file descriptor of the directory inside which to create the new snapshot
用于创建新快照的目录内文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args_v2
结构体 btrfs_ioctl_vol_args_v2

args.fd

file descriptor of any directory inside the subvolume to snapshot, must be on the filesystem
任何子卷内部目录的文件描述符,用于快照,必须在文件系统上

args.transid

ignored

args.flags

any subset of BTRFS_SUBVOL_RDONLY to make the new snapshot read-only, or BTRFS_SUBVOL_QGROUP_INHERIT to apply the qgroup_inherit field
任何 BTRFS_SUBVOL_RDONLY 的子集,使新快照为只读,或者 BTRFS_SUBVOL_QGROUP_INHERIT 以应用 qgroup_inherit 字段

args.name

the name, under the ioctl fd, for the new subvolume
新子卷的 ioctl fd 下的名称

BTRFS_IOC_SUBVOL_CREATE_V2
BTRFS_IOC_SUBVOL_CREATE_V2

(since: 3.6) Create a subvolume, qgroup inheritance and limits can be specified.
(自 3.6 版本起) 可以创建子卷,可以指定 qgroup 继承和限制。

Field

Description

ioctl fd ioctl 文件描述符

file descriptor of the parent directory of the new subvolume
新子卷的父目录的文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args_v2
结构体 btrfs_ioctl_vol_args_v2

args.fd

ignored

args.transid

ignored

args.flags

flags to set on the subvolume, BTRFS_SUBVOL_RDONLY for readonly, BTRFS_SUBVOL_QGROUP_INHERIT if the qgroup related fileds should be processed
在子卷上设置的标志, BTRFS_SUBVOL_RDONLY 为只读, BTRFS_SUBVOL_QGROUP_INHERIT 如果应处理与 qgroup 相关的字段

args.size

number of entries in args.qgroup_inherit
args.qgroup_inherit 中的条目数

args.qgroup_inherit

inherit the given qgroups (struct btrfs_qgroup_inherit) and limits (struct btrfs_qgroup_limit)
继承给定的 qgroups(struct btrfs_qgroup_inherit)和限制(struct btrfs_qgroup_limit)

name

name of the subvolume, although the buffer can be almost 4KiB, the file size is limited by Linux VFS to 255 characters and must not contain a slash (‘/’)
子卷的名称,尽管缓冲区几乎可以达到 4KiB,但文件大小受 Linux VFS 限制为 255 个字符,且不能包含斜杠('/')

BTRFS_IOC_SUBVOL_GETFLAGS

Read the flags of a subvolume. The returned flags are either 0 or BTRFS_SUBVOL_RDONLY.
读取子卷的标志。返回的标志要么是 0,要么是 BTRFS_SUBVOL_RDONLY。

Field

Description

ioctl fd

file descriptor of the subvolume to examine
要检查的子卷文件描述符

ioctl args ioctl 参数

uint64_t

BTRFS_IOC_SUBVOL_SETFLAGS

Change the flags of a subvolume.
更改子卷的标志。

Field

Description

ioctl fd 子卷的 ioctl 文件描述符

file descriptor of the subvolume to modify
要修改的子卷的文件描述符

ioctl args ioctl 参数

uint64_t, either 0 or BTRFS_SUBVOL_RDONLY
uint64_t,要么为 0,要么为 BTRFS_SUBVOL_RDONLY

BTRFS_IOC_GET_FSLABEL

Read the label of the filesystem into a given buffer. Alternatively it can be read from /sys/fs/btrfs/FSID/label though it requires to know the FSID of the filesystem.
将文件系统的标签读入给定的缓冲区。或者可以从 /sys/fs/btrfs/FSID/label 读取,尽管需要知道文件系统的 FSID。

Field

Description

ioctl fd ioctl 文件描述符

file descriptor of any file/directory in the filesystem
文件系统中任何文件/目录的文件描述符

ioctl args ioctl 参数

char buffer[BTRFS_LABEL_SIZE]
char 缓冲区[BTRFS_LABEL_SIZE]

BTRFS_IOC_SET_FSLABEL

Set the label of filesystem from given buffer. The maximum length also accounts for terminating NUL character. Alternatively it can be also set by writing to /sys/fs/btrfs/FSID/label though it requires to know the FSID of the filesystem (and an explicit commit before the change is permanent).
从给定的缓冲区设置文件系统的标签。最大长度还包括终止的 NUL 字符。或者也可以通过写入 /sys/fs/btrfs/FSID/label 来设置,尽管这需要知道文件系统的 FSID(在更改永久生效之前需要显式提交)。

Required permissions: CAP_SYS_ADMIN
所需权限:CAP_SYS_ADMIN

Field

Description

ioctl fd

file descriptor of any file/directory in the filesystem
文件系统中任何文件/目录的文件描述符

ioctl args ioctl 参数

char buffer[BTRFS_LABEL_SIZE]
char 缓冲区[BTRFS_LABEL_SIZE]

BTRFS_IOC_FS_INFO

Read internal information about the filesystem. The data can be exchanged both ways and part of the structure could be optionally filled. The reserved bytes can be used to get new kind of information in the future, always depending on the flags set.
读取文件系统的内部信息。数据可以双向交换,结构的一部分可以选择性地填充。保留的字节可以在将来用于获取新类型的信息,始终取决于设置的标志。

Field

Description

ioctl fd

file descriptor of any file/directory in the filesystem
文件系统中任何文件/目录的文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_fs_info_args
结构体 btrfs_ioctl_fs_info_args

BTRFS_IOC_GET_SUBVOL_INFO
获取有关子卷的信息

Get information about a subvolume.
获取有关子卷的信息

Field

Description

ioctl fd

file descriptor of the subvolume to examine
要检查的子卷的文件描述符

ioctl args ioctl 参数

struct btrfs_ioctl_get_subvol_info_args
结构 btrfs_ioctl_get_subvol_info_args

BTRFS_IOC_SNAP_DESTROY_V2

Destroy a subvolume, which may or may not be a snapshot.
销毁一个子卷,可能是快照也可能不是。

Field

Description

ioctl fd

if flags does not include BTRFS_SUBVOL_SPEC_BY_ID, or if executing in a non-root user namespace, file descriptor of the parent directory containing the subvolume to delete; otherwise, file descriptor of any directory on the same filesystem as the subvolume to delete, but not within the same subvolume
如果标志不包括 BTRFS_SUBVOL_SPEC_BY_ID,或者在非根用户命名空间中执行,则为要删除的子卷所在父目录的文件描述符;否则,为要删除的子卷所在同一文件系统上任何目录的文件描述符,但不能在同一子卷内部

ioctl args ioctl 参数

struct btrfs_ioctl_vol_args_v2
结构体 btrfs_ioctl_vol_args_v2

args.fd

ignored

args.transid

ignored

args.flags

0 if the name field identifies the subvolume by name in the specified directory, or BTRFS_SUBVOL_SPEC_BY_ID if the subvolid field specifies the ID of the subvolume
如果名称字段在指定目录中通过名称标识子卷,则为 0,或者如果 subvolid 字段指定子卷的 ID,则为 BTRFS_SUBVOL_SPEC_BY_ID

args.name

only if flags does not contain BTRFS_SUBVOL_SPEC_BY_ID, the name (within the directory identified by fd) of the subvolume to delete
仅当 flags 不包含 BTRFS_SUBVOL_SPEC_BY_ID 时,要删除的子卷的名称(在由 fd 标识的目录中)

args.subvolid

only if flags contains BTRFS_SUBVOL_SPEC_BY_ID, the subvolume ID of the subvolume to delete
仅当 flags 包含 BTRFS_SUBVOL_SPEC_BY_ID 时,要删除的子卷的子卷 ID

AVAILABILITY 可用性 

btrfs is part of btrfs-progs. Please refer to the documentation at https://btrfs.readthedocs.io.
btrfs 是 btrfs-progs 的一部分。请参考 https://btrfs.readthedocs.io 上的文档。

SEE ALSO 参见 

ioctl(2)