ioctl.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * Copyright (C) 2007 Oracle. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License v2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public
  14. * License along with this program; if not, write to the
  15. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. * Boston, MA 021110-1307, USA.
  17. */
  18. #ifndef __IOCTL_
  19. #define __IOCTL_
  20. #include <linux/ioctl.h>
  21. #define BTRFS_IOCTL_MAGIC 0x94
  22. #define BTRFS_VOL_NAME_MAX 255
  23. /* this should be 4k */
  24. #define BTRFS_PATH_NAME_MAX 4087
  25. struct btrfs_ioctl_vol_args {
  26. __s64 fd;
  27. char name[BTRFS_PATH_NAME_MAX + 1];
  28. };
  29. #define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
  30. #define BTRFS_SUBVOL_RDONLY (1ULL << 1)
  31. #define BTRFS_SUBVOL_NAME_MAX 4039
  32. struct btrfs_ioctl_vol_args_v2 {
  33. __s64 fd;
  34. __u64 transid;
  35. __u64 flags;
  36. __u64 unused[4];
  37. char name[BTRFS_SUBVOL_NAME_MAX + 1];
  38. };
  39. #define BTRFS_INO_LOOKUP_PATH_MAX 4080
  40. struct btrfs_ioctl_ino_lookup_args {
  41. __u64 treeid;
  42. __u64 objectid;
  43. char name[BTRFS_INO_LOOKUP_PATH_MAX];
  44. };
  45. struct btrfs_ioctl_search_key {
  46. /* which root are we searching. 0 is the tree of tree roots */
  47. __u64 tree_id;
  48. /* keys returned will be >= min and <= max */
  49. __u64 min_objectid;
  50. __u64 max_objectid;
  51. /* keys returned will be >= min and <= max */
  52. __u64 min_offset;
  53. __u64 max_offset;
  54. /* max and min transids to search for */
  55. __u64 min_transid;
  56. __u64 max_transid;
  57. /* keys returned will be >= min and <= max */
  58. __u32 min_type;
  59. __u32 max_type;
  60. /*
  61. * how many items did userland ask for, and how many are we
  62. * returning
  63. */
  64. __u32 nr_items;
  65. /* align to 64 bits */
  66. __u32 unused;
  67. /* some extra for later */
  68. __u64 unused1;
  69. __u64 unused2;
  70. __u64 unused3;
  71. __u64 unused4;
  72. };
  73. struct btrfs_ioctl_search_header {
  74. __u64 transid;
  75. __u64 objectid;
  76. __u64 offset;
  77. __u32 type;
  78. __u32 len;
  79. };
  80. #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
  81. /*
  82. * the buf is an array of search headers where
  83. * each header is followed by the actual item
  84. * the type field is expanded to 32 bits for alignment
  85. */
  86. struct btrfs_ioctl_search_args {
  87. struct btrfs_ioctl_search_key key;
  88. char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
  89. };
  90. struct btrfs_ioctl_clone_range_args {
  91. __s64 src_fd;
  92. __u64 src_offset, src_length;
  93. __u64 dest_offset;
  94. };
  95. /* flags for the defrag range ioctl */
  96. #define BTRFS_DEFRAG_RANGE_COMPRESS 1
  97. #define BTRFS_DEFRAG_RANGE_START_IO 2
  98. struct btrfs_ioctl_defrag_range_args {
  99. /* start of the defrag operation */
  100. __u64 start;
  101. /* number of bytes to defrag, use (u64)-1 to say all */
  102. __u64 len;
  103. /*
  104. * flags for the operation, which can include turning
  105. * on compression for this one defrag
  106. */
  107. __u64 flags;
  108. /*
  109. * any extent bigger than this will be considered
  110. * already defragged. Use 0 to take the kernel default
  111. * Use 1 to say every single extent must be rewritten
  112. */
  113. __u32 extent_thresh;
  114. /*
  115. * which compression method to use if turning on compression
  116. * for this defrag operation. If unspecified, zlib will
  117. * be used
  118. */
  119. __u32 compress_type;
  120. /* spare for later */
  121. __u32 unused[4];
  122. };
  123. struct btrfs_ioctl_space_info {
  124. __u64 flags;
  125. __u64 total_bytes;
  126. __u64 used_bytes;
  127. };
  128. struct btrfs_ioctl_space_args {
  129. __u64 space_slots;
  130. __u64 total_spaces;
  131. struct btrfs_ioctl_space_info spaces[0];
  132. };
  133. #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
  134. struct btrfs_ioctl_vol_args)
  135. #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
  136. struct btrfs_ioctl_vol_args)
  137. #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
  138. struct btrfs_ioctl_vol_args)
  139. #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
  140. struct btrfs_ioctl_vol_args)
  141. /* trans start and trans end are dangerous, and only for
  142. * use by applications that know how to avoid the
  143. * resulting deadlocks
  144. */
  145. #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
  146. #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
  147. #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
  148. #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
  149. #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
  150. struct btrfs_ioctl_vol_args)
  151. #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
  152. struct btrfs_ioctl_vol_args)
  153. #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
  154. struct btrfs_ioctl_vol_args)
  155. #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
  156. struct btrfs_ioctl_clone_range_args)
  157. #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
  158. struct btrfs_ioctl_vol_args)
  159. #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
  160. struct btrfs_ioctl_vol_args)
  161. #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
  162. struct btrfs_ioctl_defrag_range_args)
  163. #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
  164. struct btrfs_ioctl_search_args)
  165. #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
  166. struct btrfs_ioctl_ino_lookup_args)
  167. #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
  168. #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
  169. struct btrfs_ioctl_space_args)
  170. #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
  171. #define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
  172. #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
  173. struct btrfs_ioctl_vol_args_v2)
  174. #define BTRFS_IOC_SUBVOL_GETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 25, __u64)
  175. #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
  176. #endif