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 unsigned lo_blocksize
;
59 struct bio_list lo_bio_list
;
61 struct mutex lo_ctl_mutex
;
62 struct task_struct
*lo_thread
;
63 wait_queue_head_t lo_event
;
65 struct request_queue
*lo_queue
;
66 struct gendisk
*lo_disk
;
67 struct list_head lo_list
;
70 #endif /* __KERNEL__ */
76 LO_FLAGS_READ_ONLY
= 1,
77 LO_FLAGS_USE_AOPS
= 2,
78 LO_FLAGS_AUTOCLEAR
= 4,
81 #include <asm/posix_types.h> /* for __kernel_old_dev_t */
82 #include <linux/types.h> /* for __u64 */
84 /* Backwards compatibility version */
86 int lo_number
; /* ioctl r/o */
87 __kernel_old_dev_t lo_device
; /* ioctl r/o */
88 unsigned long lo_inode
; /* ioctl r/o */
89 __kernel_old_dev_t lo_rdevice
; /* ioctl r/o */
92 int lo_encrypt_key_size
; /* ioctl w/o */
93 int lo_flags
; /* ioctl r/o */
94 char lo_name
[LO_NAME_SIZE
];
95 unsigned char lo_encrypt_key
[LO_KEY_SIZE
]; /* ioctl w/o */
96 unsigned long lo_init
[2];
101 __u64 lo_device
; /* ioctl r/o */
102 __u64 lo_inode
; /* ioctl r/o */
103 __u64 lo_rdevice
; /* ioctl r/o */
105 __u64 lo_sizelimit
;/* bytes, 0 == max available */
106 __u32 lo_number
; /* ioctl r/o */
107 __u32 lo_encrypt_type
;
108 __u32 lo_encrypt_key_size
; /* ioctl w/o */
109 __u32 lo_flags
; /* ioctl r/o */
110 __u8 lo_file_name
[LO_NAME_SIZE
];
111 __u8 lo_crypt_name
[LO_NAME_SIZE
];
112 __u8 lo_encrypt_key
[LO_KEY_SIZE
]; /* ioctl w/o */
120 #define LO_CRYPT_NONE 0
121 #define LO_CRYPT_XOR 1
122 #define LO_CRYPT_DES 2
123 #define LO_CRYPT_FISH2 3 /* Twofish encryption */
124 #define LO_CRYPT_BLOW 4
125 #define LO_CRYPT_CAST128 5
126 #define LO_CRYPT_IDEA 6
127 #define LO_CRYPT_DUMMY 9
128 #define LO_CRYPT_SKIPJACK 10
129 #define LO_CRYPT_CRYPTOAPI 18
130 #define MAX_LO_CRYPT 20
133 /* Support for loadable transfer modules */
134 struct loop_func_table
{
135 int number
; /* filter type */
136 int (*transfer
)(struct loop_device
*lo
, int cmd
,
137 struct page
*raw_page
, unsigned raw_off
,
138 struct page
*loop_page
, unsigned loop_off
,
139 int size
, sector_t real_block
);
140 int (*init
)(struct loop_device
*, const struct loop_info64
*);
141 /* release is called from loop_unregister_transfer or clr_fd */
142 int (*release
)(struct loop_device
*);
143 int (*ioctl
)(struct loop_device
*, int cmd
, unsigned long arg
);
144 struct module
*owner
;
147 int loop_register_transfer(struct loop_func_table
*funcs
);
148 int loop_unregister_transfer(int number
);
152 * IOCTL commands --- we will commandeer 0x4C ('L')
155 #define LOOP_SET_FD 0x4C00
156 #define LOOP_CLR_FD 0x4C01
157 #define LOOP_SET_STATUS 0x4C02
158 #define LOOP_GET_STATUS 0x4C03
159 #define LOOP_SET_STATUS64 0x4C04
160 #define LOOP_GET_STATUS64 0x4C05
161 #define LOOP_CHANGE_FD 0x4C06
162 #define LOOP_SET_CAPACITY 0x4C07