diff options
author | Tejun Heo <tj@kernel.org> | 2013-11-28 14:54:24 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-29 17:48:14 -0800 |
commit | 496f73944a4a974f89d48920bf368aec8841b195 (patch) | |
tree | ceaf60c390103523edecb4a3d7ff3f79b3f50171 /include/linux/kernfs.h | |
parent | a7dc66dfb4c6d6c1d7c14d5106ce467f1dbd4eba (diff) | |
download | linux-496f73944a4a974f89d48920bf368aec8841b195.tar.gz linux-496f73944a4a974f89d48920bf368aec8841b195.tar.bz2 linux-496f73944a4a974f89d48920bf368aec8841b195.zip |
sysfs, kernfs: introduce kernfs_create_file[_ns]()
Introduce kernfs interface to create a file which takes and returns
sysfs_dirents.
The actual file creation part is separated out from
sysfs_add_file_mode_ns() into kernfs_create_file_ns(). The former now
only decides the kernfs_ops to use and the file's size and invokes the
latter.
This patch doesn't introduce behavior changes.
v2: Dummy implementation for !CONFIG_SYSFS updated to return -ENOSYS.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/kernfs.h')
-rw-r--r-- | include/linux/kernfs.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 97c6c0f91325..d0912cf02087 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -64,6 +64,11 @@ struct kernfs_ops { struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv, const void *ns); +struct sysfs_dirent *kernfs_create_file_ns(struct sysfs_dirent *parent, + const char *name, + umode_t mode, loff_t size, + const struct kernfs_ops *ops, + void *priv, const void *ns); struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, const char *name, struct sysfs_dirent *target); @@ -83,6 +88,12 @@ kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv, { return ERR_PTR(-ENOSYS); } static inline struct sysfs_dirent * +kernfs_create_file_ns(struct sysfs_dirent *parent, const char *name, + umode_t mode, loff_t size, const struct kernfs_ops *ops, + void *priv, const void *ns) +{ return ERR_PTR(-ENOSYS); } + +static inline struct sysfs_dirent * kernfs_create_link(struct sysfs_dirent *parent, const char *name, struct sysfs_dirent *target) { return ERR_PTR(-ENOSYS); } @@ -112,6 +123,13 @@ kernfs_create_dir(struct sysfs_dirent *parent, const char *name, void *priv) return kernfs_create_dir_ns(parent, name, priv, NULL); } +static inline struct sysfs_dirent * +kernfs_create_file(struct sysfs_dirent *parent, const char *name, umode_t mode, + loff_t size, const struct kernfs_ops *ops, void *priv) +{ + return kernfs_create_file_ns(parent, name, mode, size, ops, priv, NULL); +} + static inline int kernfs_remove_by_name(struct sysfs_dirent *parent, const char *name) { |