xref: /openbmc/linux/fs/btrfs/send.h (revision d87c25e8)
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 
17 enum btrfs_tlv_type {
18 	BTRFS_TLV_U8,
19 	BTRFS_TLV_U16,
20 	BTRFS_TLV_U32,
21 	BTRFS_TLV_U64,
22 	BTRFS_TLV_BINARY,
23 	BTRFS_TLV_STRING,
24 	BTRFS_TLV_UUID,
25 	BTRFS_TLV_TIMESPEC,
26 };
27 
28 struct btrfs_stream_header {
29 	char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
30 	__le32 version;
31 } __attribute__ ((__packed__));
32 
33 struct btrfs_cmd_header {
34 	/* len excluding the header */
35 	__le32 len;
36 	__le16 cmd;
37 	/* crc including the header with zero crc field */
38 	__le32 crc;
39 } __attribute__ ((__packed__));
40 
41 struct btrfs_tlv_header {
42 	__le16 tlv_type;
43 	/* len excluding the header */
44 	__le16 tlv_len;
45 } __attribute__ ((__packed__));
46 
47 /* commands */
48 enum btrfs_send_cmd {
49 	BTRFS_SEND_C_UNSPEC,
50 
51 	/* Version 1 */
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_V1,
81 
82 	/* Version 2 */
83 	__BTRFS_SEND_C_MAX_V2,
84 
85 	/* End */
86 	__BTRFS_SEND_C_MAX,
87 };
88 #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
89 
90 /* attributes in send stream */
91 enum {
92 	BTRFS_SEND_A_UNSPEC,
93 
94 	BTRFS_SEND_A_UUID,
95 	BTRFS_SEND_A_CTRANSID,
96 
97 	BTRFS_SEND_A_INO,
98 	BTRFS_SEND_A_SIZE,
99 	BTRFS_SEND_A_MODE,
100 	BTRFS_SEND_A_UID,
101 	BTRFS_SEND_A_GID,
102 	BTRFS_SEND_A_RDEV,
103 	BTRFS_SEND_A_CTIME,
104 	BTRFS_SEND_A_MTIME,
105 	BTRFS_SEND_A_ATIME,
106 	BTRFS_SEND_A_OTIME,
107 
108 	BTRFS_SEND_A_XATTR_NAME,
109 	BTRFS_SEND_A_XATTR_DATA,
110 
111 	BTRFS_SEND_A_PATH,
112 	BTRFS_SEND_A_PATH_TO,
113 	BTRFS_SEND_A_PATH_LINK,
114 
115 	BTRFS_SEND_A_FILE_OFFSET,
116 	BTRFS_SEND_A_DATA,
117 
118 	BTRFS_SEND_A_CLONE_UUID,
119 	BTRFS_SEND_A_CLONE_CTRANSID,
120 	BTRFS_SEND_A_CLONE_PATH,
121 	BTRFS_SEND_A_CLONE_OFFSET,
122 	BTRFS_SEND_A_CLONE_LEN,
123 
124 	__BTRFS_SEND_A_MAX,
125 };
126 #define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
127 
128 #ifdef __KERNEL__
129 long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg);
130 #endif
131 
132 #endif
133