aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/sunrpc/rpc_pipe.c78
1 files changed, 50 insertions, 28 deletions
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 1613d858ba38..57e9cd3c49b6 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -406,19 +406,6 @@ struct rpc_filelist {
406 umode_t mode; 406 umode_t mode;
407}; 407};
408 408
409enum {
410 RPCAUTH_info,
411 RPCAUTH_EOF
412};
413
414static const struct rpc_filelist authfiles[] = {
415 [RPCAUTH_info] = {
416 .name = "info",
417 .i_fop = &rpc_info_operations,
418 .mode = S_IFREG | S_IRUSR,
419 },
420};
421
422struct vfsmount *rpc_get_mount(void) 409struct vfsmount *rpc_get_mount(void)
423{ 410{
424 int err; 411 int err;
@@ -698,8 +685,9 @@ out_bad:
698 return err; 685 return err;
699} 686}
700 687
701struct dentry *rpc_mkdir_populate(struct dentry *parent, 688static struct dentry *rpc_mkdir_populate(struct dentry *parent,
702 struct qstr *name, umode_t mode, void *private) 689 struct qstr *name, umode_t mode, void *private,
690 int (*populate)(struct dentry *, void *), void *args_populate)
703{ 691{
704 struct dentry *dentry; 692 struct dentry *dentry;
705 struct inode *dir = parent->d_inode; 693 struct inode *dir = parent->d_inode;
@@ -712,10 +700,11 @@ struct dentry *rpc_mkdir_populate(struct dentry *parent,
712 error = __rpc_mkdir(dir, dentry, mode, NULL, private); 700 error = __rpc_mkdir(dir, dentry, mode, NULL, private);
713 if (error != 0) 701 if (error != 0)
714 goto out_err; 702 goto out_err;
715 error = rpc_populate(dentry, authfiles, 703 if (populate != NULL) {
716 RPCAUTH_info, RPCAUTH_EOF, private); 704 error = populate(dentry, args_populate);
717 if (error) 705 if (error)
718 goto err_rmdir; 706 goto err_rmdir;
707 }
719out: 708out:
720 mutex_unlock(&dir->i_mutex); 709 mutex_unlock(&dir->i_mutex);
721 return dentry; 710 return dentry;
@@ -726,11 +715,8 @@ out_err:
726 goto out; 715 goto out;
727} 716}
728 717
729/** 718static int rpc_rmdir_depopulate(struct dentry *dentry,
730 * rpc_remove_client_dir - Remove a directory created with rpc_create_client_dir() 719 void (*depopulate)(struct dentry *))
731 * @dentry: directory to remove
732 */
733int rpc_remove_client_dir(struct dentry *dentry)
734{ 720{
735 struct dentry *parent; 721 struct dentry *parent;
736 struct inode *dir; 722 struct inode *dir;
@@ -739,7 +725,8 @@ int rpc_remove_client_dir(struct dentry *dentry)
739 parent = dget_parent(dentry); 725 parent = dget_parent(dentry);
740 dir = parent->d_inode; 726 dir = parent->d_inode;
741 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); 727 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
742 rpc_depopulate(dentry, authfiles, RPCAUTH_info, RPCAUTH_EOF); 728 if (depopulate != NULL)
729 depopulate(dentry);
743 error = __rpc_rmdir(dir, dentry); 730 error = __rpc_rmdir(dir, dentry);
744 mutex_unlock(&dir->i_mutex); 731 mutex_unlock(&dir->i_mutex);
745 dput(parent); 732 dput(parent);
@@ -843,6 +830,31 @@ rpc_unlink(struct dentry *dentry)
843} 830}
844EXPORT_SYMBOL_GPL(rpc_unlink); 831EXPORT_SYMBOL_GPL(rpc_unlink);
845 832
833enum {
834 RPCAUTH_info,
835 RPCAUTH_EOF
836};
837
838static const struct rpc_filelist authfiles[] = {
839 [RPCAUTH_info] = {
840 .name = "info",
841 .i_fop = &rpc_info_operations,
842 .mode = S_IFREG | S_IRUSR,
843 },
844};
845
846static int rpc_clntdir_populate(struct dentry *dentry, void *private)
847{
848 return rpc_populate(dentry,
849 authfiles, RPCAUTH_info, RPCAUTH_EOF,
850 private);
851}
852
853static void rpc_clntdir_depopulate(struct dentry *dentry)
854{
855 rpc_depopulate(dentry, authfiles, RPCAUTH_info, RPCAUTH_EOF);
856}
857
846/** 858/**
847 * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs 859 * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs
848 * @path: path from the rpc_pipefs root to the new directory 860 * @path: path from the rpc_pipefs root to the new directory
@@ -854,10 +866,20 @@ EXPORT_SYMBOL_GPL(rpc_unlink);
854 * later be created using rpc_mkpipe(). 866 * later be created using rpc_mkpipe().
855 */ 867 */
856struct dentry *rpc_create_client_dir(struct dentry *dentry, 868struct dentry *rpc_create_client_dir(struct dentry *dentry,
857 struct qstr *name, 869 struct qstr *name,
858 struct rpc_clnt *rpc_client) 870 struct rpc_clnt *rpc_client)
871{
872 return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL,
873 rpc_clntdir_populate, rpc_client);
874}
875
876/**
877 * rpc_remove_client_dir - Remove a directory created with rpc_create_client_dir()
878 * @dentry: directory to remove
879 */
880int rpc_remove_client_dir(struct dentry *dentry)
859{ 881{
860 return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, rpc_client); 882 return rpc_rmdir_depopulate(dentry, rpc_clntdir_depopulate);
861} 883}
862 884
863/* 885/*