|
@@ -169,16 +169,24 @@ static int
|
|
rpc_pipe_open(struct inode *inode, struct file *filp)
|
|
rpc_pipe_open(struct inode *inode, struct file *filp)
|
|
{
|
|
{
|
|
struct rpc_inode *rpci = RPC_I(inode);
|
|
struct rpc_inode *rpci = RPC_I(inode);
|
|
|
|
+ int first_open;
|
|
int res = -ENXIO;
|
|
int res = -ENXIO;
|
|
|
|
|
|
mutex_lock(&inode->i_mutex);
|
|
mutex_lock(&inode->i_mutex);
|
|
- if (rpci->ops != NULL) {
|
|
|
|
- if (filp->f_mode & FMODE_READ)
|
|
|
|
- rpci->nreaders ++;
|
|
|
|
- if (filp->f_mode & FMODE_WRITE)
|
|
|
|
- rpci->nwriters ++;
|
|
|
|
- res = 0;
|
|
|
|
|
|
+ if (rpci->ops == NULL)
|
|
|
|
+ goto out;
|
|
|
|
+ first_open = rpci->nreaders == 0 && rpci->nwriters == 0;
|
|
|
|
+ if (first_open && rpci->ops->open_pipe) {
|
|
|
|
+ res = rpci->ops->open_pipe(inode);
|
|
|
|
+ if (res)
|
|
|
|
+ goto out;
|
|
}
|
|
}
|
|
|
|
+ if (filp->f_mode & FMODE_READ)
|
|
|
|
+ rpci->nreaders++;
|
|
|
|
+ if (filp->f_mode & FMODE_WRITE)
|
|
|
|
+ rpci->nwriters++;
|
|
|
|
+ res = 0;
|
|
|
|
+out:
|
|
mutex_unlock(&inode->i_mutex);
|
|
mutex_unlock(&inode->i_mutex);
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
@@ -748,7 +756,7 @@ rpc_rmdir(struct dentry *dentry)
|
|
* @name: name of pipe
|
|
* @name: name of pipe
|
|
* @private: private data to associate with the pipe, for the caller's use
|
|
* @private: private data to associate with the pipe, for the caller's use
|
|
* @ops: operations defining the behavior of the pipe: upcall, downcall,
|
|
* @ops: operations defining the behavior of the pipe: upcall, downcall,
|
|
- * release_pipe, and destroy_msg.
|
|
|
|
|
|
+ * release_pipe, open_pipe, and destroy_msg.
|
|
* @flags: rpc_inode flags
|
|
* @flags: rpc_inode flags
|
|
*
|
|
*
|
|
* Data is made available for userspace to read by calls to
|
|
* Data is made available for userspace to read by calls to
|