summaryrefslogtreecommitdiffstats
path: root/fs/sysfs/sysfs.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-11-28 14:54:21 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-29 17:35:05 -0800
commitf6acf8bb6a40ba3bfcf542e4c4c9e8968c8cb57a (patch)
tree63a9a946dd065f636a20a9435e2e502313bef178 /fs/sysfs/sysfs.h
parentdd8a5b036b6e8d50854e130555f90f062c5eacec (diff)
downloadlinux-f6acf8bb6a40ba3bfcf542e4c4c9e8968c8cb57a.tar.bz2
sysfs, kernfs: introduce kernfs_ops
We're in the process of separating out core sysfs functionality into kernfs which will deal with sysfs_dirents directly. This patch introduces kernfs_ops which hosts methods kernfs users implement and updates fs/sysfs/file.c such that sysfs_kf_*() functions populate kernfs_ops and kernfs_file_*() functions call the matching entries from kernfs_ops. kernfs_ops contains the following groups of methods. * seq_show() - for kernfs files which use seq_file for reads. * read() - for direct read implementations. Used iff seq_show() is not implemented. * write() - for writes. * mmap() - for mmaps. Notes: * sysfs_elem_attr->ops is added so that kernfs_ops can be accessed from sysfs_dirent. kernfs_ops() helper is added to verify locking and access the field. * SYSFS_FLAG_HAS_(SEQ_SHOW|MMAP) added. sd->s_attr->ops is accessible only while holding active_ref and there are cases where we want to take different actions depending on which ops are implemented. These two flags cache whether the two ops are implemented for those. * kernfs_file_*() no longer test sysfs type but chooses different behaviors depending on which methods in kernfs_ops are implemented. The conversions are trivial except for the open path. As kernfs_file_open() now decides whether to allow read/write accesses depending on the kernfs_ops implemented, the presence of methods in kobjs and attribute_bin should be propagated to kernfs_ops. sysfs_add_file_mode_ns() is updated so that it propagates presence / absence of the callbacks through _empty, _ro, _wo, _rw kernfs_ops. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs/sysfs.h')
-rw-r--r--fs/sysfs/sysfs.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 619250d2d7c1..c05e0ddd0268 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -27,6 +27,7 @@ struct sysfs_elem_symlink {
};
struct sysfs_elem_attr {
+ const struct kernfs_ops *ops;
struct sysfs_open_dirent *open;
};
@@ -89,6 +90,8 @@ struct sysfs_dirent {
#define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK
#define SYSFS_FLAG_NS 0x01000
#define SYSFS_FLAG_REMOVED 0x02000
+#define SYSFS_FLAG_HAS_SEQ_SHOW 0x04000
+#define SYSFS_FLAG_HAS_MMAP 0x08000
static inline unsigned int sysfs_type(struct sysfs_dirent *sd)
{