loop.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * include/linux/loop.h
  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. */
  9. #ifndef _LINUX_LOOP_H
  10. #define _LINUX_LOOP_H
  11. #include <linux/bio.h>
  12. #include <linux/blkdev.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/mutex.h>
  15. #include <uapi/linux/loop.h>
  16. /* Possible states of device */
  17. enum {
  18. Lo_unbound,
  19. Lo_bound,
  20. Lo_rundown,
  21. };
  22. struct loop_func_table;
  23. struct loop_device {
  24. int lo_number;
  25. int lo_refcnt;
  26. loff_t lo_offset;
  27. loff_t lo_sizelimit;
  28. int lo_flags;
  29. int (*transfer)(struct loop_device *, int cmd,
  30. struct page *raw_page, unsigned raw_off,
  31. struct page *loop_page, unsigned loop_off,
  32. int size, sector_t real_block);
  33. char lo_file_name[LO_NAME_SIZE];
  34. char lo_crypt_name[LO_NAME_SIZE];
  35. char lo_encrypt_key[LO_KEY_SIZE];
  36. int lo_encrypt_key_size;
  37. struct loop_func_table *lo_encryption;
  38. __u32 lo_init[2];
  39. kuid_t lo_key_owner; /* Who set the key */
  40. int (*ioctl)(struct loop_device *, int cmd,
  41. unsigned long arg);
  42. struct file * lo_backing_file;
  43. struct block_device *lo_device;
  44. unsigned lo_blocksize;
  45. void *key_data;
  46. gfp_t old_gfp_mask;
  47. spinlock_t lo_lock;
  48. struct bio_list lo_bio_list;
  49. unsigned int lo_bio_count;
  50. int lo_state;
  51. struct mutex lo_ctl_mutex;
  52. struct task_struct *lo_thread;
  53. wait_queue_head_t lo_event;
  54. /* wait queue for incoming requests */
  55. wait_queue_head_t lo_req_wait;
  56. struct request_queue *lo_queue;
  57. struct gendisk *lo_disk;
  58. };
  59. /* Support for loadable transfer modules */
  60. struct loop_func_table {
  61. int number; /* filter type */
  62. int (*transfer)(struct loop_device *lo, int cmd,
  63. struct page *raw_page, unsigned raw_off,
  64. struct page *loop_page, unsigned loop_off,
  65. int size, sector_t real_block);
  66. int (*init)(struct loop_device *, const struct loop_info64 *);
  67. /* release is called from loop_unregister_transfer or clr_fd */
  68. int (*release)(struct loop_device *);
  69. int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
  70. struct module *owner;
  71. };
  72. int loop_register_transfer(struct loop_func_table *funcs);
  73. int loop_unregister_transfer(int number);
  74. #endif