public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: David Miller <davem@davemloft.net>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	Tejun Heo <htejun@gmail.com>, Jay Vosburgh <fubar@us.ibm.com>,
	Andy Gospodarek <andy@greyhouse.net>
Subject: [PATCH 2/5] class: Implement support for class attrs in tagged sysfs directories.
Date: Thu, 13 Oct 2011 00:55:08 -0700	[thread overview]
Message-ID: <m1sjmx9vhf.fsf_-_@fess.ebiederm.org> (raw)
In-Reply-To: <m1wrc99vjx.fsf@fess.ebiederm.org> (Eric W. Biederman's message of "Thu, 13 Oct 2011 00:53:38 -0700")


Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 drivers/base/class.c   |   17 +++++++++++++++--
 include/linux/device.h |    2 ++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 4f1df2e..b80d91c 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -47,6 +47,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
 	return ret;
 }
 
+static const void *class_attr_namespace(struct kobject *kobj,
+					const struct attribute *attr)
+{
+	struct class_attribute *class_attr = to_class_attr(attr);
+	struct subsys_private *cp = to_subsys_private(kobj);
+	const void *ns = NULL;
+
+	if (class_attr->namespace)
+		ns = class_attr->namespace(cp->class, class_attr);
+	return ns;
+}
+
 static void class_release(struct kobject *kobj)
 {
 	struct subsys_private *cp = to_subsys_private(kobj);
@@ -72,8 +84,9 @@ static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject
 }
 
 static const struct sysfs_ops class_sysfs_ops = {
-	.show	= class_attr_show,
-	.store	= class_attr_store,
+	.show	   = class_attr_show,
+	.store	   = class_attr_store,
+	.namespace = class_attr_namespace,
 };
 
 static struct kobj_type class_ktype = {
diff --git a/include/linux/device.h b/include/linux/device.h
index c20dfbf..ea70bb2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -350,6 +350,8 @@ struct class_attribute {
 			char *buf);
 	ssize_t (*store)(struct class *class, struct class_attribute *attr,
 			const char *buf, size_t count);
+	const void *(*namespace)(struct class *class,
+				 const struct class_attribute *attr);
 };
 
 #define CLASS_ATTR(_name, _mode, _show, _store)			\
-- 
1.7.2.5


  reply	other threads:[~2011-10-13  7:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13  7:47 [PATCH 0/5] Better namespace handling for /sys/class/net/bonding_masters Eric W. Biederman
2011-10-13  7:53 ` [PATCH 1/5] sysfs: Implement support for tagged files in sysfs Eric W. Biederman
2011-10-13  7:55   ` Eric W. Biederman [this message]
2011-10-13  7:56     ` [PATCH 3/5] bonding: Use a per netns implementation of /sys/class/net/bonding_masters Eric W. Biederman
2011-10-13  8:01       ` [PATCH 4/5] sysfs: Remove support for tagged directories with untagged members Eric W. Biederman
2011-10-13  8:02         ` [PATCH 5/5] sysfs: Reject with a warning invalid uses of tagged directories Eric W. Biederman
2011-10-13 17:25 ` [PATCH 0/5] Better namespace handling for /sys/class/net/bonding_masters Greg KH
2011-10-19  4:09 ` David Miller
2011-10-19 13:27   ` Eric W. Biederman
2011-10-19 22:49     ` David Miller
2011-10-19 14:36   ` Greg KH

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=m1sjmx9vhf.fsf_-_@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --cc=fubar@us.ibm.com \
    --cc=gregkh@suse.de \
    --cc=htejun@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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