2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* include/linux/loop.h
|
|
|
|
*
|
|
|
|
* Written by Theodore Ts'o, 3/29/93.
|
|
|
|
*
|
|
|
|
* Copyright 1993 by Theodore Ts'o. Redistribution of this file is
|
|
|
|
* permitted under the GNU General Public License.
|
|
|
|
*/
|
2012-10-13 17:46:48 +08:00
|
|
|
#ifndef _LINUX_LOOP_H
|
|
|
|
#define _LINUX_LOOP_H
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <linux/bio.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/spinlock.h>
|
2006-03-23 19:00:38 +08:00
|
|
|
#include <linux/mutex.h>
|
2012-10-13 17:46:48 +08:00
|
|
|
#include <uapi/linux/loop.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Possible states of device */
|
|
|
|
enum {
|
|
|
|
Lo_unbound,
|
|
|
|
Lo_bound,
|
|
|
|
Lo_rundown,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct loop_func_table;
|
|
|
|
|
|
|
|
struct loop_device {
|
|
|
|
int lo_number;
|
|
|
|
int lo_refcnt;
|
|
|
|
loff_t lo_offset;
|
|
|
|
loff_t lo_sizelimit;
|
|
|
|
int lo_flags;
|
|
|
|
int (*transfer)(struct loop_device *, int cmd,
|
|
|
|
struct page *raw_page, unsigned raw_off,
|
|
|
|
struct page *loop_page, unsigned loop_off,
|
|
|
|
int size, sector_t real_block);
|
|
|
|
char lo_file_name[LO_NAME_SIZE];
|
|
|
|
char lo_crypt_name[LO_NAME_SIZE];
|
|
|
|
char lo_encrypt_key[LO_KEY_SIZE];
|
|
|
|
int lo_encrypt_key_size;
|
|
|
|
struct loop_func_table *lo_encryption;
|
|
|
|
__u32 lo_init[2];
|
2012-02-12 03:23:51 +08:00
|
|
|
kuid_t lo_key_owner; /* Who set the key */
|
2005-04-17 06:20:36 +08:00
|
|
|
int (*ioctl)(struct loop_device *, int cmd,
|
|
|
|
unsigned long arg);
|
|
|
|
|
|
|
|
struct file * lo_backing_file;
|
|
|
|
struct block_device *lo_device;
|
|
|
|
unsigned lo_blocksize;
|
|
|
|
void *key_data;
|
|
|
|
|
2005-10-21 15:22:34 +08:00
|
|
|
gfp_t old_gfp_mask;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
spinlock_t lo_lock;
|
2009-04-17 14:41:21 +08:00
|
|
|
struct bio_list lo_bio_list;
|
2005-04-17 06:20:36 +08:00
|
|
|
int lo_state;
|
2006-03-23 19:00:38 +08:00
|
|
|
struct mutex lo_ctl_mutex;
|
2006-09-29 16:59:11 +08:00
|
|
|
struct task_struct *lo_thread;
|
|
|
|
wait_queue_head_t lo_event;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-07-24 09:44:00 +08:00
|
|
|
struct request_queue *lo_queue;
|
2007-05-08 15:28:20 +08:00
|
|
|
struct gendisk *lo_disk;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Support for loadable transfer modules */
|
|
|
|
struct loop_func_table {
|
|
|
|
int number; /* filter type */
|
|
|
|
int (*transfer)(struct loop_device *lo, int cmd,
|
|
|
|
struct page *raw_page, unsigned raw_off,
|
|
|
|
struct page *loop_page, unsigned loop_off,
|
|
|
|
int size, sector_t real_block);
|
|
|
|
int (*init)(struct loop_device *, const struct loop_info64 *);
|
|
|
|
/* release is called from loop_unregister_transfer or clr_fd */
|
|
|
|
int (*release)(struct loop_device *);
|
|
|
|
int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
|
|
|
|
struct module *owner;
|
|
|
|
};
|
|
|
|
|
|
|
|
int loop_register_transfer(struct loop_func_table *funcs);
|
|
|
|
int loop_unregister_transfer(int number);
|
|
|
|
|
|
|
|
#endif
|