Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2012 Alexander Block.  All rights reserved.
0004  * Copyright (C) 2012 STRATO.  All rights reserved.
0005  */
0006 
0007 #ifndef BTRFS_SEND_H
0008 #define BTRFS_SEND_H
0009 
0010 #include <linux/types.h>
0011 
0012 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
0013 #define BTRFS_SEND_STREAM_VERSION 2
0014 
0015 /*
0016  * In send stream v1, no command is larger than 64K. In send stream v2, no limit
0017  * should be assumed.
0018  */
0019 #define BTRFS_SEND_BUF_SIZE_V1              SZ_64K
0020 
0021 struct inode;
0022 struct btrfs_ioctl_send_args;
0023 
0024 enum btrfs_tlv_type {
0025     BTRFS_TLV_U8,
0026     BTRFS_TLV_U16,
0027     BTRFS_TLV_U32,
0028     BTRFS_TLV_U64,
0029     BTRFS_TLV_BINARY,
0030     BTRFS_TLV_STRING,
0031     BTRFS_TLV_UUID,
0032     BTRFS_TLV_TIMESPEC,
0033 };
0034 
0035 struct btrfs_stream_header {
0036     char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
0037     __le32 version;
0038 } __attribute__ ((__packed__));
0039 
0040 struct btrfs_cmd_header {
0041     /* len excluding the header */
0042     __le32 len;
0043     __le16 cmd;
0044     /* crc including the header with zero crc field */
0045     __le32 crc;
0046 } __attribute__ ((__packed__));
0047 
0048 struct btrfs_tlv_header {
0049     __le16 tlv_type;
0050     /* len excluding the header */
0051     __le16 tlv_len;
0052 } __attribute__ ((__packed__));
0053 
0054 /* commands */
0055 enum btrfs_send_cmd {
0056     BTRFS_SEND_C_UNSPEC     = 0,
0057 
0058     /* Version 1 */
0059     BTRFS_SEND_C_SUBVOL     = 1,
0060     BTRFS_SEND_C_SNAPSHOT       = 2,
0061 
0062     BTRFS_SEND_C_MKFILE     = 3,
0063     BTRFS_SEND_C_MKDIR      = 4,
0064     BTRFS_SEND_C_MKNOD      = 5,
0065     BTRFS_SEND_C_MKFIFO     = 6,
0066     BTRFS_SEND_C_MKSOCK     = 7,
0067     BTRFS_SEND_C_SYMLINK        = 8,
0068 
0069     BTRFS_SEND_C_RENAME     = 9,
0070     BTRFS_SEND_C_LINK       = 10,
0071     BTRFS_SEND_C_UNLINK     = 11,
0072     BTRFS_SEND_C_RMDIR      = 12,
0073 
0074     BTRFS_SEND_C_SET_XATTR      = 13,
0075     BTRFS_SEND_C_REMOVE_XATTR   = 14,
0076 
0077     BTRFS_SEND_C_WRITE      = 15,
0078     BTRFS_SEND_C_CLONE      = 16,
0079 
0080     BTRFS_SEND_C_TRUNCATE       = 17,
0081     BTRFS_SEND_C_CHMOD      = 18,
0082     BTRFS_SEND_C_CHOWN      = 19,
0083     BTRFS_SEND_C_UTIMES     = 20,
0084 
0085     BTRFS_SEND_C_END        = 21,
0086     BTRFS_SEND_C_UPDATE_EXTENT  = 22,
0087     BTRFS_SEND_C_MAX_V1     = 22,
0088 
0089     /* Version 2 */
0090     BTRFS_SEND_C_FALLOCATE      = 23,
0091     BTRFS_SEND_C_FILEATTR       = 24,
0092     BTRFS_SEND_C_ENCODED_WRITE  = 25,
0093     BTRFS_SEND_C_MAX_V2     = 25,
0094 
0095     /* End */
0096     BTRFS_SEND_C_MAX        = 25,
0097 };
0098 
0099 /* attributes in send stream */
0100 enum {
0101     BTRFS_SEND_A_UNSPEC     = 0,
0102 
0103     /* Version 1 */
0104     BTRFS_SEND_A_UUID       = 1,
0105     BTRFS_SEND_A_CTRANSID       = 2,
0106 
0107     BTRFS_SEND_A_INO        = 3,
0108     BTRFS_SEND_A_SIZE       = 4,
0109     BTRFS_SEND_A_MODE       = 5,
0110     BTRFS_SEND_A_UID        = 6,
0111     BTRFS_SEND_A_GID        = 7,
0112     BTRFS_SEND_A_RDEV       = 8,
0113     BTRFS_SEND_A_CTIME      = 9,
0114     BTRFS_SEND_A_MTIME      = 10,
0115     BTRFS_SEND_A_ATIME      = 11,
0116     BTRFS_SEND_A_OTIME      = 12,
0117 
0118     BTRFS_SEND_A_XATTR_NAME     = 13,
0119     BTRFS_SEND_A_XATTR_DATA     = 14,
0120 
0121     BTRFS_SEND_A_PATH       = 15,
0122     BTRFS_SEND_A_PATH_TO        = 16,
0123     BTRFS_SEND_A_PATH_LINK      = 17,
0124 
0125     BTRFS_SEND_A_FILE_OFFSET    = 18,
0126     /*
0127      * As of send stream v2, this attribute is special: it must be the last
0128      * attribute in a command, its header contains only the type, and its
0129      * length is implicitly the remaining length of the command.
0130      */
0131     BTRFS_SEND_A_DATA       = 19,
0132 
0133     BTRFS_SEND_A_CLONE_UUID     = 20,
0134     BTRFS_SEND_A_CLONE_CTRANSID = 21,
0135     BTRFS_SEND_A_CLONE_PATH     = 22,
0136     BTRFS_SEND_A_CLONE_OFFSET   = 23,
0137     BTRFS_SEND_A_CLONE_LEN      = 24,
0138 
0139     BTRFS_SEND_A_MAX_V1     = 24,
0140 
0141     /* Version 2 */
0142     BTRFS_SEND_A_FALLOCATE_MODE = 25,
0143 
0144     /*
0145      * File attributes from the FS_*_FL namespace (i_flags, xflags),
0146      * translated to BTRFS_INODE_* bits (BTRFS_INODE_FLAG_MASK) and stored
0147      * in btrfs_inode_item::flags (represented by btrfs_inode::flags and
0148      * btrfs_inode::ro_flags).
0149      */
0150     BTRFS_SEND_A_FILEATTR       = 26,
0151 
0152     BTRFS_SEND_A_UNENCODED_FILE_LEN = 27,
0153     BTRFS_SEND_A_UNENCODED_LEN  = 28,
0154     BTRFS_SEND_A_UNENCODED_OFFSET   = 29,
0155     /*
0156      * COMPRESSION and ENCRYPTION default to NONE (0) if omitted from
0157      * BTRFS_SEND_C_ENCODED_WRITE.
0158      */
0159     BTRFS_SEND_A_COMPRESSION    = 30,
0160     BTRFS_SEND_A_ENCRYPTION     = 31,
0161     BTRFS_SEND_A_MAX_V2     = 31,
0162 
0163     /* End */
0164     BTRFS_SEND_A_MAX        = 31,
0165 };
0166 
0167 long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg);
0168 
0169 #endif