xref: /openbmc/linux/fs/btrfs/send.h (revision 6c9111bc)
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 	BTRFS_SEND_C_SUBVOL,
52 	BTRFS_SEND_C_SNAPSHOT,
53 
54 	BTRFS_SEND_C_MKFILE,
55 	BTRFS_SEND_C_MKDIR,
56 	BTRFS_SEND_C_MKNOD,
57 	BTRFS_SEND_C_MKFIFO,
58 	BTRFS_SEND_C_MKSOCK,
59 	BTRFS_SEND_C_SYMLINK,
60 
61 	BTRFS_SEND_C_RENAME,
62 	BTRFS_SEND_C_LINK,
63 	BTRFS_SEND_C_UNLINK,
64 	BTRFS_SEND_C_RMDIR,
65 
66 	BTRFS_SEND_C_SET_XATTR,
67 	BTRFS_SEND_C_REMOVE_XATTR,
68 
69 	BTRFS_SEND_C_WRITE,
70 	BTRFS_SEND_C_CLONE,
71 
72 	BTRFS_SEND_C_TRUNCATE,
73 	BTRFS_SEND_C_CHMOD,
74 	BTRFS_SEND_C_CHOWN,
75 	BTRFS_SEND_C_UTIMES,
76 
77 	BTRFS_SEND_C_END,
78 	BTRFS_SEND_C_UPDATE_EXTENT,
79 	__BTRFS_SEND_C_MAX,
80 };
81 #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
82 
83 /* attributes in send stream */
84 enum {
85 	BTRFS_SEND_A_UNSPEC,
86 
87 	BTRFS_SEND_A_UUID,
88 	BTRFS_SEND_A_CTRANSID,
89 
90 	BTRFS_SEND_A_INO,
91 	BTRFS_SEND_A_SIZE,
92 	BTRFS_SEND_A_MODE,
93 	BTRFS_SEND_A_UID,
94 	BTRFS_SEND_A_GID,
95 	BTRFS_SEND_A_RDEV,
96 	BTRFS_SEND_A_CTIME,
97 	BTRFS_SEND_A_MTIME,
98 	BTRFS_SEND_A_ATIME,
99 	BTRFS_SEND_A_OTIME,
100 
101 	BTRFS_SEND_A_XATTR_NAME,
102 	BTRFS_SEND_A_XATTR_DATA,
103 
104 	BTRFS_SEND_A_PATH,
105 	BTRFS_SEND_A_PATH_TO,
106 	BTRFS_SEND_A_PATH_LINK,
107 
108 	BTRFS_SEND_A_FILE_OFFSET,
109 	BTRFS_SEND_A_DATA,
110 
111 	BTRFS_SEND_A_CLONE_UUID,
112 	BTRFS_SEND_A_CLONE_CTRANSID,
113 	BTRFS_SEND_A_CLONE_PATH,
114 	BTRFS_SEND_A_CLONE_OFFSET,
115 	BTRFS_SEND_A_CLONE_LEN,
116 
117 	__BTRFS_SEND_A_MAX,
118 };
119 #define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
120 
121 #ifdef __KERNEL__
122 long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg);
123 #endif
124 
125 #endif
126