18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2012 Alexander Block.  All rights reserved.
48c2ecf20Sopenharmony_ci * Copyright (C) 2012 STRATO.  All rights reserved.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef BTRFS_SEND_H
88c2ecf20Sopenharmony_ci#define BTRFS_SEND_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include "ctree.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
138c2ecf20Sopenharmony_ci#define BTRFS_SEND_STREAM_VERSION 1
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define BTRFS_SEND_BUF_SIZE SZ_64K
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cienum btrfs_tlv_type {
188c2ecf20Sopenharmony_ci	BTRFS_TLV_U8,
198c2ecf20Sopenharmony_ci	BTRFS_TLV_U16,
208c2ecf20Sopenharmony_ci	BTRFS_TLV_U32,
218c2ecf20Sopenharmony_ci	BTRFS_TLV_U64,
228c2ecf20Sopenharmony_ci	BTRFS_TLV_BINARY,
238c2ecf20Sopenharmony_ci	BTRFS_TLV_STRING,
248c2ecf20Sopenharmony_ci	BTRFS_TLV_UUID,
258c2ecf20Sopenharmony_ci	BTRFS_TLV_TIMESPEC,
268c2ecf20Sopenharmony_ci};
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_cistruct btrfs_stream_header {
298c2ecf20Sopenharmony_ci	char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
308c2ecf20Sopenharmony_ci	__le32 version;
318c2ecf20Sopenharmony_ci} __attribute__ ((__packed__));
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistruct btrfs_cmd_header {
348c2ecf20Sopenharmony_ci	/* len excluding the header */
358c2ecf20Sopenharmony_ci	__le32 len;
368c2ecf20Sopenharmony_ci	__le16 cmd;
378c2ecf20Sopenharmony_ci	/* crc including the header with zero crc field */
388c2ecf20Sopenharmony_ci	__le32 crc;
398c2ecf20Sopenharmony_ci} __attribute__ ((__packed__));
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistruct btrfs_tlv_header {
428c2ecf20Sopenharmony_ci	__le16 tlv_type;
438c2ecf20Sopenharmony_ci	/* len excluding the header */
448c2ecf20Sopenharmony_ci	__le16 tlv_len;
458c2ecf20Sopenharmony_ci} __attribute__ ((__packed__));
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci/* commands */
488c2ecf20Sopenharmony_cienum btrfs_send_cmd {
498c2ecf20Sopenharmony_ci	BTRFS_SEND_C_UNSPEC,
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	BTRFS_SEND_C_SUBVOL,
528c2ecf20Sopenharmony_ci	BTRFS_SEND_C_SNAPSHOT,
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	BTRFS_SEND_C_MKFILE,
558c2ecf20Sopenharmony_ci	BTRFS_SEND_C_MKDIR,
568c2ecf20Sopenharmony_ci	BTRFS_SEND_C_MKNOD,
578c2ecf20Sopenharmony_ci	BTRFS_SEND_C_MKFIFO,
588c2ecf20Sopenharmony_ci	BTRFS_SEND_C_MKSOCK,
598c2ecf20Sopenharmony_ci	BTRFS_SEND_C_SYMLINK,
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	BTRFS_SEND_C_RENAME,
628c2ecf20Sopenharmony_ci	BTRFS_SEND_C_LINK,
638c2ecf20Sopenharmony_ci	BTRFS_SEND_C_UNLINK,
648c2ecf20Sopenharmony_ci	BTRFS_SEND_C_RMDIR,
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	BTRFS_SEND_C_SET_XATTR,
678c2ecf20Sopenharmony_ci	BTRFS_SEND_C_REMOVE_XATTR,
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	BTRFS_SEND_C_WRITE,
708c2ecf20Sopenharmony_ci	BTRFS_SEND_C_CLONE,
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	BTRFS_SEND_C_TRUNCATE,
738c2ecf20Sopenharmony_ci	BTRFS_SEND_C_CHMOD,
748c2ecf20Sopenharmony_ci	BTRFS_SEND_C_CHOWN,
758c2ecf20Sopenharmony_ci	BTRFS_SEND_C_UTIMES,
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	BTRFS_SEND_C_END,
788c2ecf20Sopenharmony_ci	BTRFS_SEND_C_UPDATE_EXTENT,
798c2ecf20Sopenharmony_ci	__BTRFS_SEND_C_MAX,
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci#define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* attributes in send stream */
848c2ecf20Sopenharmony_cienum {
858c2ecf20Sopenharmony_ci	BTRFS_SEND_A_UNSPEC,
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci	BTRFS_SEND_A_UUID,
888c2ecf20Sopenharmony_ci	BTRFS_SEND_A_CTRANSID,
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci	BTRFS_SEND_A_INO,
918c2ecf20Sopenharmony_ci	BTRFS_SEND_A_SIZE,
928c2ecf20Sopenharmony_ci	BTRFS_SEND_A_MODE,
938c2ecf20Sopenharmony_ci	BTRFS_SEND_A_UID,
948c2ecf20Sopenharmony_ci	BTRFS_SEND_A_GID,
958c2ecf20Sopenharmony_ci	BTRFS_SEND_A_RDEV,
968c2ecf20Sopenharmony_ci	BTRFS_SEND_A_CTIME,
978c2ecf20Sopenharmony_ci	BTRFS_SEND_A_MTIME,
988c2ecf20Sopenharmony_ci	BTRFS_SEND_A_ATIME,
998c2ecf20Sopenharmony_ci	BTRFS_SEND_A_OTIME,
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	BTRFS_SEND_A_XATTR_NAME,
1028c2ecf20Sopenharmony_ci	BTRFS_SEND_A_XATTR_DATA,
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci	BTRFS_SEND_A_PATH,
1058c2ecf20Sopenharmony_ci	BTRFS_SEND_A_PATH_TO,
1068c2ecf20Sopenharmony_ci	BTRFS_SEND_A_PATH_LINK,
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci	BTRFS_SEND_A_FILE_OFFSET,
1098c2ecf20Sopenharmony_ci	BTRFS_SEND_A_DATA,
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	BTRFS_SEND_A_CLONE_UUID,
1128c2ecf20Sopenharmony_ci	BTRFS_SEND_A_CLONE_CTRANSID,
1138c2ecf20Sopenharmony_ci	BTRFS_SEND_A_CLONE_PATH,
1148c2ecf20Sopenharmony_ci	BTRFS_SEND_A_CLONE_OFFSET,
1158c2ecf20Sopenharmony_ci	BTRFS_SEND_A_CLONE_LEN,
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	__BTRFS_SEND_A_MAX,
1188c2ecf20Sopenharmony_ci};
1198c2ecf20Sopenharmony_ci#define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#ifdef __KERNEL__
1228c2ecf20Sopenharmony_cilong btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg);
1238c2ecf20Sopenharmony_ci#endif
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci#endif
126