rpc_pipe_fs.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H
  2. #define _LINUX_SUNRPC_RPC_PIPE_FS_H
  3. #ifdef __KERNEL__
  4. #include <linux/workqueue.h>
  5. struct rpc_pipe_dir_head {
  6. struct list_head pdh_entries;
  7. struct dentry *pdh_dentry;
  8. };
  9. struct rpc_pipe_dir_object_ops;
  10. struct rpc_pipe_dir_object {
  11. struct list_head pdo_head;
  12. const struct rpc_pipe_dir_object_ops *pdo_ops;
  13. void *pdo_data;
  14. };
  15. struct rpc_pipe_dir_object_ops {
  16. int (*create)(struct dentry *dir,
  17. struct rpc_pipe_dir_object *pdo);
  18. void (*destroy)(struct dentry *dir,
  19. struct rpc_pipe_dir_object *pdo);
  20. };
  21. struct rpc_pipe_msg {
  22. struct list_head list;
  23. void *data;
  24. size_t len;
  25. size_t copied;
  26. int errno;
  27. };
  28. struct rpc_pipe_ops {
  29. ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t);
  30. ssize_t (*downcall)(struct file *, const char __user *, size_t);
  31. void (*release_pipe)(struct inode *);
  32. int (*open_pipe)(struct inode *);
  33. void (*destroy_msg)(struct rpc_pipe_msg *);
  34. };
  35. struct rpc_pipe {
  36. struct list_head pipe;
  37. struct list_head in_upcall;
  38. struct list_head in_downcall;
  39. int pipelen;
  40. int nreaders;
  41. int nwriters;
  42. #define RPC_PIPE_WAIT_FOR_OPEN 1
  43. int flags;
  44. struct delayed_work queue_timeout;
  45. const struct rpc_pipe_ops *ops;
  46. spinlock_t lock;
  47. struct dentry *dentry;
  48. };
  49. struct rpc_inode {
  50. struct inode vfs_inode;
  51. void *private;
  52. struct rpc_pipe *pipe;
  53. wait_queue_head_t waitq;
  54. };
  55. static inline struct rpc_inode *
  56. RPC_I(struct inode *inode)
  57. {
  58. return container_of(inode, struct rpc_inode, vfs_inode);
  59. }
  60. enum {
  61. SUNRPC_PIPEFS_NFS_PRIO,
  62. SUNRPC_PIPEFS_RPC_PRIO,
  63. };
  64. extern int rpc_pipefs_notifier_register(struct notifier_block *);
  65. extern void rpc_pipefs_notifier_unregister(struct notifier_block *);
  66. enum {
  67. RPC_PIPEFS_MOUNT,
  68. RPC_PIPEFS_UMOUNT,
  69. };
  70. extern struct dentry *rpc_d_lookup_sb(const struct super_block *sb,
  71. const unsigned char *dir_name);
  72. extern int rpc_pipefs_init_net(struct net *net);
  73. extern void rpc_pipefs_exit_net(struct net *net);
  74. extern struct super_block *rpc_get_sb_net(const struct net *net);
  75. extern void rpc_put_sb_net(const struct net *net);
  76. extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *,
  77. char __user *, size_t);
  78. extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *);
  79. struct rpc_clnt;
  80. extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *);
  81. extern int rpc_remove_client_dir(struct rpc_clnt *);
  82. extern void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh);
  83. extern void rpc_init_pipe_dir_object(struct rpc_pipe_dir_object *pdo,
  84. const struct rpc_pipe_dir_object_ops *pdo_ops,
  85. void *pdo_data);
  86. extern int rpc_add_pipe_dir_object(struct net *net,
  87. struct rpc_pipe_dir_head *pdh,
  88. struct rpc_pipe_dir_object *pdo);
  89. extern void rpc_remove_pipe_dir_object(struct net *net,
  90. struct rpc_pipe_dir_head *pdh,
  91. struct rpc_pipe_dir_object *pdo);
  92. extern struct rpc_pipe_dir_object *rpc_find_or_alloc_pipe_dir_object(
  93. struct net *net,
  94. struct rpc_pipe_dir_head *pdh,
  95. int (*match)(struct rpc_pipe_dir_object *, void *),
  96. struct rpc_pipe_dir_object *(*alloc)(void *),
  97. void *data);
  98. struct cache_detail;
  99. extern struct dentry *rpc_create_cache_dir(struct dentry *,
  100. const char *,
  101. umode_t umode,
  102. struct cache_detail *);
  103. extern void rpc_remove_cache_dir(struct dentry *);
  104. extern int rpc_rmdir(struct dentry *dentry);
  105. struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags);
  106. void rpc_destroy_pipe_data(struct rpc_pipe *pipe);
  107. extern struct dentry *rpc_mkpipe_dentry(struct dentry *, const char *, void *,
  108. struct rpc_pipe *);
  109. extern int rpc_unlink(struct dentry *);
  110. extern int register_rpc_pipefs(void);
  111. extern void unregister_rpc_pipefs(void);
  112. extern bool gssd_running(struct net *net);
  113. #endif
  114. #endif