ioctl.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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_NAME_MAX 4039
  31. struct btrfs_ioctl_vol_args_v2 {
  32. __s64 fd;
  33. __u64 transid;
  34. __u64 flags;
  35. __u64 unused[4];
  36. char name[BTRFS_SUBVOL_NAME_MAX + 1];
  37. };
  38. #define BTRFS_INO_LOOKUP_PATH_MAX 4080
  39. struct btrfs_ioctl_ino_lookup_args {
  40. __u64 treeid;
  41. __u64 objectid;
  42. char name[BTRFS_INO_LOOKUP_PATH_MAX];
  43. };
  44. struct btrfs_ioctl_search_key {
  45. /* which root are we searching. 0 is the tree of tree roots */
  46. __u64 tree_id;
  47. /* keys returned will be >= min and <= max */
  48. __u64 min_objectid;
  49. __u64 max_objectid;
  50. /* keys returned will be >= min and <= max */
  51. __u64 min_offset;
  52. __u64 max_offset;
  53. /* max and min transids to search for */
  54. __u64 min_transid;
  55. __u64 max_transid;
  56. /* keys returned will be >= min and <= max */
  57. __u32 min_type;
  58. __u32 max_type;
  59. /*
  60. * how many items did userland ask for, and how many are we
  61. * returning
  62. */
  63. __u32 nr_items;
  64. /* align to 64 bits */
  65. __u32 unused;
  66. /* some extra for later */
  67. __u64 unused1;
  68. __u64 unused2;
  69. __u64 unused3;
  70. __u64 unused4;
  71. };
  72. struct btrfs_ioctl_search_header {
  73. __u64 transid;
  74. __u64 objectid;
  75. __u64 offset;
  76. __u32 type;
  77. __u32 len;
  78. };
  79. #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
  80. /*
  81. * the buf is an array of search headers where
  82. * each header is followed by the actual item
  83. * the type field is expanded to 32 bits for alignment
  84. */
  85. struct btrfs_ioctl_search_args {
  86. struct btrfs_ioctl_search_key key;
  87. char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
  88. };
  89. struct btrfs_ioctl_clone_range_args {
  90. __s64 src_fd;
  91. __u64 src_offset, src_length;
  92. __u64 dest_offset;
  93. };
  94. /* flags for the defrag range ioctl */
  95. #define BTRFS_DEFRAG_RANGE_COMPRESS 1
  96. #define BTRFS_DEFRAG_RANGE_START_IO 2
  97. struct btrfs_ioctl_defrag_range_args {
  98. /* start of the defrag operation */
  99. __u64 start;
  100. /* number of bytes to defrag, use (u64)-1 to say all */
  101. __u64 len;
  102. /*
  103. * flags for the operation, which can include turning
  104. * on compression for this one defrag
  105. */
  106. __u64 flags;
  107. /*
  108. * any extent bigger than this will be considered
  109. * already defragged. Use 0 to take the kernel default
  110. * Use 1 to say every single extent must be rewritten
  111. */
  112. __u32 extent_thresh;
  113. /* spare for later */
  114. __u32 unused[5];
  115. };
  116. struct btrfs_ioctl_space_info {
  117. __u64 flags;
  118. __u64 total_bytes;
  119. __u64 used_bytes;
  120. };
  121. struct btrfs_ioctl_space_args {
  122. __u64 space_slots;
  123. __u64 total_spaces;
  124. struct btrfs_ioctl_space_info spaces[0];
  125. };
  126. #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
  127. struct btrfs_ioctl_vol_args)
  128. #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
  129. struct btrfs_ioctl_vol_args)
  130. #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
  131. struct btrfs_ioctl_vol_args)
  132. #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
  133. struct btrfs_ioctl_vol_args)
  134. /* trans start and trans end are dangerous, and only for
  135. * use by applications that know how to avoid the
  136. * resulting deadlocks
  137. */
  138. #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
  139. #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
  140. #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
  141. #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
  142. #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
  143. struct btrfs_ioctl_vol_args)
  144. #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
  145. struct btrfs_ioctl_vol_args)
  146. #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
  147. struct btrfs_ioctl_vol_args)
  148. #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
  149. struct btrfs_ioctl_clone_range_args)
  150. #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
  151. struct btrfs_ioctl_vol_args)
  152. #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
  153. struct btrfs_ioctl_vol_args)
  154. #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
  155. struct btrfs_ioctl_defrag_range_args)
  156. #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
  157. struct btrfs_ioctl_search_args)
  158. #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
  159. struct btrfs_ioctl_ino_lookup_args)
  160. #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
  161. #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
  162. struct btrfs_ioctl_space_args)
  163. #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
  164. #define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
  165. #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
  166. struct btrfs_ioctl_vol_args_v2)
  167. #endif