Tejun Heo | b8441ed | 2013-11-24 09:54:58 -0500 | [diff] [blame] | 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 | |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 10 | #include <linux/kernel.h> |
Tejun Heo | 5d0e26b | 2013-11-23 17:21:50 -0500 | [diff] [blame] | 11 | #include <linux/err.h> |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 12 | |
Tejun Heo | 5d60418 | 2013-11-23 17:21:52 -0500 | [diff] [blame^] | 13 | struct file; |
| 14 | struct iattr; |
| 15 | |
Tejun Heo | b8441ed | 2013-11-24 09:54:58 -0500 | [diff] [blame] | 16 | struct sysfs_dirent; |
| 17 | |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 18 | #ifdef CONFIG_SYSFS |
| 19 | |
Tejun Heo | 5d0e26b | 2013-11-23 17:21:50 -0500 | [diff] [blame] | 20 | struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, |
| 21 | const char *name, |
| 22 | struct sysfs_dirent *target); |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 23 | void kernfs_remove(struct sysfs_dirent *sd); |
| 24 | int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name, |
| 25 | const void *ns); |
Tejun Heo | 890ece1 | 2013-11-23 17:21:51 -0500 | [diff] [blame] | 26 | int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent, |
| 27 | const char *new_name, const void *new_ns); |
Tejun Heo | 5d60418 | 2013-11-23 17:21:52 -0500 | [diff] [blame^] | 28 | int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr); |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 29 | |
| 30 | #else /* CONFIG_SYSFS */ |
| 31 | |
Tejun Heo | 5d0e26b | 2013-11-23 17:21:50 -0500 | [diff] [blame] | 32 | static inline struct sysfs_dirent * |
| 33 | kernfs_create_link(struct sysfs_dirent *parent, const char *name, |
| 34 | struct sysfs_dirent *target) |
| 35 | { return ERR_PTR(-ENOSYS); } |
| 36 | |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 37 | static inline void kernfs_remove(struct sysfs_dirent *sd) { } |
| 38 | |
| 39 | static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, |
| 40 | const char *name, const void *ns) |
| 41 | { return -ENOSYS; } |
| 42 | |
Tejun Heo | 890ece1 | 2013-11-23 17:21:51 -0500 | [diff] [blame] | 43 | static 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 Heo | 5d60418 | 2013-11-23 17:21:52 -0500 | [diff] [blame^] | 48 | static inline int kernfs_setattr(struct sysfs_dirent *sd, |
| 49 | const struct iattr *iattr) |
| 50 | { return -ENOSYS; } |
| 51 | |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 52 | #endif /* CONFIG_SYSFS */ |
| 53 | |
| 54 | static 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 Heo | b8441ed | 2013-11-24 09:54:58 -0500 | [diff] [blame] | 60 | #endif /* __LINUX_KERNFS_H */ |