xref: /linux-6.15/include/uapi/linux/loop.h (revision faf1d254)
1 /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
2 /*
3  * include/linux/loop.h
4  *
5  * Written by Theodore Ts'o, 3/29/93.
6  *
7  * Copyright 1993 by Theodore Ts'o.  Redistribution of this file is
8  * permitted under the GNU General Public License.
9  */
10 #ifndef _UAPI_LINUX_LOOP_H
11 #define _UAPI_LINUX_LOOP_H
12 
13 
14 #define LO_NAME_SIZE	64
15 #define LO_KEY_SIZE	32
16 
17 
18 /*
19  * Loop flags
20  */
21 enum {
22 	LO_FLAGS_READ_ONLY	= 1,
23 	LO_FLAGS_AUTOCLEAR	= 4,
24 	LO_FLAGS_PARTSCAN	= 8,
25 	LO_FLAGS_DIRECT_IO	= 16,
26 };
27 
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)
30 
31 /* LO_FLAGS that can be cleared using LOOP_SET_STATUS(64) */
32 #define LOOP_SET_STATUS_CLEARABLE_FLAGS (LO_FLAGS_AUTOCLEAR)
33 
34 #include <asm/posix_types.h>	/* for __kernel_old_dev_t */
35 #include <linux/types.h>	/* for __u64 */
36 
37 /* Backwards compatibility version */
38 struct loop_info {
39 	int		   lo_number;		/* ioctl r/o */
40 	__kernel_old_dev_t lo_device; 		/* ioctl r/o */
41 	unsigned long	   lo_inode; 		/* ioctl r/o */
42 	__kernel_old_dev_t lo_rdevice; 		/* ioctl r/o */
43 	int		   lo_offset;
44 	int		   lo_encrypt_type;
45 	int		   lo_encrypt_key_size; 	/* ioctl w/o */
46 	int		   lo_flags;
47 	char		   lo_name[LO_NAME_SIZE];
48 	unsigned char	   lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
49 	unsigned long	   lo_init[2];
50 	char		   reserved[4];
51 };
52 
53 struct loop_info64 {
54 	__u64		   lo_device;			/* ioctl r/o */
55 	__u64		   lo_inode;			/* ioctl r/o */
56 	__u64		   lo_rdevice;			/* ioctl r/o */
57 	__u64		   lo_offset;
58 	__u64		   lo_sizelimit;/* bytes, 0 == max available */
59 	__u32		   lo_number;			/* ioctl r/o */
60 	__u32		   lo_encrypt_type;
61 	__u32		   lo_encrypt_key_size;		/* ioctl w/o */
62 	__u32		   lo_flags;
63 	__u8		   lo_file_name[LO_NAME_SIZE];
64 	__u8		   lo_crypt_name[LO_NAME_SIZE];
65 	__u8		   lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
66 	__u64		   lo_init[2];
67 };
68 
69 /*
70  * Loop filter types
71  */
72 
73 #define LO_CRYPT_NONE		0
74 #define LO_CRYPT_XOR		1
75 #define LO_CRYPT_DES		2
76 #define LO_CRYPT_FISH2		3    /* Twofish encryption */
77 #define LO_CRYPT_BLOW		4
78 #define LO_CRYPT_CAST128	5
79 #define LO_CRYPT_IDEA		6
80 #define LO_CRYPT_DUMMY		9
81 #define LO_CRYPT_SKIPJACK	10
82 #define LO_CRYPT_CRYPTOAPI	18
83 #define MAX_LO_CRYPT		20
84 
85 /*
86  * IOCTL commands --- we will commandeer 0x4C ('L')
87  */
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 
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 */
105