blob: de91488b7cd003de0d7822b2fc2a521062bcb052 [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
Alexander Block31db9f72012-07-25 23:19:24 +020016
17enum 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
28struct btrfs_stream_header {
29 char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
30 __le32 version;
31} __attribute__ ((__packed__));
32
33struct 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
41struct btrfs_tlv_header {
42 __le16 tlv_type;
43 /* len excluding the header */
44 __le16 tlv_len;
45} __attribute__ ((__packed__));
46
47/* commands */
48enum 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,
Mark Fashehcb95e7b2013-02-04 20:54:57 +000078 BTRFS_SEND_C_UPDATE_EXTENT,
Alexander Block31db9f72012-07-25 23:19:24 +020079 __BTRFS_SEND_C_MAX,
80};
81#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
82
83/* attributes in send stream */
84enum {
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__
Josef Bacik2351f432017-09-27 10:43:13 -0400122long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg);
Alexander Block31db9f72012-07-25 23:19:24 +0200123#endif
David Sterba9888c342018-04-03 19:16:55 +0200124
125#endif