blob: ead397f7034f60d8895b059fe8cf257edeb2923e [file] [log] [blame]
David Sterba9888c342018-04-03 19:16:55 +02001/* SPDX-License-Identifier: GPL-2.0 */
Alexander Block31db9f72012-07-25 23:19:24 +02002/*
3 * Copyright (C) 2012 Alexander Block. All rights reserved.
4 * Copyright (C) 2012 STRATO. All rights reserved.
Alexander Block31db9f72012-07-25 23:19:24 +02005 */
6
David Sterba9888c342018-04-03 19:16:55 +02007#ifndef BTRFS_SEND_H
8#define BTRFS_SEND_H
9
Alexander Block31db9f72012-07-25 23:19:24 +020010#include "ctree.h"
11
12#define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
13#define BTRFS_SEND_STREAM_VERSION 1
14
Byongho Leeee221842015-12-15 01:42:10 +090015#define BTRFS_SEND_BUF_SIZE SZ_64K
16#define BTRFS_SEND_READ_SIZE (48 * SZ_1K)
Alexander Block31db9f72012-07-25 23:19:24 +020017
18enum 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
29struct btrfs_stream_header {
30 char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
31 __le32 version;
32} __attribute__ ((__packed__));
33
34struct 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
42struct btrfs_tlv_header {
43 __le16 tlv_type;
44 /* len excluding the header */
45 __le16 tlv_len;
46} __attribute__ ((__packed__));
47
48/* commands */
49enum 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,
Mark Fashehcb95e7b2013-02-04 20:54:57 +000079 BTRFS_SEND_C_UPDATE_EXTENT,
Alexander Block31db9f72012-07-25 23:19:24 +020080 __BTRFS_SEND_C_MAX,
81};
82#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
83
84/* attributes in send stream */
85enum {
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__
Josef Bacik2351f432017-09-27 10:43:13 -0400123long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg);
Alexander Block31db9f72012-07-25 23:19:24 +0200124#endif
David Sterba9888c342018-04-03 19:16:55 +0200125
126#endif