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_FITS_H
  28 #define _SYS_FITS_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 FITS_SEND_STREAM_MAGIC "btrfs-stream"
  40 #define FITS_SEND_STREAM_VERSION 1
  41 
  42 #define FITS_SEND_BUF_SIZE 65536
  43 #define FITS_SEND_READ_SIZE 49152
  44 
  45 typedef struct _fits_stream_header {
  46         char            fs_magic[sizeof (FITS_SEND_STREAM_MAGIC)];
  47         uint32_t        fs_version;
  48 } __attribute__((__packed__)) fits_stream_header_t;
  49 
  50 typedef struct _fits_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__)) fits_cmd_header_t;
  57 
  58 typedef struct _fits_attr_header {
  59         uint16_t        fa_type;
  60         /* len of the payload, not including header */
  61         uint16_t        fa_len;
  62 } __attribute__((__packed__)) fits_attr_header_t;
  63 
  64 /* commands */
  65 #define FITS_CMD_SUBVOL         1
  66 #define FITS_CMD_SNAPSHOT       2
  67 #define FITS_CMD_MKFILE         3
  68 #define FITS_CMD_MKDIR          4
  69 #define FITS_CMD_MKNOD          5
  70 #define FITS_CMD_MKFIFO         6
  71 #define FITS_CMD_MKSOCK         7
  72 #define FITS_CMD_SYMLINK        8
  73 #define FITS_CMD_RENAME         9
  74 #define FITS_CMD_LINK           10
  75 #define FITS_CMD_UNLINK         11
  76 #define FITS_CMD_RMDIR          12
  77 #define FITS_CMD_SET_XATTR      13
  78 #define FITS_CMD_REMOVE_XATTR   14
  79 #define FITS_CMD_WRITE          15
  80 #define FITS_CMD_CLONE          16
  81 #define FITS_CMD_TRUNCATE       17
  82 #define FITS_CMD_CHMOD          18
  83 #define FITS_CMD_CHOWN          19
  84 #define FITS_CMD_UTIMES         20
  85 #define FITS_CMD_END            21
  86 #define FITS_CMD_MAX            21
  87 
  88 /* attributes */
  89 #define FITS_ATTR_UUID                  1
  90 #define FITS_ATTR_CTRANSID              2
  91 #define FITS_ATTR_INO                   3
  92 #define FITS_ATTR_SIZE                  4
  93 #define FITS_ATTR_MODE                  5
  94 #define FITS_ATTR_UID                   6
  95 #define FITS_ATTR_GID                   7
  96 #define FITS_ATTR_RDEV                  8
  97 #define FITS_ATTR_CTIME                 9
  98 #define FITS_ATTR_MTIME                 10
  99 #define FITS_ATTR_ATIME                 11
 100 #define FITS_ATTR_OTIME                 12
 101 #define FITS_ATTR_XATTR_NAME            13
 102 #define FITS_ATTR_XATTR_DATA            14
 103 #define FITS_ATTR_PATH                  15
 104 #define FITS_ATTR_PATH_TO               16
 105 #define FITS_ATTR_PATH_LINK             17
 106 #define FITS_ATTR_FILE_OFFSET           18
 107 #define FITS_ATTR_DATA                  19
 108 #define FITS_ATTR_CLONE_UUID            20
 109 #define FITS_ATTR_CLONE_CTRANSID        21
 110 #define FITS_ATTR_CLONE_PATH            22
 111 #define FITS_ATTR_CLONE_OFFSET          23
 112 #define FITS_ATTR_CLONE_LEN             24
 113 #define FITS_ATTR_MAX                   24
 114 
 115 int fits_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_FITS_H */