]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sunrpc/rpc_pipe.c
rpc: add an rpc_pipe_open method
[linux-2.6-omap-h63xx.git] / net / sunrpc / rpc_pipe.c
index 23a2b8f6dc495094ec7c8de5a48c06bad2c3d4b8..c9b57f47108c7005de24bff6146e7ac90964a665 100644 (file)
@@ -113,7 +113,7 @@ out:
        wake_up(&rpci->waitq);
        return res;
 }
-EXPORT_SYMBOL(rpc_queue_upcall);
+EXPORT_SYMBOL_GPL(rpc_queue_upcall);
 
 static inline void
 rpc_inode_setowner(struct inode *inode, void *private)
@@ -169,16 +169,24 @@ static int
 rpc_pipe_open(struct inode *inode, struct file *filp)
 {
        struct rpc_inode *rpci = RPC_I(inode);
+       int first_open;
        int res = -ENXIO;
 
        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);
        return res;
 }
@@ -748,7 +756,7 @@ rpc_rmdir(struct dentry *dentry)
  * @name: name of pipe
  * @private: private data to associate with the pipe, for the caller's use
  * @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
  *
  * Data is made available for userspace to read by calls to
@@ -808,7 +816,7 @@ err_dput:
                        -ENOMEM);
        goto out;
 }
-EXPORT_SYMBOL(rpc_mkpipe);
+EXPORT_SYMBOL_GPL(rpc_mkpipe);
 
 /**
  * rpc_unlink - remove a pipe
@@ -839,7 +847,7 @@ rpc_unlink(struct dentry *dentry)
        dput(parent);
        return error;
 }
-EXPORT_SYMBOL(rpc_unlink);
+EXPORT_SYMBOL_GPL(rpc_unlink);
 
 /*
  * populate the filesystem