1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2012 Alexander Block. All rights reserved.
4 * Copyright (C) 2012 STRATO. All rights reserved.
10 #include <linux/types.h>
12 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
13 #define BTRFS_SEND_STREAM_VERSION 2
16 * In send stream v1, no command is larger than 64K. In send stream v2, no limit
19 #define BTRFS_SEND_BUF_SIZE_V1 SZ_64K
22 struct btrfs_ioctl_send_args;
35 struct btrfs_stream_header {
36 char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
38 } __attribute__ ((__packed__));
40 struct btrfs_cmd_header {
41 /* len excluding the header */
44 /* crc including the header with zero crc field */
46 } __attribute__ ((__packed__));
48 struct btrfs_tlv_header {
50 /* len excluding the header */
52 } __attribute__ ((__packed__));
56 BTRFS_SEND_C_UNSPEC = 0,
59 BTRFS_SEND_C_SUBVOL = 1,
60 BTRFS_SEND_C_SNAPSHOT = 2,
62 BTRFS_SEND_C_MKFILE = 3,
63 BTRFS_SEND_C_MKDIR = 4,
64 BTRFS_SEND_C_MKNOD = 5,
65 BTRFS_SEND_C_MKFIFO = 6,
66 BTRFS_SEND_C_MKSOCK = 7,
67 BTRFS_SEND_C_SYMLINK = 8,
69 BTRFS_SEND_C_RENAME = 9,
70 BTRFS_SEND_C_LINK = 10,
71 BTRFS_SEND_C_UNLINK = 11,
72 BTRFS_SEND_C_RMDIR = 12,
74 BTRFS_SEND_C_SET_XATTR = 13,
75 BTRFS_SEND_C_REMOVE_XATTR = 14,
77 BTRFS_SEND_C_WRITE = 15,
78 BTRFS_SEND_C_CLONE = 16,
80 BTRFS_SEND_C_TRUNCATE = 17,
81 BTRFS_SEND_C_CHMOD = 18,
82 BTRFS_SEND_C_CHOWN = 19,
83 BTRFS_SEND_C_UTIMES = 20,
85 BTRFS_SEND_C_END = 21,
86 BTRFS_SEND_C_UPDATE_EXTENT = 22,
87 BTRFS_SEND_C_MAX_V1 = 22,
90 BTRFS_SEND_C_FALLOCATE = 23,
91 BTRFS_SEND_C_FILEATTR = 24,
92 BTRFS_SEND_C_ENCODED_WRITE = 25,
93 BTRFS_SEND_C_MAX_V2 = 25,
96 BTRFS_SEND_C_MAX = 25,
99 /* attributes in send stream */
101 BTRFS_SEND_A_UNSPEC = 0,
104 BTRFS_SEND_A_UUID = 1,
105 BTRFS_SEND_A_CTRANSID = 2,
107 BTRFS_SEND_A_INO = 3,
108 BTRFS_SEND_A_SIZE = 4,
109 BTRFS_SEND_A_MODE = 5,
110 BTRFS_SEND_A_UID = 6,
111 BTRFS_SEND_A_GID = 7,
112 BTRFS_SEND_A_RDEV = 8,
113 BTRFS_SEND_A_CTIME = 9,
114 BTRFS_SEND_A_MTIME = 10,
115 BTRFS_SEND_A_ATIME = 11,
116 BTRFS_SEND_A_OTIME = 12,
118 BTRFS_SEND_A_XATTR_NAME = 13,
119 BTRFS_SEND_A_XATTR_DATA = 14,
121 BTRFS_SEND_A_PATH = 15,
122 BTRFS_SEND_A_PATH_TO = 16,
123 BTRFS_SEND_A_PATH_LINK = 17,
125 BTRFS_SEND_A_FILE_OFFSET = 18,
127 * As of send stream v2, this attribute is special: it must be the last
128 * attribute in a command, its header contains only the type, and its
129 * length is implicitly the remaining length of the command.
131 BTRFS_SEND_A_DATA = 19,
133 BTRFS_SEND_A_CLONE_UUID = 20,
134 BTRFS_SEND_A_CLONE_CTRANSID = 21,
135 BTRFS_SEND_A_CLONE_PATH = 22,
136 BTRFS_SEND_A_CLONE_OFFSET = 23,
137 BTRFS_SEND_A_CLONE_LEN = 24,
139 BTRFS_SEND_A_MAX_V1 = 24,
142 BTRFS_SEND_A_FALLOCATE_MODE = 25,
145 * File attributes from the FS_*_FL namespace (i_flags, xflags),
146 * translated to BTRFS_INODE_* bits (BTRFS_INODE_FLAG_MASK) and stored
147 * in btrfs_inode_item::flags (represented by btrfs_inode::flags and
148 * btrfs_inode::ro_flags).
150 BTRFS_SEND_A_FILEATTR = 26,
152 BTRFS_SEND_A_UNENCODED_FILE_LEN = 27,
153 BTRFS_SEND_A_UNENCODED_LEN = 28,
154 BTRFS_SEND_A_UNENCODED_OFFSET = 29,
156 * COMPRESSION and ENCRYPTION default to NONE (0) if omitted from
157 * BTRFS_SEND_C_ENCODED_WRITE.
159 BTRFS_SEND_A_COMPRESSION = 30,
160 BTRFS_SEND_A_ENCRYPTION = 31,
161 BTRFS_SEND_A_MAX_V2 = 31,
164 BTRFS_SEND_A_MAX = 31,
167 long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg);