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 | 93b2b8e | 2013-11-28 14:54:15 -0500 | [diff] [blame^] | 20 | struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent, |
| 21 | const char *name, void *priv, |
| 22 | const void *ns); |
Tejun Heo | 5d0e26b | 2013-11-23 17:21:50 -0500 | [diff] [blame] | 23 | struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, |
| 24 | const char *name, |
| 25 | struct sysfs_dirent *target); |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 26 | void kernfs_remove(struct sysfs_dirent *sd); |
| 27 | int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name, |
| 28 | const void *ns); |
Tejun Heo | 890ece1 | 2013-11-23 17:21:51 -0500 | [diff] [blame] | 29 | int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent, |
| 30 | const char *new_name, const void *new_ns); |
Tejun Heo | 93b2b8e | 2013-11-28 14:54:15 -0500 | [diff] [blame^] | 31 | void kernfs_enable_ns(struct sysfs_dirent *sd); |
Tejun Heo | 5d60418 | 2013-11-23 17:21:52 -0500 | [diff] [blame] | 32 | int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr); |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 33 | |
| 34 | #else /* CONFIG_SYSFS */ |
| 35 | |
Tejun Heo | 5d0e26b | 2013-11-23 17:21:50 -0500 | [diff] [blame] | 36 | static inline struct sysfs_dirent * |
Tejun Heo | 93b2b8e | 2013-11-28 14:54:15 -0500 | [diff] [blame^] | 37 | kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv, |
| 38 | const void *ns) |
| 39 | { return ERR_PTR(-ENOSYS); } |
| 40 | |
| 41 | static inline struct sysfs_dirent * |
Tejun Heo | 5d0e26b | 2013-11-23 17:21:50 -0500 | [diff] [blame] | 42 | kernfs_create_link(struct sysfs_dirent *parent, const char *name, |
| 43 | struct sysfs_dirent *target) |
| 44 | { return ERR_PTR(-ENOSYS); } |
| 45 | |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 46 | static inline void kernfs_remove(struct sysfs_dirent *sd) { } |
| 47 | |
| 48 | static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, |
| 49 | const char *name, const void *ns) |
| 50 | { return -ENOSYS; } |
| 51 | |
Tejun Heo | 890ece1 | 2013-11-23 17:21:51 -0500 | [diff] [blame] | 52 | static inline int kernfs_rename_ns(struct sysfs_dirent *sd, |
| 53 | struct sysfs_dirent *new_parent, |
| 54 | const char *new_name, const void *new_ns) |
| 55 | { return -ENOSYS; } |
| 56 | |
Tejun Heo | 93b2b8e | 2013-11-28 14:54:15 -0500 | [diff] [blame^] | 57 | static inline void kernfs_enable_ns(struct sysfs_dirent *sd) { } |
| 58 | |
Tejun Heo | 5d60418 | 2013-11-23 17:21:52 -0500 | [diff] [blame] | 59 | static inline int kernfs_setattr(struct sysfs_dirent *sd, |
| 60 | const struct iattr *iattr) |
| 61 | { return -ENOSYS; } |
| 62 | |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 63 | #endif /* CONFIG_SYSFS */ |
| 64 | |
Tejun Heo | 93b2b8e | 2013-11-28 14:54:15 -0500 | [diff] [blame^] | 65 | static inline struct sysfs_dirent * |
| 66 | kernfs_create_dir(struct sysfs_dirent *parent, const char *name, void *priv) |
| 67 | { |
| 68 | return kernfs_create_dir_ns(parent, name, priv, NULL); |
| 69 | } |
| 70 | |
Tejun Heo | 879f40d | 2013-11-23 17:21:49 -0500 | [diff] [blame] | 71 | static inline int kernfs_remove_by_name(struct sysfs_dirent *parent, |
| 72 | const char *name) |
| 73 | { |
| 74 | return kernfs_remove_by_name_ns(parent, name, NULL); |
| 75 | } |
| 76 | |
Tejun Heo | b8441ed | 2013-11-24 09:54:58 -0500 | [diff] [blame] | 77 | #endif /* __LINUX_KERNFS_H */ |