sysfs, kernfs: introduce kernfs_create_link()
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / include / linux / kernfs.h
CommitLineData
b8441ed2
TH
1/*
2 * kernfs.h - pseudo filesystem decoupled from vfs locking
3 *
4 * This file is released under the GPLv2.
5 */
6
7#ifndef __LINUX_KERNFS_H
8#define __LINUX_KERNFS_H
9
879f40d1 10#include <linux/kernel.h>
5d0e26bb 11#include <linux/err.h>
879f40d1 12
b8441ed2
TH
13struct sysfs_dirent;
14
879f40d1
TH
15#ifdef CONFIG_SYSFS
16
5d0e26bb
TH
17struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent,
18 const char *name,
19 struct sysfs_dirent *target);
879f40d1
TH
20void kernfs_remove(struct sysfs_dirent *sd);
21int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name,
22 const void *ns);
23
24#else /* CONFIG_SYSFS */
25
5d0e26bb
TH
26static inline struct sysfs_dirent *
27kernfs_create_link(struct sysfs_dirent *parent, const char *name,
28 struct sysfs_dirent *target)
29{ return ERR_PTR(-ENOSYS); }
30
879f40d1
TH
31static inline void kernfs_remove(struct sysfs_dirent *sd) { }
32
33static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent,
34 const char *name, const void *ns)
35{ return -ENOSYS; }
36
37#endif /* CONFIG_SYSFS */
38
39static inline int kernfs_remove_by_name(struct sysfs_dirent *parent,
40 const char *name)
41{
42 return kernfs_remove_by_name_ns(parent, name, NULL);
43}
44
b8441ed2 45#endif /* __LINUX_KERNFS_H */