loop.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
  2. /*
  3. * Copyright 1993 by Theodore Ts'o.
  4. */
  5. #ifndef _UAPI_LINUX_LOOP_H
  6. #define _UAPI_LINUX_LOOP_H
  7. #define LO_NAME_SIZE 64
  8. #define LO_KEY_SIZE 32
  9. /*
  10. * Loop flags
  11. */
  12. enum {
  13. LO_FLAGS_READ_ONLY = 1,
  14. LO_FLAGS_AUTOCLEAR = 4,
  15. LO_FLAGS_PARTSCAN = 8,
  16. LO_FLAGS_DIRECT_IO = 16,
  17. };
  18. /* LO_FLAGS that can be set using LOOP_SET_STATUS(64) */
  19. #define LOOP_SET_STATUS_SETTABLE_FLAGS (LO_FLAGS_AUTOCLEAR | LO_FLAGS_PARTSCAN)
  20. /* LO_FLAGS that can be cleared using LOOP_SET_STATUS(64) */
  21. #define LOOP_SET_STATUS_CLEARABLE_FLAGS (LO_FLAGS_AUTOCLEAR)
  22. /* LO_FLAGS that can be set using LOOP_CONFIGURE */
  23. #define LOOP_CONFIGURE_SETTABLE_FLAGS (LO_FLAGS_READ_ONLY | LO_FLAGS_AUTOCLEAR \
  24. | LO_FLAGS_PARTSCAN | LO_FLAGS_DIRECT_IO)
  25. #include <asm/posix_types.h> /* for __kernel_old_dev_t */
  26. #include <linux/types.h> /* for __u64 */
  27. /* Backwards compatibility version */
  28. struct loop_info {
  29. int lo_number; /* ioctl r/o */
  30. __kernel_old_dev_t lo_device; /* ioctl r/o */
  31. unsigned long lo_inode; /* ioctl r/o */
  32. __kernel_old_dev_t lo_rdevice; /* ioctl r/o */
  33. int lo_offset;
  34. int lo_encrypt_type; /* obsolete, ignored */
  35. int lo_encrypt_key_size; /* ioctl w/o */
  36. int lo_flags;
  37. char lo_name[LO_NAME_SIZE];
  38. unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
  39. unsigned long lo_init[2];
  40. char reserved[4];
  41. };
  42. struct loop_info64 {
  43. __u64 lo_device; /* ioctl r/o */
  44. __u64 lo_inode; /* ioctl r/o */
  45. __u64 lo_rdevice; /* ioctl r/o */
  46. __u64 lo_offset;
  47. __u64 lo_sizelimit;/* bytes, 0 == max available */
  48. __u32 lo_number; /* ioctl r/o */
  49. __u32 lo_encrypt_type; /* obsolete, ignored */
  50. __u32 lo_encrypt_key_size; /* ioctl w/o */
  51. __u32 lo_flags;
  52. __u8 lo_file_name[LO_NAME_SIZE];
  53. __u8 lo_crypt_name[LO_NAME_SIZE];
  54. __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
  55. __u64 lo_init[2];
  56. };
  57. /**
  58. * struct loop_config - Complete configuration for a loop device.
  59. * @fd: fd of the file to be used as a backing file for the loop device.
  60. * @block_size: block size to use; ignored if 0.
  61. * @info: struct loop_info64 to configure the loop device with.
  62. *
  63. * This structure is used with the LOOP_CONFIGURE ioctl, and can be used to
  64. * atomically setup and configure all loop device parameters at once.
  65. */
  66. struct loop_config {
  67. __u32 fd;
  68. __u32 block_size;
  69. struct loop_info64 info;
  70. __u64 __reserved[8];
  71. };
  72. /*
  73. * Loop filter types
  74. */
  75. #define LO_CRYPT_NONE 0
  76. #define LO_CRYPT_XOR 1
  77. #define LO_CRYPT_DES 2
  78. #define LO_CRYPT_FISH2 3 /* Twofish encryption */
  79. #define LO_CRYPT_BLOW 4
  80. #define LO_CRYPT_CAST128 5
  81. #define LO_CRYPT_IDEA 6
  82. #define LO_CRYPT_DUMMY 9
  83. #define LO_CRYPT_SKIPJACK 10
  84. #define LO_CRYPT_CRYPTOAPI 18
  85. #define MAX_LO_CRYPT 20
  86. /*
  87. * IOCTL commands --- we will commandeer 0x4C ('L')
  88. */
  89. #define LOOP_SET_FD 0x4C00
  90. #define LOOP_CLR_FD 0x4C01
  91. #define LOOP_SET_STATUS 0x4C02
  92. #define LOOP_GET_STATUS 0x4C03
  93. #define LOOP_SET_STATUS64 0x4C04
  94. #define LOOP_GET_STATUS64 0x4C05
  95. #define LOOP_CHANGE_FD 0x4C06
  96. #define LOOP_SET_CAPACITY 0x4C07
  97. #define LOOP_SET_DIRECT_IO 0x4C08
  98. #define LOOP_SET_BLOCK_SIZE 0x4C09
  99. #define LOOP_CONFIGURE 0x4C0A
  100. /* /dev/loop-control interface */
  101. #define LOOP_CTL_ADD 0x4C80
  102. #define LOOP_CTL_REMOVE 0x4C81
  103. #define LOOP_CTL_GET_FREE 0x4C82
  104. #endif /* _UAPI_LINUX_LOOP_H */