1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2012 Alexander Block. All rights reserved.
  24  * Copyright (c) 2012 STRATO AG. All rights reserved.
  25  */
  26 
  27 #ifndef _SYS_FAR_H
  28 #define _SYS_FAR_H
  29 
  30 #include <sys/inttypes.h>
  31 #include <sys/types.h>
  32 #include <sys/dmu.h>
  33 #include <sys/vnode.h>
  34 
  35 #ifdef  __cplusplus
  36 extern "C" {
  37 #endif
  38 
  39 #define FAR_SEND_STREAM_MAGIC "btrfs-stream"
  40 #define FAR_SEND_STREAM_VERSION 1
  41 
  42 #define FAR_SEND_BUF_SIZE 65536
  43 #define FAR_SEND_READ_SIZE 49152
  44 
  45 typedef struct _far_stream_header {
  46         char            fs_magic[sizeof (FAR_SEND_STREAM_MAGIC)];
  47         uint32_t        fs_version;
  48 } __attribute__((__packed__)) far_stream_header_t;
  49 
  50 typedef struct _far_cmd_header {
  51         /* len of the payload, not including header */
  52         uint32_t        fc_len;
  53         uint16_t        fc_cmd;
  54         /* the crc includes the header, but with fc_crc assumed as 0 */
  55         uint32_t        fc_crc;
  56 } __attribute__((__packed__)) far_cmd_header_t;
  57 
  58 typedef struct _far_attr_header {
  59         uint16_t        fa_type;
  60         /* len of the payload, not including header */
  61         uint16_t        fa_len;
  62 } __attribute__((__packed__)) far_attr_header_t;
  63 
  64 /* commands */
  65 #define FAR_CMD_SUBVOL          1
  66 #define FAR_CMD_SNAPSHOT        2
  67 #define FAR_CMD_MKFILE          3
  68 #define FAR_CMD_MKDIR           4
  69 #define FAR_CMD_MKNOD           5
  70 #define FAR_CMD_MKFIFO          6
  71 #define FAR_CMD_MKSOCK          7
  72 #define FAR_CMD_SYMLINK 8
  73 #define FAR_CMD_RENAME          9
  74 #define FAR_CMD_LINK            10
  75 #define FAR_CMD_UNLINK          11
  76 #define FAR_CMD_RMDIR           12
  77 #define FAR_CMD_SET_XATTR       13
  78 #define FAR_CMD_REMOVE_XATTR    14
  79 #define FAR_CMD_WRITE           15
  80 #define FAR_CMD_CLONE           16
  81 #define FAR_CMD_TRUNCATE        17
  82 #define FAR_CMD_CHMOD           18
  83 #define FAR_CMD_CHOWN           19
  84 #define FAR_CMD_UTIMES          20
  85 #define FAR_CMD_END             21
  86 #define FAR_CMD_MAX             21
  87 
  88 /* attributes */
  89 #define FAR_ATTR_UUID                   1
  90 #define FAR_ATTR_CTRANSID               2
  91 #define FAR_ATTR_INO                    3
  92 #define FAR_ATTR_SIZE                   4
  93 #define FAR_ATTR_MODE                   5
  94 #define FAR_ATTR_UID                    6
  95 #define FAR_ATTR_GID                    7
  96 #define FAR_ATTR_RDEV                   8
  97 #define FAR_ATTR_CTIME                  9
  98 #define FAR_ATTR_MTIME                  10
  99 #define FAR_ATTR_ATIME                  11
 100 #define FAR_ATTR_OTIME                  12
 101 #define FAR_ATTR_XATTR_NAME             13
 102 #define FAR_ATTR_XATTR_DATA             14
 103 #define FAR_ATTR_PATH                   15
 104 #define FAR_ATTR_PATH_TO                16
 105 #define FAR_ATTR_PATH_LINK              17
 106 #define FAR_ATTR_FILE_OFFSET            18
 107 #define FAR_ATTR_DATA                   19
 108 #define FAR_ATTR_CLONE_UUID             20
 109 #define FAR_ATTR_CLONE_CTRANSID 21
 110 #define FAR_ATTR_CLONE_PATH             22
 111 #define FAR_ATTR_CLONE_OFFSET           23
 112 #define FAR_ATTR_CLONE_LEN              24
 113 #define FAR_ATTR_MAX                    24
 114 
 115 int far_send(objset_t *tosnap, objset_t *fromsnap, int outfd, vnode_t *vp,
 116     offset_t *off);
 117 
 118 #ifdef  __cplusplus
 119 }
 120 #endif
 121 
 122 #endif  /* _SYS_FAR_H */