diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/kernfs.h | 60 | ||||
-rw-r--r-- | include/linux/sysfs.h | 9 |
2 files changed, 67 insertions, 2 deletions
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h new file mode 100644 index 000000000000..8cb673875715 --- /dev/null +++ b/include/linux/kernfs.h @@ -0,0 +1,60 @@ +/* + * kernfs.h - pseudo filesystem decoupled from vfs locking + * + * This file is released under the GPLv2. + */ + +#ifndef __LINUX_KERNFS_H +#define __LINUX_KERNFS_H + +#include <linux/kernel.h> +#include <linux/err.h> + +struct file; +struct iattr; + +struct sysfs_dirent; + +#ifdef CONFIG_SYSFS + +struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, + const char *name, + struct sysfs_dirent *target); +void kernfs_remove(struct sysfs_dirent *sd); +int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, const char *name, + const void *ns); +int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent, + const char *new_name, const void *new_ns); +int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr); + +#else /* CONFIG_SYSFS */ + +static inline struct sysfs_dirent * +kernfs_create_link(struct sysfs_dirent *parent, const char *name, + struct sysfs_dirent *target) +{ return ERR_PTR(-ENOSYS); } + +static inline void kernfs_remove(struct sysfs_dirent *sd) { } + +static inline int kernfs_remove_by_name_ns(struct sysfs_dirent *parent, + const char *name, const void *ns) +{ return -ENOSYS; } + +static inline int kernfs_rename_ns(struct sysfs_dirent *sd, + struct sysfs_dirent *new_parent, + const char *new_name, const void *new_ns) +{ return -ENOSYS; } + +static inline int kernfs_setattr(struct sysfs_dirent *sd, + const struct iattr *iattr) +{ return -ENOSYS; } + +#endif /* CONFIG_SYSFS */ + +static inline int kernfs_remove_by_name(struct sysfs_dirent *parent, + const char *name) +{ + return kernfs_remove_by_name_ns(parent, name, NULL); +} + +#endif /* __LINUX_KERNFS_H */ diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 6695040a0317..e17381a92e1a 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -12,6 +12,7 @@ #ifndef _SYSFS_H_ #define _SYSFS_H_ +#include <linux/kernfs.h> #include <linux/compiler.h> #include <linux/errno.h> #include <linux/list.h> @@ -175,8 +176,6 @@ struct sysfs_ops { ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); }; -struct sysfs_dirent; - #ifdef CONFIG_SYSFS int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), @@ -220,6 +219,8 @@ int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target, void sysfs_delete_link(struct kobject *dir, struct kobject *targ, const char *name); +void sysfs_enable_ns(struct sysfs_dirent *sd); + int __must_check sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp); int __must_check sysfs_create_groups(struct kobject *kobj, @@ -353,6 +354,10 @@ static inline void sysfs_delete_link(struct kobject *k, struct kobject *t, { } +static inline void sysfs_enable_ns(struct sysfs_dirent *sd) +{ +} + static inline int sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp) { |