aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-05-13 17:31:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-07-21 13:10:01 -0400
commit9924f6e89823a41bfd272ab759636276b9f9ee9c (patch)
treeee65aa6c9130c1ad0bfc630d8bf7112ae1fde160 /fs
parent80c298105bf80e33ae494eaeba51f00352b5373c (diff)
sysfs: Add support for permanently empty directories to serve as mount points.
commit 87d2846fcf88113fae2341da1ca9a71f0d916f2c upstream. Add two functions sysfs_create_mount_point and sysfs_remove_mount_point that hang a permanently empty directory off of a kobject or remove a permanently emptpy directory hanging from a kobject. Export these new functions so modular filesystems can use them. Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/sysfs/dir.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 0b45ff42f374..94374e435025 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -121,3 +121,37 @@ int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj,
121 121
122 return kernfs_rename_ns(kn, new_parent, kn->name, new_ns); 122 return kernfs_rename_ns(kn, new_parent, kn->name, new_ns);
123} 123}
124
125/**
126 * sysfs_create_mount_point - create an always empty directory
127 * @parent_kobj: kobject that will contain this always empty directory
128 * @name: The name of the always empty directory to add
129 */
130int sysfs_create_mount_point(struct kobject *parent_kobj, const char *name)
131{
132 struct kernfs_node *kn, *parent = parent_kobj->sd;
133
134 kn = kernfs_create_empty_dir(parent, name);
135 if (IS_ERR(kn)) {
136 if (PTR_ERR(kn) == -EEXIST)
137 sysfs_warn_dup(parent, name);
138 return PTR_ERR(kn);
139 }
140
141 return 0;
142}
143EXPORT_SYMBOL_GPL(sysfs_create_mount_point);
144
145/**
146 * sysfs_remove_mount_point - remove an always empty directory.
147 * @parent_kobj: kobject that will contain this always empty directory
148 * @name: The name of the always empty directory to remove
149 *
150 */
151void sysfs_remove_mount_point(struct kobject *parent_kobj, const char *name)
152{
153 struct kernfs_node *parent = parent_kobj->sd;
154
155 kernfs_remove_by_name_ns(parent, name, NULL);
156}
157EXPORT_SYMBOL_GPL(sysfs_remove_mount_point);