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>
11 #include <linux/sizes.h>
12 #include <linux/align.h>
15 struct btrfs_ioctl_send_args
;
17 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
18 /* Conditional support for the upcoming protocol version. */
19 #ifdef CONFIG_BTRFS_EXPERIMENTAL
20 #define BTRFS_SEND_STREAM_VERSION 3
22 #define BTRFS_SEND_STREAM_VERSION 2
26 * In send stream v1, no command is larger than 64K. In send stream v2, no
27 * limit should be assumed, the buffer size is set to be a header with
28 * compressed extent size.
30 #define BTRFS_SEND_BUF_SIZE_V1 SZ_64K
31 #define BTRFS_SEND_BUF_SIZE_V2 ALIGN(SZ_16K + BTRFS_MAX_COMPRESSED, PAGE_SIZE)
44 struct btrfs_stream_header
{
45 char magic
[sizeof(BTRFS_SEND_STREAM_MAGIC
)];
47 } __attribute__ ((__packed__
));
49 struct btrfs_cmd_header
{
50 /* len excluding the header */
53 /* crc including the header with zero crc field */
55 } __attribute__ ((__packed__
));
57 struct btrfs_tlv_header
{
59 /* len excluding the header */
61 } __attribute__ ((__packed__
));
65 BTRFS_SEND_C_UNSPEC
= 0,
68 BTRFS_SEND_C_SUBVOL
= 1,
69 BTRFS_SEND_C_SNAPSHOT
= 2,
71 BTRFS_SEND_C_MKFILE
= 3,
72 BTRFS_SEND_C_MKDIR
= 4,
73 BTRFS_SEND_C_MKNOD
= 5,
74 BTRFS_SEND_C_MKFIFO
= 6,
75 BTRFS_SEND_C_MKSOCK
= 7,
76 BTRFS_SEND_C_SYMLINK
= 8,
78 BTRFS_SEND_C_RENAME
= 9,
79 BTRFS_SEND_C_LINK
= 10,
80 BTRFS_SEND_C_UNLINK
= 11,
81 BTRFS_SEND_C_RMDIR
= 12,
83 BTRFS_SEND_C_SET_XATTR
= 13,
84 BTRFS_SEND_C_REMOVE_XATTR
= 14,
86 BTRFS_SEND_C_WRITE
= 15,
87 BTRFS_SEND_C_CLONE
= 16,
89 BTRFS_SEND_C_TRUNCATE
= 17,
90 BTRFS_SEND_C_CHMOD
= 18,
91 BTRFS_SEND_C_CHOWN
= 19,
92 BTRFS_SEND_C_UTIMES
= 20,
94 BTRFS_SEND_C_END
= 21,
95 BTRFS_SEND_C_UPDATE_EXTENT
= 22,
96 BTRFS_SEND_C_MAX_V1
= 22,
99 BTRFS_SEND_C_FALLOCATE
= 23,
100 BTRFS_SEND_C_FILEATTR
= 24,
101 BTRFS_SEND_C_ENCODED_WRITE
= 25,
102 BTRFS_SEND_C_MAX_V2
= 25,
105 BTRFS_SEND_C_ENABLE_VERITY
= 26,
106 BTRFS_SEND_C_MAX_V3
= 26,
108 BTRFS_SEND_C_MAX
= 26,
111 /* attributes in send stream */
113 BTRFS_SEND_A_UNSPEC
= 0,
116 BTRFS_SEND_A_UUID
= 1,
117 BTRFS_SEND_A_CTRANSID
= 2,
119 BTRFS_SEND_A_INO
= 3,
120 BTRFS_SEND_A_SIZE
= 4,
121 BTRFS_SEND_A_MODE
= 5,
122 BTRFS_SEND_A_UID
= 6,
123 BTRFS_SEND_A_GID
= 7,
124 BTRFS_SEND_A_RDEV
= 8,
125 BTRFS_SEND_A_CTIME
= 9,
126 BTRFS_SEND_A_MTIME
= 10,
127 BTRFS_SEND_A_ATIME
= 11,
128 BTRFS_SEND_A_OTIME
= 12,
130 BTRFS_SEND_A_XATTR_NAME
= 13,
131 BTRFS_SEND_A_XATTR_DATA
= 14,
133 BTRFS_SEND_A_PATH
= 15,
134 BTRFS_SEND_A_PATH_TO
= 16,
135 BTRFS_SEND_A_PATH_LINK
= 17,
137 BTRFS_SEND_A_FILE_OFFSET
= 18,
139 * As of send stream v2, this attribute is special: it must be the last
140 * attribute in a command, its header contains only the type, and its
141 * length is implicitly the remaining length of the command.
143 BTRFS_SEND_A_DATA
= 19,
145 BTRFS_SEND_A_CLONE_UUID
= 20,
146 BTRFS_SEND_A_CLONE_CTRANSID
= 21,
147 BTRFS_SEND_A_CLONE_PATH
= 22,
148 BTRFS_SEND_A_CLONE_OFFSET
= 23,
149 BTRFS_SEND_A_CLONE_LEN
= 24,
151 BTRFS_SEND_A_MAX_V1
= 24,
154 BTRFS_SEND_A_FALLOCATE_MODE
= 25,
157 * File attributes from the FS_*_FL namespace (i_flags, xflags),
158 * translated to BTRFS_INODE_* bits (BTRFS_INODE_FLAG_MASK) and stored
159 * in btrfs_inode_item::flags (represented by btrfs_inode::flags and
160 * btrfs_inode::ro_flags).
162 BTRFS_SEND_A_FILEATTR
= 26,
164 BTRFS_SEND_A_UNENCODED_FILE_LEN
= 27,
165 BTRFS_SEND_A_UNENCODED_LEN
= 28,
166 BTRFS_SEND_A_UNENCODED_OFFSET
= 29,
168 * COMPRESSION and ENCRYPTION default to NONE (0) if omitted from
169 * BTRFS_SEND_C_ENCODED_WRITE.
171 BTRFS_SEND_A_COMPRESSION
= 30,
172 BTRFS_SEND_A_ENCRYPTION
= 31,
173 BTRFS_SEND_A_MAX_V2
= 31,
176 BTRFS_SEND_A_VERITY_ALGORITHM
= 32,
177 BTRFS_SEND_A_VERITY_BLOCK_SIZE
= 33,
178 BTRFS_SEND_A_VERITY_SALT_DATA
= 34,
179 BTRFS_SEND_A_VERITY_SIG_DATA
= 35,
180 BTRFS_SEND_A_MAX_V3
= 35,
182 __BTRFS_SEND_A_MAX
= 35,
185 long btrfs_ioctl_send(struct btrfs_inode
*inode
, const struct btrfs_ioctl_send_args
*arg
);