1 /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
5 * Written by Theodore Ts'o, 3/29/93.
7 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
8 * permitted under the GNU General Public License.
10 #ifndef _UAPI_LINUX_LOOP_H
11 #define _UAPI_LINUX_LOOP_H
14 #define LO_NAME_SIZE 64
15 #define LO_KEY_SIZE 32
22 LO_FLAGS_READ_ONLY = 1,
23 LO_FLAGS_AUTOCLEAR = 4,
24 LO_FLAGS_PARTSCAN = 8,
25 LO_FLAGS_DIRECT_IO = 16,
28 /* LO_FLAGS that can be set using LOOP_SET_STATUS(64) */
29 #define LOOP_SET_STATUS_SETTABLE_FLAGS (LO_FLAGS_AUTOCLEAR | LO_FLAGS_PARTSCAN)
31 /* LO_FLAGS that can be cleared using LOOP_SET_STATUS(64) */
32 #define LOOP_SET_STATUS_CLEARABLE_FLAGS (LO_FLAGS_AUTOCLEAR)
34 /* LO_FLAGS that can be set using LOOP_CONFIGURE */
35 #define LOOP_CONFIGURE_SETTABLE_FLAGS (LO_FLAGS_READ_ONLY | LO_FLAGS_AUTOCLEAR \
36 | LO_FLAGS_PARTSCAN | LO_FLAGS_DIRECT_IO)
38 #include <asm/posix_types.h> /* for __kernel_old_dev_t */
39 #include <linux/types.h> /* for __u64 */
41 /* Backwards compatibility version */
43 int lo_number; /* ioctl r/o */
44 __kernel_old_dev_t lo_device; /* ioctl r/o */
45 unsigned long lo_inode; /* ioctl r/o */
46 __kernel_old_dev_t lo_rdevice; /* ioctl r/o */
48 int lo_encrypt_type; /* obsolete, ignored */
49 int lo_encrypt_key_size; /* ioctl w/o */
51 char lo_name[LO_NAME_SIZE];
52 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
53 unsigned long lo_init[2];
58 __u64 lo_device; /* ioctl r/o */
59 __u64 lo_inode; /* ioctl r/o */
60 __u64 lo_rdevice; /* ioctl r/o */
62 __u64 lo_sizelimit;/* bytes, 0 == max available */
63 __u32 lo_number; /* ioctl r/o */
64 __u32 lo_encrypt_type; /* obsolete, ignored */
65 __u32 lo_encrypt_key_size; /* ioctl w/o */
67 __u8 lo_file_name[LO_NAME_SIZE];
68 __u8 lo_crypt_name[LO_NAME_SIZE];
69 __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
74 * struct loop_config - Complete configuration for a loop device.
75 * @fd: fd of the file to be used as a backing file for the loop device.
76 * @block_size: block size to use; ignored if 0.
77 * @info: struct loop_info64 to configure the loop device with.
79 * This structure is used with the LOOP_CONFIGURE ioctl, and can be used to
80 * atomically setup and configure all loop device parameters at once.
85 struct loop_info64 info;
93 #define LO_CRYPT_NONE 0
94 #define LO_CRYPT_XOR 1
95 #define LO_CRYPT_DES 2
96 #define LO_CRYPT_FISH2 3 /* Twofish encryption */
97 #define LO_CRYPT_BLOW 4
98 #define LO_CRYPT_CAST128 5
99 #define LO_CRYPT_IDEA 6
100 #define LO_CRYPT_DUMMY 9
101 #define LO_CRYPT_SKIPJACK 10
102 #define LO_CRYPT_CRYPTOAPI 18
103 #define MAX_LO_CRYPT 20
106 * IOCTL commands --- we will commandeer 0x4C ('L')
109 #define LOOP_SET_FD 0x4C00
110 #define LOOP_CLR_FD 0x4C01
111 #define LOOP_SET_STATUS 0x4C02
112 #define LOOP_GET_STATUS 0x4C03
113 #define LOOP_SET_STATUS64 0x4C04
114 #define LOOP_GET_STATUS64 0x4C05
115 #define LOOP_CHANGE_FD 0x4C06
116 #define LOOP_SET_CAPACITY 0x4C07
117 #define LOOP_SET_DIRECT_IO 0x4C08
118 #define LOOP_SET_BLOCK_SIZE 0x4C09
119 #define LOOP_CONFIGURE 0x4C0A
121 /* /dev/loop-control interface */
122 #define LOOP_CTL_ADD 0x4C80
123 #define LOOP_CTL_REMOVE 0x4C81
124 #define LOOP_CTL_GET_FREE 0x4C82
125 #endif /* _UAPI_LINUX_LOOP_H */