fuse_i.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. FUSE: Filesystem in Userspace
  3. Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu>
  4. This program can be distributed under the terms of the GNU GPL.
  5. See the file COPYING.
  6. */
  7. #include <linux/fuse.h>
  8. #include <linux/fs.h>
  9. #include <linux/wait.h>
  10. #include <linux/list.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/mm.h>
  13. #include <linux/backing-dev.h>
  14. #include <asm/semaphore.h>
  15. /** FUSE inode */
  16. struct fuse_inode {
  17. /** Inode data */
  18. struct inode inode;
  19. /** Unique ID, which identifies the inode between userspace
  20. * and kernel */
  21. u64 nodeid;
  22. /** Time in jiffies until the file attributes are valid */
  23. unsigned long i_time;
  24. };
  25. /**
  26. * A Fuse connection.
  27. *
  28. * This structure is created, when the filesystem is mounted, and is
  29. * destroyed, when the client device is closed and the filesystem is
  30. * unmounted.
  31. */
  32. struct fuse_conn {
  33. /** The superblock of the mounted filesystem */
  34. struct super_block *sb;
  35. /** The user id for this mount */
  36. uid_t user_id;
  37. /** Backing dev info */
  38. struct backing_dev_info bdi;
  39. };
  40. static inline struct fuse_conn **get_fuse_conn_super_p(struct super_block *sb)
  41. {
  42. return (struct fuse_conn **) &sb->s_fs_info;
  43. }
  44. static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
  45. {
  46. return *get_fuse_conn_super_p(sb);
  47. }
  48. static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
  49. {
  50. return get_fuse_conn_super(inode->i_sb);
  51. }
  52. static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
  53. {
  54. return container_of(inode, struct fuse_inode, inode);
  55. }
  56. static inline u64 get_node_id(struct inode *inode)
  57. {
  58. return get_fuse_inode(inode)->nodeid;
  59. }
  60. /**
  61. * This is the single global spinlock which protects FUSE's structures
  62. *
  63. * The following data is protected by this lock:
  64. *
  65. * - the s_fs_info field of the super block
  66. * - the sb (super_block) field in fuse_conn
  67. */
  68. extern spinlock_t fuse_lock;
  69. /**
  70. * Check if the connection can be released, and if yes, then free the
  71. * connection structure
  72. */
  73. void fuse_release_conn(struct fuse_conn *fc);