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