7 * Written by Theodore Ts'o, 3/29/93.
9 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
10 * permitted under the GNU General Public License.
13 #define LO_NAME_SIZE 64
14 #define LO_KEY_SIZE 32
17 #include <linux/bio.h>
18 #include <linux/blkdev.h>
19 #include <linux/spinlock.h>
21 /* Possible states of device */
28 struct loop_func_table;
36 int (*transfer)(struct loop_device *, int cmd,
37 struct page *raw_page, unsigned raw_off,
38 struct page *loop_page, unsigned loop_off,
39 int size, sector_t real_block);
40 char lo_file_name[LO_NAME_SIZE];
41 char lo_crypt_name[LO_NAME_SIZE];
42 char lo_encrypt_key[LO_KEY_SIZE];
43 int lo_encrypt_key_size;
44 struct loop_func_table *lo_encryption;
46 uid_t lo_key_owner; /* Who set the key */
47 int (*ioctl)(struct loop_device *, int cmd,
50 struct file * lo_backing_file;
51 struct block_device *lo_device;
52 unsigned lo_blocksize;
59 struct bio *lo_biotail;
61 struct semaphore lo_sem;
62 struct semaphore lo_ctl_mutex;
63 struct semaphore lo_bh_mutex;
66 request_queue_t *lo_queue;
69 #endif /* __KERNEL__ */
74 #define LO_FLAGS_READ_ONLY 1
76 #include <asm/posix_types.h> /* for __kernel_old_dev_t */
77 #include <asm/types.h> /* for __u64 */
79 /* Backwards compatibility version */
81 int lo_number; /* ioctl r/o */
82 __kernel_old_dev_t lo_device; /* ioctl r/o */
83 unsigned long lo_inode; /* ioctl r/o */
84 __kernel_old_dev_t lo_rdevice; /* ioctl r/o */
87 int lo_encrypt_key_size; /* ioctl w/o */
88 int lo_flags; /* ioctl r/o */
89 char lo_name[LO_NAME_SIZE];
90 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
91 unsigned long lo_init[2];
96 __u64 lo_device; /* ioctl r/o */
97 __u64 lo_inode; /* ioctl r/o */
98 __u64 lo_rdevice; /* ioctl r/o */
100 __u64 lo_sizelimit;/* bytes, 0 == max available */
101 __u32 lo_number; /* ioctl r/o */
102 __u32 lo_encrypt_type;
103 __u32 lo_encrypt_key_size; /* ioctl w/o */
104 __u32 lo_flags; /* ioctl r/o */
105 __u8 lo_file_name[LO_NAME_SIZE];
106 __u8 lo_crypt_name[LO_NAME_SIZE];
107 __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
115 #define LO_CRYPT_NONE 0
116 #define LO_CRYPT_XOR 1
117 #define LO_CRYPT_DES 2
118 #define LO_CRYPT_FISH2 3 /* Twofish encryption */
119 #define LO_CRYPT_BLOW 4
120 #define LO_CRYPT_CAST128 5
121 #define LO_CRYPT_IDEA 6
122 #define LO_CRYPT_DUMMY 9
123 #define LO_CRYPT_SKIPJACK 10
124 #define LO_CRYPT_CRYPTOAPI 18
125 #define MAX_LO_CRYPT 20
128 /* Support for loadable transfer modules */
129 struct loop_func_table {
130 int number; /* filter type */
131 int (*transfer)(struct loop_device *lo, int cmd,
132 struct page *raw_page, unsigned raw_off,
133 struct page *loop_page, unsigned loop_off,
134 int size, sector_t real_block);
135 int (*init)(struct loop_device *, const struct loop_info64 *);
136 /* release is called from loop_unregister_transfer or clr_fd */
137 int (*release)(struct loop_device *);
138 int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
139 struct module *owner;
142 int loop_register_transfer(struct loop_func_table *funcs);
143 int loop_unregister_transfer(int number);
147 * IOCTL commands --- we will commandeer 0x4C ('L')
150 #define LOOP_SET_FD 0x4C00
151 #define LOOP_CLR_FD 0x4C01
152 #define LOOP_SET_STATUS 0x4C02
153 #define LOOP_GET_STATUS 0x4C03
154 #define LOOP_SET_STATUS64 0x4C04
155 #define LOOP_GET_STATUS64 0x4C05
156 #define LOOP_CHANGE_FD 0x4C06