xref: /linux/fs/btrfs/send.h (revision a8b70ccf10e38775785d9cb12ead916474549f99)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2012 Alexander Block.  All rights reserved.
4  * Copyright (C) 2012 STRATO.  All rights reserved.
5  */
6 
7 #ifndef BTRFS_SEND_H
8 #define BTRFS_SEND_H
9 
10 #include "ctree.h"
11 
12 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
13 #define BTRFS_SEND_STREAM_VERSION 1
14 
15 #define BTRFS_SEND_BUF_SIZE SZ_64K
16 #define BTRFS_SEND_READ_SIZE (48 * SZ_1K)
17 
18 enum btrfs_tlv_type {
19 	BTRFS_TLV_U8,
20 	BTRFS_TLV_U16,
21 	BTRFS_TLV_U32,
22 	BTRFS_TLV_U64,
23 	BTRFS_TLV_BINARY,
24 	BTRFS_TLV_STRING,
25 	BTRFS_TLV_UUID,
26 	BTRFS_TLV_TIMESPEC,
27 };
28 
29 struct btrfs_stream_header {
30 	char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
31 	__le32 version;
32 } __attribute__ ((__packed__));
33 
34 struct btrfs_cmd_header {
35 	/* len excluding the header */
36 	__le32 len;
37 	__le16 cmd;
38 	/* crc including the header with zero crc field */
39 	__le32 crc;
40 } __attribute__ ((__packed__));
41 
42 struct btrfs_tlv_header {
43 	__le16 tlv_type;
44 	/* len excluding the header */
45 	__le16 tlv_len;
46 } __attribute__ ((__packed__));
47 
48 /* commands */
49 enum btrfs_send_cmd {
50 	BTRFS_SEND_C_UNSPEC,
51 
52 	BTRFS_SEND_C_SUBVOL,
53 	BTRFS_SEND_C_SNAPSHOT,
54 
55 	BTRFS_SEND_C_MKFILE,
56 	BTRFS_SEND_C_MKDIR,
57 	BTRFS_SEND_C_MKNOD,
58 	BTRFS_SEND_C_MKFIFO,
59 	BTRFS_SEND_C_MKSOCK,
60 	BTRFS_SEND_C_SYMLINK,
61 
62 	BTRFS_SEND_C_RENAME,
63 	BTRFS_SEND_C_LINK,
64 	BTRFS_SEND_C_UNLINK,
65 	BTRFS_SEND_C_RMDIR,
66 
67 	BTRFS_SEND_C_SET_XATTR,
68 	BTRFS_SEND_C_REMOVE_XATTR,
69 
70 	BTRFS_SEND_C_WRITE,
71 	BTRFS_SEND_C_CLONE,
72 
73 	BTRFS_SEND_C_TRUNCATE,
74 	BTRFS_SEND_C_CHMOD,
75 	BTRFS_SEND_C_CHOWN,
76 	BTRFS_SEND_C_UTIMES,
77 
78 	BTRFS_SEND_C_END,
79 	BTRFS_SEND_C_UPDATE_EXTENT,
80 	__BTRFS_SEND_C_MAX,
81 };
82 #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
83 
84 /* attributes in send stream */
85 enum {
86 	BTRFS_SEND_A_UNSPEC,
87 
88 	BTRFS_SEND_A_UUID,
89 	BTRFS_SEND_A_CTRANSID,
90 
91 	BTRFS_SEND_A_INO,
92 	BTRFS_SEND_A_SIZE,
93 	BTRFS_SEND_A_MODE,
94 	BTRFS_SEND_A_UID,
95 	BTRFS_SEND_A_GID,
96 	BTRFS_SEND_A_RDEV,
97 	BTRFS_SEND_A_CTIME,
98 	BTRFS_SEND_A_MTIME,
99 	BTRFS_SEND_A_ATIME,
100 	BTRFS_SEND_A_OTIME,
101 
102 	BTRFS_SEND_A_XATTR_NAME,
103 	BTRFS_SEND_A_XATTR_DATA,
104 
105 	BTRFS_SEND_A_PATH,
106 	BTRFS_SEND_A_PATH_TO,
107 	BTRFS_SEND_A_PATH_LINK,
108 
109 	BTRFS_SEND_A_FILE_OFFSET,
110 	BTRFS_SEND_A_DATA,
111 
112 	BTRFS_SEND_A_CLONE_UUID,
113 	BTRFS_SEND_A_CLONE_CTRANSID,
114 	BTRFS_SEND_A_CLONE_PATH,
115 	BTRFS_SEND_A_CLONE_OFFSET,
116 	BTRFS_SEND_A_CLONE_LEN,
117 
118 	__BTRFS_SEND_A_MAX,
119 };
120 #define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
121 
122 #ifdef __KERNEL__
123 long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg);
124 #endif
125 
126 #endif
127