diff options
Diffstat (limited to 'loop_main.h')
-rw-r--r-- | loop_main.h | 120 |
1 files changed, 41 insertions, 79 deletions
diff --git a/loop_main.h b/loop_main.h index eec7ceb..1b5851a 100644 --- a/loop_main.h +++ b/loop_main.h @@ -6,8 +6,8 @@ * Copyright 1993 by Theodore Ts'o. Redistribution of this file is * permitted under the GNU General Public License. */ -#ifndef _LINUX_LOOP_H -#define _LINUX_LOOP_H +#ifndef _LINUX_XLOOP_H +#define _LINUX_XLOOP_H #include <linux/bio.h> #include <linux/blkdev.h> @@ -15,105 +15,67 @@ #include <linux/spinlock.h> #include <linux/mutex.h> #include <linux/kthread.h> -#include <uapi/linux/loop.h> - +#include "uapi/linux/loop.h" #ifdef CONFIG_DEBUG_FS #include <linux/debugfs.h> #endif #include "loop_file_fmt.h" -// See: https://www.kernel.org/doc/Documentation/admin-guide/devices.txt -#define XLOOP_MAJOR 120 -#define XLOOP_CTRL_MINOR 142 - /* Possible states of device */ enum { - Lo_unbound, - Lo_bound, - Lo_rundown, -}; - -struct loop_func_table; - -struct xloop_info { - int lo_number; /* ioctl r/o */ - __kernel_old_dev_t lo_device; /* ioctl r/o */ - unsigned long lo_inode; /* ioctl r/o */ - __kernel_old_dev_t lo_rdevice; /* ioctl r/o */ - int lo_offset; - int lo_encrypt_type; - int lo_encrypt_key_size; /* ioctl w/o */ - int lo_flags; /* ioctl r/o */ - char lo_name[LO_NAME_SIZE]; - unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ - unsigned long lo_init[2]; - char reserved[4]; - int lo_file_fmt_type; + Xlo_unbound, + Xlo_bound, + Xlo_rundown, }; -struct xloop_info64 { - __u64 lo_device; /* ioctl r/o */ - __u64 lo_inode; /* ioctl r/o */ - __u64 lo_rdevice; /* ioctl r/o */ - __u64 lo_offset; - __u64 lo_sizelimit;/* bytes, 0 == max available */ - __u32 lo_number; /* ioctl r/o */ - __u32 lo_encrypt_type; - __u32 lo_encrypt_key_size; /* ioctl w/o */ - __u32 lo_flags; /* ioctl r/o */ - __u8 lo_file_name[LO_NAME_SIZE]; - __u8 lo_crypt_name[LO_NAME_SIZE]; - __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ - __u64 lo_init[2]; - __u32 lo_file_fmt_type; -} __attribute__((packed)); +struct xloop_func_table; -struct loop_device { - int lo_number; - atomic_t lo_refcnt; - loff_t lo_offset; - loff_t lo_sizelimit; - int lo_flags; - int (*transfer)(struct loop_device *, int cmd, +struct xloop_device { + int xlo_number; + atomic_t xlo_refcnt; + loff_t xlo_offset; + loff_t xlo_sizelimit; + int xlo_flags; + int (*transfer)(struct xloop_device *, int cmd, struct page *raw_page, unsigned raw_off, - struct page *loop_page, unsigned loop_off, + struct page *xloop_page, unsigned xloop_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]; - kuid_t lo_key_owner; /* Who set the key */ - int (*ioctl)(struct loop_device *, int cmd, + char xlo_file_name[XLO_NAME_SIZE]; + char xlo_crypt_name[XLO_NAME_SIZE]; + char xlo_encrypt_key[XLO_KEY_SIZE]; + int xlo_encrypt_key_size; + struct xloop_func_table *xlo_encryption; + __u32 xlo_init[2]; + kuid_t xlo_key_owner; /* Who set the key */ + int (*ioctl)(struct xloop_device *, int cmd, unsigned long arg); - struct loop_file_fmt *lo_fmt; + struct xloop_file_fmt *xlo_fmt; - struct file * lo_backing_file; - struct block_device *lo_device; + struct file * xlo_backing_file; + struct block_device *xlo_device; void *key_data; gfp_t old_gfp_mask; - spinlock_t lo_lock; - int lo_state; + spinlock_t xlo_lock; + int xlo_state; struct kthread_worker worker; struct task_struct *worker_task; bool use_dio; bool sysfs_inited; - struct request_queue *lo_queue; + struct request_queue *xlo_queue; struct blk_mq_tag_set tag_set; - struct gendisk *lo_disk; + struct gendisk *xlo_disk; #ifdef CONFIG_DEBUG_FS - struct dentry *lo_dbgfs_dir; + struct dentry *xlo_dbgfs_dir; #endif }; -struct loop_cmd { +struct xloop_cmd { struct kthread_work work; bool use_aio; /* use AIO interface to handle I/O */ atomic_t ref; /* only for aio */ @@ -124,20 +86,20 @@ struct loop_cmd { }; /* Support for loadable transfer modules */ -struct loop_func_table { +struct xloop_func_table { int number; /* filter type */ - int (*transfer)(struct loop_device *lo, int cmd, + int (*transfer)(struct xloop_device *xlo, int cmd, struct page *raw_page, unsigned raw_off, - struct page *loop_page, unsigned loop_off, + struct page *xloop_page, unsigned xloop_off, int size, sector_t real_block); - int (*init)(struct loop_device *, const struct xloop_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); + int (*init)(struct xloop_device *, const struct xloop_info64 *); + /* release is called from xloop_unregister_transfer or clr_fd */ + int (*release)(struct xloop_device *); + int (*ioctl)(struct xloop_device *, int cmd, unsigned long arg); struct module *owner; }; -int xloop_register_transfer(struct loop_func_table *funcs); -int xloop_unregister_transfer(int number); +int xloop_register_transfer(struct xloop_func_table *funcs); +int xloop_unregister_transfer(int number); #endif |