send.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright (C) 2012 Alexander Block. All rights reserved.
  3. * Copyright (C) 2012 STRATO. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public
  7. * License v2 as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public
  15. * License along with this program; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 021110-1307, USA.
  18. */
  19. #include "ctree.h"
  20. #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
  21. #define BTRFS_SEND_STREAM_VERSION 1
  22. #define BTRFS_SEND_BUF_SIZE (1024 * 64)
  23. #define BTRFS_SEND_READ_SIZE (1024 * 48)
  24. enum btrfs_tlv_type {
  25. BTRFS_TLV_U8,
  26. BTRFS_TLV_U16,
  27. BTRFS_TLV_U32,
  28. BTRFS_TLV_U64,
  29. BTRFS_TLV_BINARY,
  30. BTRFS_TLV_STRING,
  31. BTRFS_TLV_UUID,
  32. BTRFS_TLV_TIMESPEC,
  33. };
  34. struct btrfs_stream_header {
  35. char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
  36. __le32 version;
  37. } __attribute__ ((__packed__));
  38. struct btrfs_cmd_header {
  39. /* len excluding the header */
  40. __le32 len;
  41. __le16 cmd;
  42. /* crc including the header with zero crc field */
  43. __le32 crc;
  44. } __attribute__ ((__packed__));
  45. struct btrfs_tlv_header {
  46. __le16 tlv_type;
  47. /* len excluding the header */
  48. __le16 tlv_len;
  49. } __attribute__ ((__packed__));
  50. /* commands */
  51. enum btrfs_send_cmd {
  52. BTRFS_SEND_C_UNSPEC,
  53. BTRFS_SEND_C_SUBVOL,
  54. BTRFS_SEND_C_SNAPSHOT,
  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. BTRFS_SEND_C_RENAME,
  62. BTRFS_SEND_C_LINK,
  63. BTRFS_SEND_C_UNLINK,
  64. BTRFS_SEND_C_RMDIR,
  65. BTRFS_SEND_C_SET_XATTR,
  66. BTRFS_SEND_C_REMOVE_XATTR,
  67. BTRFS_SEND_C_WRITE,
  68. BTRFS_SEND_C_CLONE,
  69. BTRFS_SEND_C_TRUNCATE,
  70. BTRFS_SEND_C_CHMOD,
  71. BTRFS_SEND_C_CHOWN,
  72. BTRFS_SEND_C_UTIMES,
  73. BTRFS_SEND_C_END,
  74. BTRFS_SEND_C_UPDATE_EXTENT,
  75. __BTRFS_SEND_C_MAX,
  76. };
  77. #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
  78. /* attributes in send stream */
  79. enum {
  80. BTRFS_SEND_A_UNSPEC,
  81. BTRFS_SEND_A_UUID,
  82. BTRFS_SEND_A_CTRANSID,
  83. BTRFS_SEND_A_INO,
  84. BTRFS_SEND_A_SIZE,
  85. BTRFS_SEND_A_MODE,
  86. BTRFS_SEND_A_UID,
  87. BTRFS_SEND_A_GID,
  88. BTRFS_SEND_A_RDEV,
  89. BTRFS_SEND_A_CTIME,
  90. BTRFS_SEND_A_MTIME,
  91. BTRFS_SEND_A_ATIME,
  92. BTRFS_SEND_A_OTIME,
  93. BTRFS_SEND_A_XATTR_NAME,
  94. BTRFS_SEND_A_XATTR_DATA,
  95. BTRFS_SEND_A_PATH,
  96. BTRFS_SEND_A_PATH_TO,
  97. BTRFS_SEND_A_PATH_LINK,
  98. BTRFS_SEND_A_FILE_OFFSET,
  99. BTRFS_SEND_A_DATA,
  100. BTRFS_SEND_A_CLONE_UUID,
  101. BTRFS_SEND_A_CLONE_CTRANSID,
  102. BTRFS_SEND_A_CLONE_PATH,
  103. BTRFS_SEND_A_CLONE_OFFSET,
  104. BTRFS_SEND_A_CLONE_LEN,
  105. __BTRFS_SEND_A_MAX,
  106. };
  107. #define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
  108. #ifdef __KERNEL__
  109. long btrfs_ioctl_send(struct file *mnt_file, void __user *arg);
  110. #endif