linux_loop.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Copied from 2.6.25 kernel headers to avoid problems on older hosts,
  2. * and subsequently updated to match newer additions to the API.
  3. */
  4. #ifndef LINUX_LOOP_H
  5. #define LINUX_LOOP_H
  6. /*
  7. * include/linux/loop.h
  8. *
  9. * Written by Theodore Ts'o, 3/29/93.
  10. *
  11. * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
  12. * permitted under the GNU General Public License.
  13. */
  14. #define LO_NAME_SIZE 64
  15. #define LO_KEY_SIZE 32
  16. /*
  17. * Loop flags
  18. */
  19. enum {
  20. LO_FLAGS_READ_ONLY = 1,
  21. LO_FLAGS_USE_AOPS = 2,
  22. LO_FLAGS_AUTOCLEAR = 4,
  23. };
  24. #include <linux/version.h>
  25. #include <asm/posix_types.h> /* for __kernel_old_dev_t */
  26. #include <asm/types.h> /* for __u64 */
  27. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) /* This is a guess. */
  28. #define __kernel_old_dev_t __kernel_dev_t
  29. #endif
  30. /* Backwards compatibility version */
  31. struct loop_info {
  32. int lo_number; /* ioctl r/o */
  33. __kernel_old_dev_t lo_device; /* ioctl r/o */
  34. unsigned long lo_inode; /* ioctl r/o */
  35. __kernel_old_dev_t lo_rdevice; /* ioctl r/o */
  36. int lo_offset;
  37. int lo_encrypt_type;
  38. int lo_encrypt_key_size; /* ioctl w/o */
  39. int lo_flags; /* ioctl r/o */
  40. char lo_name[LO_NAME_SIZE];
  41. unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
  42. unsigned long lo_init[2];
  43. char reserved[4];
  44. };
  45. struct loop_info64 {
  46. __u64 lo_device; /* ioctl r/o */
  47. __u64 lo_inode; /* ioctl r/o */
  48. __u64 lo_rdevice; /* ioctl r/o */
  49. __u64 lo_offset;
  50. __u64 lo_sizelimit;/* bytes, 0 == max available */
  51. __u32 lo_number; /* ioctl r/o */
  52. __u32 lo_encrypt_type;
  53. __u32 lo_encrypt_key_size; /* ioctl w/o */
  54. __u32 lo_flags; /* ioctl r/o */
  55. __u8 lo_file_name[LO_NAME_SIZE];
  56. __u8 lo_crypt_name[LO_NAME_SIZE];
  57. __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
  58. __u64 lo_init[2];
  59. };
  60. /*
  61. * Loop filter types
  62. */
  63. #define LO_CRYPT_NONE 0
  64. #define LO_CRYPT_XOR 1
  65. #define LO_CRYPT_DES 2
  66. #define LO_CRYPT_FISH2 3 /* Twofish encryption */
  67. #define LO_CRYPT_BLOW 4
  68. #define LO_CRYPT_CAST128 5
  69. #define LO_CRYPT_IDEA 6
  70. #define LO_CRYPT_DUMMY 9
  71. #define LO_CRYPT_SKIPJACK 10
  72. #define LO_CRYPT_CRYPTOAPI 18
  73. #define MAX_LO_CRYPT 20
  74. /*
  75. * IOCTL commands --- we will commandeer 0x4C ('L')
  76. */
  77. #define LOOP_SET_FD 0x4C00
  78. #define LOOP_CLR_FD 0x4C01
  79. #define LOOP_SET_STATUS 0x4C02
  80. #define LOOP_GET_STATUS 0x4C03
  81. #define LOOP_SET_STATUS64 0x4C04
  82. #define LOOP_GET_STATUS64 0x4C05
  83. #define LOOP_CHANGE_FD 0x4C06
  84. #define LOOP_SET_CAPACITY 0x4C07
  85. #define LOOP_SET_DIRECT_IO 0x4C08
  86. /* /dev/loop-control interface */
  87. #define LOOP_CTL_ADD 0x4C80
  88. #define LOOP_CTL_REMOVE 0x4C81
  89. #define LOOP_CTL_GET_FREE 0x4C82
  90. #endif