diff options
Diffstat (limited to 'fs/sysfs/group.c')
-rw-r--r-- | fs/sysfs/group.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 39a019936768..51b56e6d9537 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c | |||
@@ -73,13 +73,26 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj, | |||
73 | } | 73 | } |
74 | 74 | ||
75 | if (grp->bin_attrs) { | 75 | if (grp->bin_attrs) { |
76 | for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) { | 76 | for (i = 0, bin_attr = grp->bin_attrs; *bin_attr; i++, bin_attr++) { |
77 | umode_t mode = (*bin_attr)->attr.mode; | ||
78 | |||
77 | if (update) | 79 | if (update) |
78 | kernfs_remove_by_name(parent, | 80 | kernfs_remove_by_name(parent, |
79 | (*bin_attr)->attr.name); | 81 | (*bin_attr)->attr.name); |
82 | if (grp->is_bin_visible) { | ||
83 | mode = grp->is_bin_visible(kobj, *bin_attr, i); | ||
84 | if (!mode) | ||
85 | continue; | ||
86 | } | ||
87 | |||
88 | WARN(mode & ~(SYSFS_PREALLOC | 0664), | ||
89 | "Attribute %s: Invalid permissions 0%o\n", | ||
90 | (*bin_attr)->attr.name, mode); | ||
91 | |||
92 | mode &= SYSFS_PREALLOC | 0664; | ||
80 | error = sysfs_add_file_mode_ns(parent, | 93 | error = sysfs_add_file_mode_ns(parent, |
81 | &(*bin_attr)->attr, true, | 94 | &(*bin_attr)->attr, true, |
82 | (*bin_attr)->attr.mode, NULL); | 95 | mode, NULL); |
83 | if (error) | 96 | if (error) |
84 | break; | 97 | break; |
85 | } | 98 | } |