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>
20 #include <linux/mutex.h>
22 /* Possible states of device */
29 struct loop_func_table;
37 int (*transfer)(struct loop_device *, int cmd,
38 struct page *raw_page, unsigned raw_off,
39 struct page *loop_page, unsigned loop_off,
40 int size, sector_t real_block);
41 char lo_file_name[LO_NAME_SIZE];
42 char lo_crypt_name[LO_NAME_SIZE];
43 char lo_encrypt_key[LO_KEY_SIZE];
44 int lo_encrypt_key_size;
45 struct loop_func_table *lo_encryption;
47 uid_t lo_key_owner; /* Who set the key */
48 int (*ioctl)(struct loop_device *, int cmd,
51 struct file * lo_backing_file;
52 struct block_device *lo_device;
53 struct block_device *fs_bdev;
54 unsigned lo_blocksize;
56 unsigned int lo_switch;
62 struct bio *lo_biotail;
63 unsigned int lo_bio_cnt;
65 struct mutex lo_ctl_mutex;
66 struct task_struct *lo_thread;
67 wait_queue_head_t lo_event;
68 wait_queue_head_t lo_bio_wait;
69 struct timer_list lo_bio_timer;
71 struct request_queue *lo_queue;
72 struct gendisk *lo_disk;
73 struct list_head lo_list;
78 #endif /* __KERNEL__ */
84 LO_FLAGS_READ_ONLY = 1,
85 LO_FLAGS_USE_AOPS = 2,
86 LO_FLAGS_AUTOCLEAR = 4,
90 #include <asm/posix_types.h> /* for __kernel_old_dev_t */
91 #include <linux/types.h> /* for __u64 */
93 /* Backwards compatibility version */
95 int lo_number; /* ioctl r/o */
96 __kernel_old_dev_t lo_device; /* ioctl r/o */
97 unsigned long lo_inode; /* ioctl r/o */
98 __kernel_old_dev_t lo_rdevice; /* ioctl r/o */
101 int lo_encrypt_key_size; /* ioctl w/o */
102 int lo_flags; /* ioctl r/o */
103 char lo_name[LO_NAME_SIZE];
104 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
105 unsigned long lo_init[2];
110 __u64 lo_device; /* ioctl r/o */
111 __u64 lo_inode; /* ioctl r/o */
112 __u64 lo_rdevice; /* ioctl r/o */
114 __u64 lo_sizelimit;/* bytes, 0 == max available */
115 __u32 lo_number; /* ioctl r/o */
116 __u32 lo_encrypt_type;
117 __u32 lo_encrypt_key_size; /* ioctl w/o */
118 __u32 lo_flags; /* ioctl r/o */
119 __u8 lo_file_name[LO_NAME_SIZE];
120 __u8 lo_crypt_name[LO_NAME_SIZE];
121 __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
129 #define LO_CRYPT_NONE 0
130 #define LO_CRYPT_XOR 1
131 #define LO_CRYPT_DES 2
132 #define LO_CRYPT_FISH2 3 /* Twofish encryption */
133 #define LO_CRYPT_BLOW 4
134 #define LO_CRYPT_CAST128 5
135 #define LO_CRYPT_IDEA 6
136 #define LO_CRYPT_DUMMY 9
137 #define LO_CRYPT_SKIPJACK 10
138 #define LO_CRYPT_CRYPTOAPI 18
139 #define MAX_LO_CRYPT 20
142 /* Support for loadable transfer modules */
143 struct loop_func_table {
144 int number; /* filter type */
145 int (*transfer)(struct loop_device *lo, int cmd,
146 struct page *raw_page, unsigned raw_off,
147 struct page *loop_page, unsigned loop_off,
148 int size, sector_t real_block);
149 int (*init)(struct loop_device *, const struct loop_info64 *);
150 /* release is called from loop_unregister_transfer or clr_fd */
151 int (*release)(struct loop_device *);
152 int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
153 struct module *owner;
156 int loop_register_transfer(struct loop_func_table *funcs);
157 int loop_unregister_transfer(int number);
161 * IOCTL commands --- we will commandeer 0x4C ('L')
164 #define LOOP_SET_FD 0x4C00
165 #define LOOP_CLR_FD 0x4C01
166 #define LOOP_SET_STATUS 0x4C02
167 #define LOOP_GET_STATUS 0x4C03
168 #define LOOP_SET_STATUS64 0x4C04
169 #define LOOP_GET_STATUS64 0x4C05
170 #define LOOP_CHANGE_FD 0x4C06
171 #define LOOP_SET_FASTFS 0x4C07
174 LOOP_EXTENT_RW_MAGIC = 0x19283744,
175 LOOP_SWITCH_RW_MAGIC = 0xfeedbeec,