diff options
-rw-r--r-- | include/linux/sunrpc/rpc_pipe_fs.h | 1 | ||||
-rw-r--r-- | net/sunrpc/rpc_pipe.c | 22 |
2 files changed, 16 insertions, 7 deletions
diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h index 51b977a4ca20..cea764c2359f 100644 --- a/include/linux/sunrpc/rpc_pipe_fs.h +++ b/include/linux/sunrpc/rpc_pipe_fs.h | |||
@@ -15,6 +15,7 @@ struct rpc_pipe_ops { | |||
15 | ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t); | 15 | ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t); |
16 | ssize_t (*downcall)(struct file *, const char __user *, size_t); | 16 | ssize_t (*downcall)(struct file *, const char __user *, size_t); |
17 | void (*release_pipe)(struct inode *); | 17 | void (*release_pipe)(struct inode *); |
18 | int (*open_pipe)(struct inode *); | ||
18 | void (*destroy_msg)(struct rpc_pipe_msg *); | 19 | void (*destroy_msg)(struct rpc_pipe_msg *); |
19 | }; | 20 | }; |
20 | 21 | ||
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 55b2049834c4..c9b57f47108c 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -169,16 +169,24 @@ static int | |||
169 | rpc_pipe_open(struct inode *inode, struct file *filp) | 169 | rpc_pipe_open(struct inode *inode, struct file *filp) |
170 | { | 170 | { |
171 | struct rpc_inode *rpci = RPC_I(inode); | 171 | struct rpc_inode *rpci = RPC_I(inode); |
172 | int first_open; | ||
172 | int res = -ENXIO; | 173 | int res = -ENXIO; |
173 | 174 | ||
174 | mutex_lock(&inode->i_mutex); | 175 | mutex_lock(&inode->i_mutex); |
175 | if (rpci->ops != NULL) { | 176 | if (rpci->ops == NULL) |
176 | if (filp->f_mode & FMODE_READ) | 177 | goto out; |
177 | rpci->nreaders ++; | 178 | first_open = rpci->nreaders == 0 && rpci->nwriters == 0; |
178 | if (filp->f_mode & FMODE_WRITE) | 179 | if (first_open && rpci->ops->open_pipe) { |
179 | rpci->nwriters ++; | 180 | res = rpci->ops->open_pipe(inode); |
180 | res = 0; | 181 | if (res) |
182 | goto out; | ||
181 | } | 183 | } |
184 | if (filp->f_mode & FMODE_READ) | ||
185 | rpci->nreaders++; | ||
186 | if (filp->f_mode & FMODE_WRITE) | ||
187 | rpci->nwriters++; | ||
188 | res = 0; | ||
189 | out: | ||
182 | mutex_unlock(&inode->i_mutex); | 190 | mutex_unlock(&inode->i_mutex); |
183 | return res; | 191 | return res; |
184 | } | 192 | } |
@@ -748,7 +756,7 @@ rpc_rmdir(struct dentry *dentry) | |||
748 | * @name: name of pipe | 756 | * @name: name of pipe |
749 | * @private: private data to associate with the pipe, for the caller's use | 757 | * @private: private data to associate with the pipe, for the caller's use |
750 | * @ops: operations defining the behavior of the pipe: upcall, downcall, | 758 | * @ops: operations defining the behavior of the pipe: upcall, downcall, |
751 | * release_pipe, and destroy_msg. | 759 | * release_pipe, open_pipe, and destroy_msg. |
752 | * @flags: rpc_inode flags | 760 | * @flags: rpc_inode flags |
753 | * | 761 | * |
754 | * Data is made available for userspace to read by calls to | 762 | * Data is made available for userspace to read by calls to |