loop: fastfs support
[linux-2.6-block.git] / include / linux / loop.h
CommitLineData
1da177e4
LT
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#ifdef __KERNEL__
17#include <linux/bio.h>
18#include <linux/blkdev.h>
19#include <linux/spinlock.h>
f85221dd 20#include <linux/mutex.h>
1da177e4
LT
21
22/* Possible states of device */
23enum {
24 Lo_unbound,
25 Lo_bound,
26 Lo_rundown,
27};
28
29struct loop_func_table;
30
31struct loop_device {
32 int lo_number;
33 int lo_refcnt;
34 loff_t lo_offset;
35 loff_t lo_sizelimit;
36 int lo_flags;
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;
46 __u32 lo_init[2];
47 uid_t lo_key_owner; /* Who set the key */
48 int (*ioctl)(struct loop_device *, int cmd,
49 unsigned long arg);
50
51 struct file * lo_backing_file;
52 struct block_device *lo_device;
e85a418c 53 struct block_device *fs_bdev;
1da177e4
LT
54 unsigned lo_blocksize;
55 void *key_data;
e85a418c 56 unsigned int lo_switch;
1da177e4 57
b4e3ca1a 58 gfp_t old_gfp_mask;
1da177e4
LT
59
60 spinlock_t lo_lock;
61 struct bio *lo_bio;
62 struct bio *lo_biotail;
e85a418c 63 unsigned int lo_bio_cnt;
1da177e4 64 int lo_state;
f85221dd 65 struct mutex lo_ctl_mutex;
6c997918
SH
66 struct task_struct *lo_thread;
67 wait_queue_head_t lo_event;
e85a418c
JA
68 wait_queue_head_t lo_bio_wait;
69 struct timer_list lo_bio_timer;
1da177e4 70
01e457cf 71 struct request_queue *lo_queue;
73285082
KC
72 struct gendisk *lo_disk;
73 struct list_head lo_list;
e85a418c
JA
74
75 unsigned int blkbits;
1da177e4
LT
76};
77
78#endif /* __KERNEL__ */
79
80/*
81 * Loop flags
82 */
83enum {
84 LO_FLAGS_READ_ONLY = 1,
85 LO_FLAGS_USE_AOPS = 2,
96c58655 86 LO_FLAGS_AUTOCLEAR = 4,
e85a418c 87 LO_FLAGS_FASTFS = 8,
1da177e4
LT
88};
89
90#include <asm/posix_types.h> /* for __kernel_old_dev_t */
00bfddaf 91#include <linux/types.h> /* for __u64 */
1da177e4
LT
92
93/* Backwards compatibility version */
94struct loop_info {
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 */
99 int lo_offset;
100 int lo_encrypt_type;
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];
106 char reserved[4];
107};
108
109struct loop_info64 {
110 __u64 lo_device; /* ioctl r/o */
111 __u64 lo_inode; /* ioctl r/o */
112 __u64 lo_rdevice; /* ioctl r/o */
113 __u64 lo_offset;
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 */
122 __u64 lo_init[2];
123};
124
125/*
126 * Loop filter types
127 */
128
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
140
141#ifdef __KERNEL__
142/* Support for loadable transfer modules */
143struct 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;
154};
155
156int loop_register_transfer(struct loop_func_table *funcs);
157int loop_unregister_transfer(int number);
158
159#endif
160/*
161 * IOCTL commands --- we will commandeer 0x4C ('L')
162 */
163
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
e85a418c
JA
171#define LOOP_SET_FASTFS 0x4C07
172
173enum {
174 LOOP_EXTENT_RW_MAGIC = 0x19283744,
175 LOOP_SWITCH_RW_MAGIC = 0xfeedbeec,
176};
1da177e4
LT
177
178#endif