Add latest ia64 patches.
[linux-flexiantxendom0-3.2.10.git] / include / linux / loop.h
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/blk.h>
19 #include <linux/spinlock.h>
20
21 /* Possible states of device */
22 enum {
23         Lo_unbound,
24         Lo_bound,
25         Lo_rundown,
26 };
27
28 struct loop_func_table;
29
30 struct loop_device {
31         int             lo_number;
32         int             lo_refcnt;
33         int             lo_offset;
34         int             lo_flags;
35         int             (*transfer)(struct loop_device *, int cmd,
36                                     char *raw_buf, char *loop_buf, int size,
37                                     sector_t real_block);
38         char            lo_name[LO_NAME_SIZE];
39         char            lo_encrypt_key[LO_KEY_SIZE];
40         int             lo_encrypt_key_size;
41         struct loop_func_table *lo_encryption;
42         __u32           lo_init[2];
43         uid_t           lo_key_owner;   /* Who set the key */
44         int             (*ioctl)(struct loop_device *, int cmd, 
45                                  unsigned long arg); 
46
47         struct file *   lo_backing_file;
48         struct block_device *lo_device;
49         unsigned        lo_blocksize;
50         void            *key_data; 
51         char            key_reserved[48]; /* for use by the filter modules */
52
53         int             old_gfp_mask;
54
55         spinlock_t              lo_lock;
56         struct bio              *lo_bio;
57         struct bio              *lo_biotail;
58         int                     lo_state;
59         struct semaphore        lo_sem;
60         struct semaphore        lo_ctl_mutex;
61         struct semaphore        lo_bh_mutex;
62         atomic_t                lo_pending;
63
64         request_queue_t         lo_queue;
65 };
66
67 typedef int (* transfer_proc_t)(struct loop_device *, int cmd,
68                                 char *raw_buf, char *loop_buf, int size,
69                                 int real_block);
70
71 #endif /* __KERNEL__ */
72
73 /*
74  * Loop flags
75  */
76 #define LO_FLAGS_DO_BMAP        1
77 #define LO_FLAGS_READ_ONLY      2
78
79 #include <asm/posix_types.h>    /* for __kernel_old_dev_t */
80 #include <asm/types.h>          /* for __u64 */
81
82 /* Backwards compatibility version */
83 struct loop_info {
84         int                lo_number;           /* ioctl r/o */
85         __kernel_old_dev_t lo_device;           /* ioctl r/o */
86         unsigned long      lo_inode;            /* ioctl r/o */
87         __kernel_old_dev_t lo_rdevice;          /* ioctl r/o */
88         int                lo_offset;
89         int                lo_encrypt_type;
90         int                lo_encrypt_key_size;         /* ioctl w/o */
91         int                lo_flags;                    /* ioctl r/o */
92         char               lo_name[LO_NAME_SIZE];
93         unsigned char      lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
94         unsigned long      lo_init[2];
95         char               reserved[4];
96 };
97
98 struct loop_info64 {
99         __u64              lo_device;           /* ioctl r/o */
100         __u64              lo_inode;            /* ioctl r/o */
101         __u64              lo_rdevice;          /* ioctl r/o */
102         __u64              lo_offset;
103         __u32              lo_number;           /* ioctl r/o */
104         __u32              lo_encrypt_type;
105         __u32              lo_encrypt_key_size;         /* ioctl w/o */
106         __u32              lo_flags;                    /* ioctl r/o */
107         __u8               lo_name[LO_NAME_SIZE];
108         __u8               lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
109         __u64              lo_init[2];
110 };
111
112 /*
113  * Loop filter types
114  */
115
116 #define LO_CRYPT_NONE     0
117 #define LO_CRYPT_XOR      1
118 #define LO_CRYPT_DES      2
119 #define LO_CRYPT_FISH2    3    /* Brand new Twofish encryption */
120 #define LO_CRYPT_BLOW     4
121 #define LO_CRYPT_CAST128  5
122 #define LO_CRYPT_IDEA     6
123 #define LO_CRYPT_DUMMY    9
124 #define LO_CRYPT_SKIPJACK 10
125 #define MAX_LO_CRYPT    20
126
127 #ifdef __KERNEL__
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, char *raw_buf,
132                         char *loop_buf, int size, sector_t real_block);
133         int (*init)(struct loop_device *, const struct loop_info64 *); 
134         /* release is called from loop_unregister_transfer or clr_fd */
135         int (*release)(struct loop_device *); 
136         int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
137         struct module *owner;
138 }; 
139
140 int loop_register_transfer(struct loop_func_table *funcs);
141 int loop_unregister_transfer(int number); 
142
143 #endif
144 /*
145  * IOCTL commands --- we will commandeer 0x4C ('L')
146  */
147
148 #define LOOP_SET_FD             0x4C00
149 #define LOOP_CLR_FD             0x4C01
150 #define LOOP_SET_STATUS         0x4C02
151 #define LOOP_GET_STATUS         0x4C03
152 #define LOOP_SET_STATUS64       0x4C04
153 #define LOOP_GET_STATUS64       0x4C05
154
155 #endif