From: "Emilio López" <emilio.lopez@collabora.co.uk>
To: gregkh@linuxfoundation.org, olof@lixom.net, kgene@kernel.org,
k.kozlowski@samsung.com
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org,
"Emilio López" <emilio.lopez@collabora.co.uk>
Subject: [PATCH 1/3] sysfs: Fix is_visible() support for binary attributes
Date: Tue, 8 Sep 2015 09:07:44 -0300 [thread overview]
Message-ID: <1441714066-5599-2-git-send-email-emilio.lopez@collabora.co.uk> (raw)
In-Reply-To: <1441714066-5599-1-git-send-email-emilio.lopez@collabora.co.uk>
According to the sysfs header file:
"The returned value will replace static permissions defined in
struct attribute or struct bin_attribute."
but this isn't the case, as is_visible is only called on
struct attribute only. This patch adds the code paths required
to support is_visible() on binary attributes.
Signed-off-by: Emilio López <emilio.lopez@collabora.co.uk>
---
fs/sysfs/group.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 39a0199..eb6996a 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -37,10 +37,10 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj,
{
struct attribute *const *attr;
struct bin_attribute *const *bin_attr;
- int error = 0, i;
+ int error = 0, i = 0;
if (grp->attrs) {
- for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) {
+ for (attr = grp->attrs; *attr && !error; i++, attr++) {
umode_t mode = (*attr)->mode;
/*
@@ -73,13 +73,27 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj,
}
if (grp->bin_attrs) {
- for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) {
+ for (bin_attr = grp->bin_attrs; *bin_attr; i++, bin_attr++) {
+ umode_t mode = (*bin_attr)->attr.mode;
+
if (update)
kernfs_remove_by_name(parent,
(*bin_attr)->attr.name);
+ if (grp->is_visible) {
+ mode = grp->is_visible(kobj,
+ &(*bin_attr)->attr, i);
+ if (!mode)
+ continue;
+ }
+
+ WARN(mode & ~(SYSFS_PREALLOC | 0664),
+ "Attribute %s: Invalid permissions 0%o\n",
+ (*bin_attr)->attr.name, mode);
+
+ mode &= SYSFS_PREALLOC | 0664;
error = sysfs_add_file_mode_ns(parent,
&(*bin_attr)->attr, true,
- (*bin_attr)->attr.mode, NULL);
+ mode, NULL);
if (error)
break;
}
--
2.1.4
next prev parent reply other threads:[~2015-09-08 12:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-08 12:07 [PATCH 0/3] platform/chrome: vboot context support Emilio López
2015-09-08 12:07 ` Emilio López [this message]
2015-09-08 15:30 ` [PATCH 1/3] sysfs: Fix is_visible() support for binary attributes Guenter Roeck
2015-09-08 19:10 ` Greg KH
2015-09-08 19:30 ` Guenter Roeck
2015-09-09 0:51 ` Emilio López
2015-09-09 1:10 ` Guenter Roeck
2015-09-09 3:58 ` Greg KH
2015-09-09 4:12 ` Guenter Roeck
2015-09-09 13:14 ` Emilio López
2015-09-09 13:30 ` Greg KH
2015-09-09 13:30 ` Guenter Roeck
2015-09-08 12:07 ` [PATCH 2/3] platform/chrome: Support reading/writing the vboot context Emilio López
2015-09-08 12:07 ` [PATCH 3/3] ARM: dts: Enable EC vboot context support on Peach boards Emilio López
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441714066-5599-2-git-send-email-emilio.lopez@collabora.co.uk \
--to=emilio.lopez@collabora.co.uk \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=k.kozlowski@samsung.com \
--cc=kgene@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=olof@lixom.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®