aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/kernfs/dir.c25
-rw-r--r--include/linux/kernfs.h18
2 files changed, 22 insertions, 21 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index bfbfb48f4ad8..f58d2f16eaf7 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -527,13 +527,14 @@ EXPORT_SYMBOL_GPL(kernfs_find_and_get_ns);
527 527
528/** 528/**
529 * kernfs_create_root - create a new kernfs hierarchy 529 * kernfs_create_root - create a new kernfs hierarchy
530 * @kdops: optional directory syscall operations for the hierarchy 530 * @scops: optional syscall operations for the hierarchy
531 * @priv: opaque data associated with the new directory 531 * @priv: opaque data associated with the new directory
532 * 532 *
533 * Returns the root of the new hierarchy on success, ERR_PTR() value on 533 * Returns the root of the new hierarchy on success, ERR_PTR() value on
534 * failure. 534 * failure.
535 */ 535 */
536struct kernfs_root *kernfs_create_root(struct kernfs_dir_ops *kdops, void *priv) 536struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
537 void *priv)
537{ 538{
538 struct kernfs_root *root; 539 struct kernfs_root *root;
539 struct kernfs_node *kn; 540 struct kernfs_node *kn;
@@ -556,7 +557,7 @@ struct kernfs_root *kernfs_create_root(struct kernfs_dir_ops *kdops, void *priv)
556 kn->priv = priv; 557 kn->priv = priv;
557 kn->dir.root = root; 558 kn->dir.root = root;
558 559
559 root->dir_ops = kdops; 560 root->syscall_ops = scops;
560 root->kn = kn; 561 root->kn = kn;
561 init_waitqueue_head(&root->deactivate_waitq); 562 init_waitqueue_head(&root->deactivate_waitq);
562 563
@@ -653,16 +654,16 @@ static int kernfs_iop_mkdir(struct inode *dir, struct dentry *dentry,
653 umode_t mode) 654 umode_t mode)
654{ 655{
655 struct kernfs_node *parent = dir->i_private; 656 struct kernfs_node *parent = dir->i_private;
656 struct kernfs_dir_ops *kdops = kernfs_root(parent)->dir_ops; 657 struct kernfs_syscall_ops *scops = kernfs_root(parent)->syscall_ops;
657 int ret; 658 int ret;
658 659
659 if (!kdops || !kdops->mkdir) 660 if (!scops || !scops->mkdir)
660 return -EPERM; 661 return -EPERM;
661 662
662 if (!kernfs_get_active(parent)) 663 if (!kernfs_get_active(parent))
663 return -ENODEV; 664 return -ENODEV;
664 665
665 ret = kdops->mkdir(parent, dentry->d_name.name, mode); 666 ret = scops->mkdir(parent, dentry->d_name.name, mode);
666 667
667 kernfs_put_active(parent); 668 kernfs_put_active(parent);
668 return ret; 669 return ret;
@@ -671,16 +672,16 @@ static int kernfs_iop_mkdir(struct inode *dir, struct dentry *dentry,
671static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry) 672static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry)
672{ 673{
673 struct kernfs_node *kn = dentry->d_fsdata; 674 struct kernfs_node *kn = dentry->d_fsdata;
674 struct kernfs_dir_ops *kdops = kernfs_root(kn)->dir_ops; 675 struct kernfs_syscall_ops *scops = kernfs_root(kn)->syscall_ops;
675 int ret; 676 int ret;
676 677
677 if (!kdops || !kdops->rmdir) 678 if (!scops || !scops->rmdir)
678 return -EPERM; 679 return -EPERM;
679 680
680 if (!kernfs_get_active(kn)) 681 if (!kernfs_get_active(kn))
681 return -ENODEV; 682 return -ENODEV;
682 683
683 ret = kdops->rmdir(kn); 684 ret = scops->rmdir(kn);
684 685
685 kernfs_put_active(kn); 686 kernfs_put_active(kn);
686 return ret; 687 return ret;
@@ -691,10 +692,10 @@ static int kernfs_iop_rename(struct inode *old_dir, struct dentry *old_dentry,
691{ 692{
692 struct kernfs_node *kn = old_dentry->d_fsdata; 693 struct kernfs_node *kn = old_dentry->d_fsdata;
693 struct kernfs_node *new_parent = new_dir->i_private; 694 struct kernfs_node *new_parent = new_dir->i_private;
694 struct kernfs_dir_ops *kdops = kernfs_root(kn)->dir_ops; 695 struct kernfs_syscall_ops *scops = kernfs_root(kn)->syscall_ops;
695 int ret; 696 int ret;
696 697
697 if (!kdops || !kdops->rename) 698 if (!scops || !scops->rename)
698 return -EPERM; 699 return -EPERM;
699 700
700 if (!kernfs_get_active(kn)) 701 if (!kernfs_get_active(kn))
@@ -705,7 +706,7 @@ static int kernfs_iop_rename(struct inode *old_dir, struct dentry *old_dentry,
705 return -ENODEV; 706 return -ENODEV;
706 } 707 }
707 708
708 ret = kdops->rename(kn, new_parent, new_dentry->d_name.name); 709 ret = scops->rename(kn, new_parent, new_dentry->d_name.name);
709 710
710 kernfs_put_active(new_parent); 711 kernfs_put_active(new_parent);
711 kernfs_put_active(kn); 712 kernfs_put_active(kn);
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index 58a131ddc6a3..5ddc47450335 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -108,13 +108,13 @@ struct kernfs_node {
108}; 108};
109 109
110/* 110/*
111 * kernfs_dir_ops may be specified on kernfs_create_root() to support 111 * kernfs_syscall_ops may be specified on kernfs_create_root() to support
112 * directory manipulation syscalls. These optional callbacks are invoked 112 * syscalls. These optional callbacks are invoked on the matching syscalls
113 * on the matching syscalls and can perform any kernfs operations which 113 * and can perform any kernfs operations which don't necessarily have to be
114 * don't necessarily have to be the exact operation requested. An active 114 * the exact operation requested. An active reference is held for each
115 * reference is held for each kernfs_node parameter. 115 * kernfs_node parameter.
116 */ 116 */
117struct kernfs_dir_ops { 117struct kernfs_syscall_ops {
118 int (*mkdir)(struct kernfs_node *parent, const char *name, 118 int (*mkdir)(struct kernfs_node *parent, const char *name,
119 umode_t mode); 119 umode_t mode);
120 int (*rmdir)(struct kernfs_node *kn); 120 int (*rmdir)(struct kernfs_node *kn);
@@ -128,7 +128,7 @@ struct kernfs_root {
128 128
129 /* private fields, do not use outside kernfs proper */ 129 /* private fields, do not use outside kernfs proper */
130 struct ida ino_ida; 130 struct ida ino_ida;
131 struct kernfs_dir_ops *dir_ops; 131 struct kernfs_syscall_ops *syscall_ops;
132 wait_queue_head_t deactivate_waitq; 132 wait_queue_head_t deactivate_waitq;
133}; 133};
134 134
@@ -219,7 +219,7 @@ struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
219void kernfs_get(struct kernfs_node *kn); 219void kernfs_get(struct kernfs_node *kn);
220void kernfs_put(struct kernfs_node *kn); 220void kernfs_put(struct kernfs_node *kn);
221 221
222struct kernfs_root *kernfs_create_root(struct kernfs_dir_ops *kdops, 222struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
223 void *priv); 223 void *priv);
224void kernfs_destroy_root(struct kernfs_root *root); 224void kernfs_destroy_root(struct kernfs_root *root);
225 225
@@ -273,7 +273,7 @@ static inline void kernfs_get(struct kernfs_node *kn) { }
273static inline void kernfs_put(struct kernfs_node *kn) { } 273static inline void kernfs_put(struct kernfs_node *kn) { }
274 274
275static inline struct kernfs_root * 275static inline struct kernfs_root *
276kernfs_create_root(struct kernfs_dir_ops *kdops, void *priv) 276kernfs_create_root(struct kernfs_syscall_ops *scops, void *priv)
277{ return ERR_PTR(-ENOSYS); } 277{ return ERR_PTR(-ENOSYS); }
278 278
279static inline void kernfs_destroy_root(struct kernfs_root *root) { } 279static inline void kernfs_destroy_root(struct kernfs_root *root) { }