aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2010-05-03 17:23:15 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-21 12:37:31 -0400
commitbe867b194a3ae3c680c29521287ae49b4d44d420 (patch)
tree1b3ad125d02603c6a9cc4bb8ae518695d7c6a66d /fs
parentf349cf34731c3b3eddbcd63cb04489aee2c405bd (diff)
sysfs: Comment sysfs directory tagging logic
Add some in-line comments to explain the new infrastructure, which was introduced to support sysfs directory tagging with namespaces. I think an overall description someplace might be good too, but it didn't really seem to fit into Documentation/filesystems/sysfs.txt, which appears more geared toward users, rather than maintainers, of sysfs. (Tejun, please let me know if I can make anything clearer or failed altogether to comment something that should be commented.) Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/sysfs/dir.c8
-rw-r--r--fs/sysfs/sysfs.h13
2 files changed, 20 insertions, 1 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index a63eb4ba7867..7e54bac8c4b0 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -614,6 +614,14 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name,
614 KOBJ_NS_TYPE_NONE, NULL, name, p_sd); 614 KOBJ_NS_TYPE_NONE, NULL, name, p_sd);
615} 615}
616 616
617/**
618 * sysfs_read_ns_type: return associated ns_type
619 * @kobj: the kobject being queried
620 *
621 * Each kobject can be tagged with exactly one namespace type
622 * (i.e. network or user). Return the ns_type associated with
623 * this object if any
624 */
617static enum kobj_ns_type sysfs_read_ns_type(struct kobject *kobj) 625static enum kobj_ns_type sysfs_read_ns_type(struct kobject *kobj)
618{ 626{
619 const struct kobj_ns_type_operations *ops; 627 const struct kobj_ns_type_operations *ops;
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 93847d54c2e3..6a13105b5594 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -58,7 +58,7 @@ struct sysfs_dirent {
58 struct sysfs_dirent *s_sibling; 58 struct sysfs_dirent *s_sibling;
59 const char *s_name; 59 const char *s_name;
60 60
61 const void *s_ns; 61 const void *s_ns; /* namespace tag */
62 union { 62 union {
63 struct sysfs_elem_dir s_dir; 63 struct sysfs_elem_dir s_dir;
64 struct sysfs_elem_symlink s_symlink; 64 struct sysfs_elem_symlink s_symlink;
@@ -82,6 +82,7 @@ struct sysfs_dirent {
82#define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) 82#define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK)
83#define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR) 83#define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR)
84 84
85/* identify any namespace tag on sysfs_dirents */
85#define SYSFS_NS_TYPE_MASK 0xff00 86#define SYSFS_NS_TYPE_MASK 0xff00
86#define SYSFS_NS_TYPE_SHIFT 8 87#define SYSFS_NS_TYPE_SHIFT 8
87 88
@@ -93,6 +94,10 @@ static inline unsigned int sysfs_type(struct sysfs_dirent *sd)
93 return sd->s_flags & SYSFS_TYPE_MASK; 94 return sd->s_flags & SYSFS_TYPE_MASK;
94} 95}
95 96
97/*
98 * Return any namespace tags on this dirent.
99 * enum kobj_ns_type is defined in linux/kobject.h
100 */
96static inline enum kobj_ns_type sysfs_ns_type(struct sysfs_dirent *sd) 101static inline enum kobj_ns_type sysfs_ns_type(struct sysfs_dirent *sd)
97{ 102{
98 return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT; 103 return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT;
@@ -123,6 +128,12 @@ struct sysfs_addrm_cxt {
123/* 128/*
124 * mount.c 129 * mount.c
125 */ 130 */
131
132/*
133 * Each sb is associated with a set of namespace tags (i.e.
134 * the network namespace of the task which mounted this sysfs
135 * instance).
136 */
126struct sysfs_super_info { 137struct sysfs_super_info {
127 const void *ns[KOBJ_NS_TYPES]; 138 const void *ns[KOBJ_NS_TYPES];
128}; 139};