• Tejun Heo's avatar
    sysfs: drop kobj_ns_type handling · cb26a311
    Tejun Heo authored
    The way namespace tags are implemented in sysfs is more complicated
    than necessary.  As each tag is a pointer value and required to be
    non-NULL under a namespace enabled parent, there's no need to record
    separately what type each tag is or where namespace is enabled.
    
    If multiple namespace types are needed, which currently aren't, we can
    simply compare the tag to a set of allowed tags in the superblock
    assuming that the tags, being pointers, won't have the same value
    across multiple types.  Also, whether to filter by namespace tag or
    not can be trivially determined by whether the node has any tagged
    children or not.
    
    This patch rips out kobj_ns_type handling from sysfs.  sysfs no longer
    cares whether specific type of namespace is enabled or not.  If a
    sysfs_dirent has a non-NULL tag, the parent is marked as needing
    namespace filtering and the value is tested against the allowed set of
    tags for the superblock (currently only one but increasing this number
    isn't difficult) and the sysfs_dirent is ignored if it doesn't match.
    
    This removes most kobject namespace knowledge from sysfs proper which
    will enable proper separation and layering of sysfs.  The namespace
    sanity checks in fs/sysfs/dir.c are replaced by the new sanity check
    in kobject_namespace().  As this is the only place ktype->namespace()
    is called for sysfs, this doesn't weaken the sanity check
    significantly.  I omitted converting the sanity check in
    sysfs_do_create_link_sd().  While the check can be shifted to upper
    layer, mistakes there are well contained and should be easily visible
    anyway.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Cc: Eric W. Biederman <ebiederm@xmission.com>
    Cc: Kay Sievers <kay@vrfy.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    cb26a311
sysfs.h 6.41 KB