aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/sysfs/dir.c34
-rw-r--r--include/linux/sysfs.h15
2 files changed, 49 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);
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 99382c0df17e..9f65758311a4 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -210,6 +210,10 @@ int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
210int __must_check sysfs_move_dir_ns(struct kobject *kobj, 210int __must_check sysfs_move_dir_ns(struct kobject *kobj,
211 struct kobject *new_parent_kobj, 211 struct kobject *new_parent_kobj,
212 const void *new_ns); 212 const void *new_ns);
213int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
214 const char *name);
215void sysfs_remove_mount_point(struct kobject *parent_kobj,
216 const char *name);
213 217
214int __must_check sysfs_create_file_ns(struct kobject *kobj, 218int __must_check sysfs_create_file_ns(struct kobject *kobj,
215 const struct attribute *attr, 219 const struct attribute *attr,
@@ -298,6 +302,17 @@ static inline int sysfs_move_dir_ns(struct kobject *kobj,
298 return 0; 302 return 0;
299} 303}
300 304
305static inline int sysfs_create_mount_point(struct kobject *parent_kobj,
306 const char *name)
307{
308 return 0;
309}
310
311static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,
312 const char *name)
313{
314}
315
301static inline int sysfs_create_file_ns(struct kobject *kobj, 316static inline int sysfs_create_file_ns(struct kobject *kobj,
302 const struct attribute *attr, 317 const struct attribute *attr,
303 const void *ns) 318 const void *ns)