btrfs-progs: make libbtrfs usable from C++
[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 #include "ctree.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
27 #define BTRFS_SEND_STREAM_VERSION 1
28
29 #define BTRFS_SEND_BUF_SIZE (1024 * 64)
30 #define BTRFS_SEND_READ_SIZE (1024 * 48)
31
32 enum btrfs_tlv_type {
33         BTRFS_TLV_U8,
34         BTRFS_TLV_U16,
35         BTRFS_TLV_U32,
36         BTRFS_TLV_U64,
37         BTRFS_TLV_BINARY,
38         BTRFS_TLV_STRING,
39         BTRFS_TLV_UUID,
40         BTRFS_TLV_TIMESPEC,
41 };
42
43 struct btrfs_stream_header {
44         char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
45         __le32 version;
46 } __attribute__ ((__packed__));
47
48 struct btrfs_cmd_header {
49         /* len excluding the header */
50         __le32 len;
51         __le16 cmd;
52         /* crc including the header with zero crc field */
53         __le32 crc;
54 } __attribute__ ((__packed__));
55
56 struct btrfs_tlv_header {
57         __le16 tlv_type;
58         /* len excluding the header */
59         __le16 tlv_len;
60 } __attribute__ ((__packed__));
61
62 /* commands */
63 enum btrfs_send_cmd {
64         BTRFS_SEND_C_UNSPEC,
65
66         BTRFS_SEND_C_SUBVOL,
67         BTRFS_SEND_C_SNAPSHOT,
68
69         BTRFS_SEND_C_MKFILE,
70         BTRFS_SEND_C_MKDIR,
71         BTRFS_SEND_C_MKNOD,
72         BTRFS_SEND_C_MKFIFO,
73         BTRFS_SEND_C_MKSOCK,
74         BTRFS_SEND_C_SYMLINK,
75
76         BTRFS_SEND_C_RENAME,
77         BTRFS_SEND_C_LINK,
78         BTRFS_SEND_C_UNLINK,
79         BTRFS_SEND_C_RMDIR,
80
81         BTRFS_SEND_C_SET_XATTR,
82         BTRFS_SEND_C_REMOVE_XATTR,
83
84         BTRFS_SEND_C_WRITE,
85         BTRFS_SEND_C_CLONE,
86
87         BTRFS_SEND_C_TRUNCATE,
88         BTRFS_SEND_C_CHMOD,
89         BTRFS_SEND_C_CHOWN,
90         BTRFS_SEND_C_UTIMES,
91
92         BTRFS_SEND_C_END,
93         BTRFS_SEND_C_UPDATE_EXTENT,
94         __BTRFS_SEND_C_MAX,
95 };
96 #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
97
98 /* attributes in send stream */
99 enum {
100         BTRFS_SEND_A_UNSPEC,
101
102         BTRFS_SEND_A_UUID,
103         BTRFS_SEND_A_CTRANSID,
104
105         BTRFS_SEND_A_INO,
106         BTRFS_SEND_A_SIZE,
107         BTRFS_SEND_A_MODE,
108         BTRFS_SEND_A_UID,
109         BTRFS_SEND_A_GID,
110         BTRFS_SEND_A_RDEV,
111         BTRFS_SEND_A_CTIME,
112         BTRFS_SEND_A_MTIME,
113         BTRFS_SEND_A_ATIME,
114         BTRFS_SEND_A_OTIME,
115
116         BTRFS_SEND_A_XATTR_NAME,
117         BTRFS_SEND_A_XATTR_DATA,
118
119         BTRFS_SEND_A_PATH,
120         BTRFS_SEND_A_PATH_TO,
121         BTRFS_SEND_A_PATH_LINK,
122
123         BTRFS_SEND_A_FILE_OFFSET,
124         BTRFS_SEND_A_DATA,
125
126         BTRFS_SEND_A_CLONE_UUID,
127         BTRFS_SEND_A_CLONE_CTRANSID,
128         BTRFS_SEND_A_CLONE_PATH,
129         BTRFS_SEND_A_CLONE_OFFSET,
130         BTRFS_SEND_A_CLONE_LEN,
131
132         __BTRFS_SEND_A_MAX,
133 };
134 #define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
135
136 #ifdef __KERNEL__
137 long btrfs_ioctl_send(struct file *mnt_file, void __user *arg);
138 #endif
139
140 #ifdef __cplusplus
141 }
142 #endif