Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Al Viro | 83a8761 | 2013-05-12 10:14:07 -0400 | [diff] [blame^] | 2 | * loop.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Written by Theodore Ts'o, 3/29/93. |
| 5 | * |
| 6 | * Copyright 1993 by Theodore Ts'o. Redistribution of this file is |
| 7 | * permitted under the GNU General Public License. |
| 8 | */ |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 9 | #ifndef _LINUX_LOOP_H |
| 10 | #define _LINUX_LOOP_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/bio.h> |
| 13 | #include <linux/blkdev.h> |
| 14 | #include <linux/spinlock.h> |
Ingo Molnar | f85221d | 2006-03-23 03:00:38 -0800 | [diff] [blame] | 15 | #include <linux/mutex.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 16 | #include <uapi/linux/loop.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | /* Possible states of device */ |
| 19 | enum { |
| 20 | Lo_unbound, |
| 21 | Lo_bound, |
| 22 | Lo_rundown, |
| 23 | }; |
| 24 | |
| 25 | struct loop_func_table; |
| 26 | |
| 27 | struct loop_device { |
| 28 | int lo_number; |
| 29 | int lo_refcnt; |
| 30 | loff_t lo_offset; |
| 31 | loff_t lo_sizelimit; |
| 32 | int lo_flags; |
| 33 | int (*transfer)(struct loop_device *, int cmd, |
| 34 | struct page *raw_page, unsigned raw_off, |
| 35 | struct page *loop_page, unsigned loop_off, |
| 36 | int size, sector_t real_block); |
| 37 | char lo_file_name[LO_NAME_SIZE]; |
| 38 | char lo_crypt_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]; |
Eric W. Biederman | e484973 | 2012-02-11 11:23:51 -0800 | [diff] [blame] | 43 | kuid_t lo_key_owner; /* Who set the key */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Al Viro | b4e3ca1 | 2005-10-21 03:22:34 -0400 | [diff] [blame] | 52 | gfp_t old_gfp_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | spinlock_t lo_lock; |
Akinobu Mita | e686307 | 2009-04-17 08:41:21 +0200 | [diff] [blame] | 55 | struct bio_list lo_bio_list; |
Lukas Czerner | 7b5a352 | 2012-11-30 11:42:41 +0100 | [diff] [blame] | 56 | unsigned int lo_bio_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | int lo_state; |
Ingo Molnar | f85221d | 2006-03-23 03:00:38 -0800 | [diff] [blame] | 58 | struct mutex lo_ctl_mutex; |
Serge E. Hallyn | 6c99791 | 2006-09-29 01:59:11 -0700 | [diff] [blame] | 59 | struct task_struct *lo_thread; |
| 60 | wait_queue_head_t lo_event; |
Lukas Czerner | 7b5a352 | 2012-11-30 11:42:41 +0100 | [diff] [blame] | 61 | /* wait queue for incoming requests */ |
| 62 | wait_queue_head_t lo_req_wait; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
Arnd Bergmann | 01e457c | 2007-07-23 18:44:00 -0700 | [diff] [blame] | 64 | struct request_queue *lo_queue; |
Ken Chen | 7328508 | 2007-05-08 00:28:20 -0700 | [diff] [blame] | 65 | struct gendisk *lo_disk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | /* Support for loadable transfer modules */ |
| 69 | struct loop_func_table { |
| 70 | int number; /* filter type */ |
| 71 | int (*transfer)(struct loop_device *lo, int cmd, |
| 72 | struct page *raw_page, unsigned raw_off, |
| 73 | struct page *loop_page, unsigned loop_off, |
| 74 | int size, sector_t real_block); |
| 75 | int (*init)(struct loop_device *, const struct loop_info64 *); |
| 76 | /* release is called from loop_unregister_transfer or clr_fd */ |
| 77 | int (*release)(struct loop_device *); |
| 78 | int (*ioctl)(struct loop_device *, int cmd, unsigned long arg); |
| 79 | struct module *owner; |
| 80 | }; |
| 81 | |
| 82 | int loop_register_transfer(struct loop_func_table *funcs); |
| 83 | int loop_unregister_transfer(int number); |
| 84 | |
| 85 | #endif |