xref: /qemu/linux-user/linux_loop.h (revision 175de524)
1 /* Copied from 2.6.25 kernel headers to avoid problems on older hosts.  */
2 
3 #ifndef LINUX_LOOP_H
4 #define LINUX_LOOP_H
5 
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 
15 #define LO_NAME_SIZE	64
16 #define LO_KEY_SIZE	32
17 
18 
19 /*
20  * Loop flags
21  */
22 enum {
23 	LO_FLAGS_READ_ONLY	= 1,
24 	LO_FLAGS_USE_AOPS	= 2,
25 	LO_FLAGS_AUTOCLEAR	= 4,
26 };
27 
28 #include <linux/version.h>
29 #include <asm/posix_types.h>	/* for __kernel_old_dev_t */
30 #include <asm/types.h>		/* for __u64 */
31 
32 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) /* This is a guess.  */
33 #define __kernel_old_dev_t __kernel_dev_t
34 #endif
35 
36 /* Backwards compatibility version */
37 struct loop_info {
38 	int		   lo_number;		/* ioctl r/o */
39 	__kernel_old_dev_t lo_device; 		/* ioctl r/o */
40 	unsigned long	   lo_inode; 		/* ioctl r/o */
41 	__kernel_old_dev_t lo_rdevice; 		/* ioctl r/o */
42 	int		   lo_offset;
43 	int		   lo_encrypt_type;
44 	int		   lo_encrypt_key_size; 	/* ioctl w/o */
45 	int		   lo_flags;			/* ioctl r/o */
46 	char		   lo_name[LO_NAME_SIZE];
47 	unsigned char	   lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
48 	unsigned long	   lo_init[2];
49 	char		   reserved[4];
50 };
51 
52 struct loop_info64 {
53 	__u64		   lo_device;			/* ioctl r/o */
54 	__u64		   lo_inode;			/* ioctl r/o */
55 	__u64		   lo_rdevice;			/* ioctl r/o */
56 	__u64		   lo_offset;
57 	__u64		   lo_sizelimit;/* bytes, 0 == max available */
58 	__u32		   lo_number;			/* ioctl r/o */
59 	__u32		   lo_encrypt_type;
60 	__u32		   lo_encrypt_key_size;		/* ioctl w/o */
61 	__u32		   lo_flags;			/* ioctl r/o */
62 	__u8		   lo_file_name[LO_NAME_SIZE];
63 	__u8		   lo_crypt_name[LO_NAME_SIZE];
64 	__u8		   lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
65 	__u64		   lo_init[2];
66 };
67 
68 /*
69  * Loop filter types
70  */
71 
72 #define LO_CRYPT_NONE		0
73 #define LO_CRYPT_XOR		1
74 #define LO_CRYPT_DES		2
75 #define LO_CRYPT_FISH2		3    /* Twofish encryption */
76 #define LO_CRYPT_BLOW		4
77 #define LO_CRYPT_CAST128	5
78 #define LO_CRYPT_IDEA		6
79 #define LO_CRYPT_DUMMY		9
80 #define LO_CRYPT_SKIPJACK	10
81 #define LO_CRYPT_CRYPTOAPI	18
82 #define MAX_LO_CRYPT		20
83 
84 /*
85  * IOCTL commands --- we will commandeer 0x4C ('L')
86  */
87 
88 #define LOOP_SET_FD		0x4C00
89 #define LOOP_CLR_FD		0x4C01
90 #define LOOP_SET_STATUS		0x4C02
91 #define LOOP_GET_STATUS		0x4C03
92 #define LOOP_SET_STATUS64	0x4C04
93 #define LOOP_GET_STATUS64	0x4C05
94 #define LOOP_CHANGE_FD		0x4C06
95 
96 #endif
97