ioctl.h 4.9 KB

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