blob: 803d9600cf723d59a42aa374b5a4d738383de968 [file] [log] [blame]
Tejun Heob8441ed2013-11-24 09:54:58 -05001/*
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
Tejun Heo879f40d2013-11-23 17:21:49 -050010#include <linux/kernel.h>
Tejun Heo5d0e26b2013-11-23 17:21:50 -050011#include <linux/err.h>
Tejun Heo879f40d2013-11-23 17:21:49 -050012
Tejun Heob8441ed2013-11-24 09:54:58 -050013struct sysfs_dirent;
14
Tejun Heo879f40d2013-11-23 17:21:49 -050015#ifdef CONFIG_SYSFS
16
Tejun Heo5d0e26b2013-11-23 17:21:50 -050017struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent,
18 const char *name,
19 struct sysfs_dirent *target);
Tejun Heo879f40d2013-11-23 17:21:49 -050020void kernfs_remove(struct sysfs_dirent *sd);
21int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name,
22 const void *ns);
Tejun Heo890ece12013-11-23 17:21:51 -050023int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent,
24 const char *new_name, const void *new_ns);
Tejun Heo879f40d2013-11-23 17:21:49 -050025
26#else /* CONFIG_SYSFS */
27
Tejun Heo5d0e26b2013-11-23 17:21:50 -050028static inline struct sysfs_dirent *
29kernfs_create_link(struct sysfs_dirent *parent, const char *name,
30 struct sysfs_dirent *target)
31{ return ERR_PTR(-ENOSYS); }
32
Tejun Heo879f40d2013-11-23 17:21:49 -050033static inline void kernfs_remove(struct sysfs_dirent *sd) { }
34
35static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent,
36 const char *name, const void *ns)
37{ return -ENOSYS; }
38
Tejun Heo890ece12013-11-23 17:21:51 -050039static inline int kernfs_rename_ns(struct sysfs_dirent *sd,
40 struct sysfs_dirent *new_parent,
41 const char *new_name, const void *new_ns)
42{ return -ENOSYS; }
43
Tejun Heo879f40d2013-11-23 17:21:49 -050044#endif /* CONFIG_SYSFS */
45
46static inline int kernfs_remove_by_name(struct sysfs_dirent *parent,
47 const char *name)
48{
49 return kernfs_remove_by_name_ns(parent, name, NULL);
50}
51
Tejun Heob8441ed2013-11-24 09:54:58 -050052#endif /* __LINUX_KERNFS_H */