blob: 23bcefc84e49abc89aaf8dc8a6f09441144890d9 [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
David Sterbae77fbf92021-10-22 16:53:36 +020051 /* Version 1 */
Alexander Block31db9f72012-07-25 23:19:24 +020052 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,
David Sterbae77fbf92021-10-22 16:53:36 +020080 __BTRFS_SEND_C_MAX_V1,
81
82 /* Version 2 */
83 __BTRFS_SEND_C_MAX_V2,
84
85 /* End */
Alexander Block31db9f72012-07-25 23:19:24 +020086 __BTRFS_SEND_C_MAX,
87};
88#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
89
90/* attributes in send stream */
91enum {
92 BTRFS_SEND_A_UNSPEC,
93
94 BTRFS_SEND_A_UUID,
95 BTRFS_SEND_A_CTRANSID,
96
97 BTRFS_SEND_A_INO,
98 BTRFS_SEND_A_SIZE,
99 BTRFS_SEND_A_MODE,
100 BTRFS_SEND_A_UID,
101 BTRFS_SEND_A_GID,
102 BTRFS_SEND_A_RDEV,
103 BTRFS_SEND_A_CTIME,
104 BTRFS_SEND_A_MTIME,
105 BTRFS_SEND_A_ATIME,
106 BTRFS_SEND_A_OTIME,
107
108 BTRFS_SEND_A_XATTR_NAME,
109 BTRFS_SEND_A_XATTR_DATA,
110
111 BTRFS_SEND_A_PATH,
112 BTRFS_SEND_A_PATH_TO,
113 BTRFS_SEND_A_PATH_LINK,
114
115 BTRFS_SEND_A_FILE_OFFSET,
116 BTRFS_SEND_A_DATA,
117
118 BTRFS_SEND_A_CLONE_UUID,
119 BTRFS_SEND_A_CLONE_CTRANSID,
120 BTRFS_SEND_A_CLONE_PATH,
121 BTRFS_SEND_A_CLONE_OFFSET,
122 BTRFS_SEND_A_CLONE_LEN,
123
124 __BTRFS_SEND_A_MAX,
125};
126#define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
127
128#ifdef __KERNEL__
Josef Bacik2351f432017-09-27 10:43:13 -0400129long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg);
Alexander Block31db9f72012-07-25 23:19:24 +0200130#endif
David Sterba9888c342018-04-03 19:16:55 +0200131
132#endif