btrfs-progs: tests: introduce mustfail helper
[platform/upstream/btrfs-progs.git] / send.h
1 /*
2  * Copyright (C) 2012 Alexander Block.  All rights reserved.
3  * Copyright (C) 2012 STRATO.  All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public
7  * License v2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 021110-1307, USA.
18  */
19
20 #ifndef __BTRFS_SEND_H__
21 #define __BTRFS_SEND_H__
22
23 #include "ctree.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
30 #define BTRFS_SEND_STREAM_VERSION 1
31
32 #define BTRFS_SEND_BUF_SIZE (1024 * 64)
33 #define BTRFS_SEND_READ_SIZE (1024 * 48)
34
35 enum btrfs_tlv_type {
36         BTRFS_TLV_U8,
37         BTRFS_TLV_U16,
38         BTRFS_TLV_U32,
39         BTRFS_TLV_U64,
40         BTRFS_TLV_BINARY,
41         BTRFS_TLV_STRING,
42         BTRFS_TLV_UUID,
43         BTRFS_TLV_TIMESPEC,
44 };
45
46 struct btrfs_stream_header {
47         char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
48         __le32 version;
49 } __attribute__ ((__packed__));
50
51 struct btrfs_cmd_header {
52         /* len excluding the header */
53         __le32 len;
54         __le16 cmd;
55         /* crc including the header with zero crc field */
56         __le32 crc;
57 } __attribute__ ((__packed__));
58
59 struct btrfs_tlv_header {
60         __le16 tlv_type;
61         /* len excluding the header */
62         __le16 tlv_len;
63 } __attribute__ ((__packed__));
64
65 /* commands */
66 enum btrfs_send_cmd {
67         BTRFS_SEND_C_UNSPEC,
68
69         BTRFS_SEND_C_SUBVOL,
70         BTRFS_SEND_C_SNAPSHOT,
71
72         BTRFS_SEND_C_MKFILE,
73         BTRFS_SEND_C_MKDIR,
74         BTRFS_SEND_C_MKNOD,
75         BTRFS_SEND_C_MKFIFO,
76         BTRFS_SEND_C_MKSOCK,
77         BTRFS_SEND_C_SYMLINK,
78
79         BTRFS_SEND_C_RENAME,
80         BTRFS_SEND_C_LINK,
81         BTRFS_SEND_C_UNLINK,
82         BTRFS_SEND_C_RMDIR,
83
84         BTRFS_SEND_C_SET_XATTR,
85         BTRFS_SEND_C_REMOVE_XATTR,
86
87         BTRFS_SEND_C_WRITE,
88         BTRFS_SEND_C_CLONE,
89
90         BTRFS_SEND_C_TRUNCATE,
91         BTRFS_SEND_C_CHMOD,
92         BTRFS_SEND_C_CHOWN,
93         BTRFS_SEND_C_UTIMES,
94
95         BTRFS_SEND_C_END,
96         BTRFS_SEND_C_UPDATE_EXTENT,
97         __BTRFS_SEND_C_MAX,
98 };
99 #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
100
101 /* attributes in send stream */
102 enum {
103         BTRFS_SEND_A_UNSPEC,
104
105         BTRFS_SEND_A_UUID,
106         BTRFS_SEND_A_CTRANSID,
107
108         BTRFS_SEND_A_INO,
109         BTRFS_SEND_A_SIZE,
110         BTRFS_SEND_A_MODE,
111         BTRFS_SEND_A_UID,
112         BTRFS_SEND_A_GID,
113         BTRFS_SEND_A_RDEV,
114         BTRFS_SEND_A_CTIME,
115         BTRFS_SEND_A_MTIME,
116         BTRFS_SEND_A_ATIME,
117         BTRFS_SEND_A_OTIME,
118
119         BTRFS_SEND_A_XATTR_NAME,
120         BTRFS_SEND_A_XATTR_DATA,
121
122         BTRFS_SEND_A_PATH,
123         BTRFS_SEND_A_PATH_TO,
124         BTRFS_SEND_A_PATH_LINK,
125
126         BTRFS_SEND_A_FILE_OFFSET,
127         BTRFS_SEND_A_DATA,
128
129         BTRFS_SEND_A_CLONE_UUID,
130         BTRFS_SEND_A_CLONE_CTRANSID,
131         BTRFS_SEND_A_CLONE_PATH,
132         BTRFS_SEND_A_CLONE_OFFSET,
133         BTRFS_SEND_A_CLONE_LEN,
134
135         __BTRFS_SEND_A_MAX,
136 };
137 #define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
138
139 #ifdef __KERNEL__
140 long btrfs_ioctl_send(struct file *mnt_file, void __user *arg);
141 #endif
142
143 #ifdef __cplusplus
144 }
145 #endif
146
147 #endif