4 #include <linux/kdev_t.h>
9 * Written by Theodore Ts'o, 3/29/93.
11 * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
12 * permitted under the GNU General Public License.
15 #define LO_NAME_SIZE 64
16 #define LO_KEY_SIZE 32
20 /* Possible states of device */
33 int lo_encrypt_key_size;
35 int (*transfer)(struct loop_device *, int cmd,
36 char *raw_buf, char *loop_buf, int size,
38 char lo_name[LO_NAME_SIZE];
39 char lo_encrypt_key[LO_KEY_SIZE];
41 uid_t lo_key_owner; /* Who set the key */
42 int (*ioctl)(struct loop_device *, int cmd,
45 struct file * lo_backing_file;
47 char key_reserved[48]; /* for use by the filter modules */
52 struct buffer_head *lo_bh;
53 struct buffer_head *lo_bhtail;
55 struct semaphore lo_sem;
56 struct semaphore lo_ctl_mutex;
57 struct semaphore lo_bh_mutex;
61 typedef int (* transfer_proc_t)(struct loop_device *, int cmd,
62 char *raw_buf, char *loop_buf, int size,
65 static inline int lo_do_transfer(struct loop_device *lo, int cmd, char *rbuf,
66 char *lbuf, int size, int rblock)
71 return lo->transfer(lo, cmd, rbuf, lbuf, size, rblock);
73 #endif /* __KERNEL__ */
78 #define LO_FLAGS_DO_BMAP 1
79 #define LO_FLAGS_READ_ONLY 2
80 #define LO_FLAGS_BH_REMAP 4
83 * Note that this structure gets the wrong offsets when directly used
84 * from a glibc program, because glibc has a 32bit dev_t.
85 * Prevent people from shooting in their own foot.
87 #if __GLIBC__ >= 2 && !defined(dev_t)
88 #error "Wrong dev_t in loop.h"
92 * This uses kdev_t because glibc currently has no appropiate
93 * conversion version for the loop ioctls.
94 * The situation is very unpleasant
98 int lo_number; /* ioctl r/o */
99 dev_t lo_device; /* ioctl r/o */
100 unsigned long lo_inode; /* ioctl r/o */
101 dev_t lo_rdevice; /* ioctl r/o */
104 int lo_encrypt_key_size; /* ioctl w/o */
105 int lo_flags; /* ioctl r/o */
106 char lo_name[LO_NAME_SIZE];
107 unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
108 unsigned long lo_init[2];
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
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, int real_block);
133 int (*init)(struct loop_device *, struct loop_info *);
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 /* lock and unlock manage the module use counts */
138 void (*lock)(struct loop_device *);
139 void (*unlock)(struct loop_device *);
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