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