1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2012 Alexander Block. All rights reserved.
4 * Copyright (C) 2012 STRATO. All rights reserved.
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
32 struct btrfs_stream_header {
33 char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
35 } __attribute__ ((__packed__));
37 struct btrfs_cmd_header {
38 /* len excluding the header */
41 /* crc including the header with zero crc field */
43 } __attribute__ ((__packed__));
45 struct btrfs_tlv_header {
47 /* len excluding the header */
49 } __attribute__ ((__packed__));
53 BTRFS_SEND_C_UNSPEC = 0,
56 BTRFS_SEND_C_SUBVOL = 1,
57 BTRFS_SEND_C_SNAPSHOT = 2,
59 BTRFS_SEND_C_MKFILE = 3,
60 BTRFS_SEND_C_MKDIR = 4,
61 BTRFS_SEND_C_MKNOD = 5,
62 BTRFS_SEND_C_MKFIFO = 6,
63 BTRFS_SEND_C_MKSOCK = 7,
64 BTRFS_SEND_C_SYMLINK = 8,
66 BTRFS_SEND_C_RENAME = 9,
67 BTRFS_SEND_C_LINK = 10,
68 BTRFS_SEND_C_UNLINK = 11,
69 BTRFS_SEND_C_RMDIR = 12,
71 BTRFS_SEND_C_SET_XATTR = 13,
72 BTRFS_SEND_C_REMOVE_XATTR = 14,
74 BTRFS_SEND_C_WRITE = 15,
75 BTRFS_SEND_C_CLONE = 16,
77 BTRFS_SEND_C_TRUNCATE = 17,
78 BTRFS_SEND_C_CHMOD = 18,
79 BTRFS_SEND_C_CHOWN = 19,
80 BTRFS_SEND_C_UTIMES = 20,
82 BTRFS_SEND_C_END = 21,
83 BTRFS_SEND_C_UPDATE_EXTENT = 22,
84 BTRFS_SEND_C_MAX_V1 = 22,
87 BTRFS_SEND_C_FALLOCATE = 23,
88 BTRFS_SEND_C_SETFLAGS = 24,
89 BTRFS_SEND_C_ENCODED_WRITE = 25,
90 BTRFS_SEND_C_MAX_V2 = 25,
93 BTRFS_SEND_C_MAX = 25,
96 /* attributes in send stream */
98 BTRFS_SEND_A_UNSPEC = 0,
101 BTRFS_SEND_A_UUID = 1,
102 BTRFS_SEND_A_CTRANSID = 2,
104 BTRFS_SEND_A_INO = 3,
105 BTRFS_SEND_A_SIZE = 4,
106 BTRFS_SEND_A_MODE = 5,
107 BTRFS_SEND_A_UID = 6,
108 BTRFS_SEND_A_GID = 7,
109 BTRFS_SEND_A_RDEV = 8,
110 BTRFS_SEND_A_CTIME = 9,
111 BTRFS_SEND_A_MTIME = 10,
112 BTRFS_SEND_A_ATIME = 11,
113 BTRFS_SEND_A_OTIME = 12,
115 BTRFS_SEND_A_XATTR_NAME = 13,
116 BTRFS_SEND_A_XATTR_DATA = 14,
118 BTRFS_SEND_A_PATH = 15,
119 BTRFS_SEND_A_PATH_TO = 16,
120 BTRFS_SEND_A_PATH_LINK = 17,
122 BTRFS_SEND_A_FILE_OFFSET = 18,
124 * As of send stream v2, this attribute is special: it must be the last
125 * attribute in a command, its header contains only the type, and its
126 * length is implicitly the remaining length of the command.
128 BTRFS_SEND_A_DATA = 19,
130 BTRFS_SEND_A_CLONE_UUID = 20,
131 BTRFS_SEND_A_CLONE_CTRANSID = 21,
132 BTRFS_SEND_A_CLONE_PATH = 22,
133 BTRFS_SEND_A_CLONE_OFFSET = 23,
134 BTRFS_SEND_A_CLONE_LEN = 24,
136 BTRFS_SEND_A_MAX_V1 = 24,
139 BTRFS_SEND_A_FALLOCATE_MODE = 25,
141 BTRFS_SEND_A_SETFLAGS_FLAGS = 26,
143 BTRFS_SEND_A_UNENCODED_FILE_LEN = 27,
144 BTRFS_SEND_A_UNENCODED_LEN = 28,
145 BTRFS_SEND_A_UNENCODED_OFFSET = 29,
147 * COMPRESSION and ENCRYPTION default to NONE (0) if omitted from
148 * BTRFS_SEND_C_ENCODED_WRITE.
150 BTRFS_SEND_A_COMPRESSION = 30,
151 BTRFS_SEND_A_ENCRYPTION = 31,
152 BTRFS_SEND_A_MAX_V2 = 31,
155 BTRFS_SEND_A_MAX = 31,
159 long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg);