blob: 8cb673875715e205ca0e55a0a612ae49b5a72f4a [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 Heo5d604182013-11-23 17:21:52 -050013struct file;
14struct iattr;
15
Tejun Heob8441ed2013-11-24 09:54:58 -050016struct sysfs_dirent;
17
Tejun Heo879f40d2013-11-23 17:21:49 -050018#ifdef CONFIG_SYSFS
19
Tejun Heo5d0e26b2013-11-23 17:21:50 -050020struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent,
21 const char *name,
22 struct sysfs_dirent *target);
Tejun Heo879f40d2013-11-23 17:21:49 -050023void kernfs_remove(struct sysfs_dirent *sd);
24int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name,
25 const void *ns);
Tejun Heo890ece12013-11-23 17:21:51 -050026int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent,
27 const char *new_name, const void *new_ns);
Tejun Heo5d604182013-11-23 17:21:52 -050028int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr);
Tejun Heo879f40d2013-11-23 17:21:49 -050029
30#else /* CONFIG_SYSFS */
31
Tejun Heo5d0e26b2013-11-23 17:21:50 -050032static inline struct sysfs_dirent *
33kernfs_create_link(struct sysfs_dirent *parent, const char *name,
34 struct sysfs_dirent *target)
35{ return ERR_PTR(-ENOSYS); }
36
Tejun Heo879f40d2013-11-23 17:21:49 -050037static inline void kernfs_remove(struct sysfs_dirent *sd) { }
38
39static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent,
40 const char *name, const void *ns)
41{ return -ENOSYS; }
42
Tejun Heo890ece12013-11-23 17:21:51 -050043static inline int kernfs_rename_ns(struct sysfs_dirent *sd,
44 struct sysfs_dirent *new_parent,
45 const char *new_name, const void *new_ns)
46{ return -ENOSYS; }
47
Tejun Heo5d604182013-11-23 17:21:52 -050048static inline int kernfs_setattr(struct sysfs_dirent *sd,
49 const struct iattr *iattr)
50{ return -ENOSYS; }
51
Tejun Heo879f40d2013-11-23 17:21:49 -050052#endif /* CONFIG_SYSFS */
53
54static inline int kernfs_remove_by_name(struct sysfs_dirent *parent,
55 const char *name)
56{
57 return kernfs_remove_by_name_ns(parent, name, NULL);
58}
59
Tejun Heob8441ed2013-11-24 09:54:58 -050060#endif /* __LINUX_KERNFS_H */