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