* [PATCH 1/3] exporting capability name/code pairs (final)
@ 2008-02-22 1:49 Kohei KaiGai
2008-02-22 17:04 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Kohei KaiGai @ 2008-02-22 1:49 UTC (permalink / raw)
To: greg, morgan, serue; +Cc: linux-security-module, linux-kernel
[1/3] Add a private data field within kobj_attribute structure.
This patch add a private data field, declared as void *, within kobj_attribute
structure. The _show() and _store() method in the sysfs attribute entries can
refer this information to identify what entry is accessed.
It makes easier to share a single method implementation with several similar
entries, like ones to export the list of capabilities the running kernel
supported.
Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
--
include/linux/kobject.h | 1 +
include/linux/sysfs.h | 7 +++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index caa3f41..57d5bf1 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -130,6 +130,7 @@ struct kobj_attribute {
char *buf);
ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count);
+ void *data; /* a private field */
};
extern struct sysfs_ops kobj_sysfs_ops;
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 8027104..6f40ff9 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -50,6 +50,13 @@ struct attribute_group {
.store = _store, \
}
+#define __ATTR_DATA(_name,_mode,_show,_store,_data) { \
+ .attr = {.name = __stringify(_name), .mode = _mode }, \
+ .show = _show, \
+ .store = _store, \
+ .data = (void *)(_data), \
+}
+
#define __ATTR_RO(_name) { \
.attr = { .name = __stringify(_name), .mode = 0444 }, \
.show = _name##_show, \
--
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai@ak.jp.nec.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH 1/3] exporting capability name/code pairs (final)
2008-02-22 1:49 [PATCH 1/3] exporting capability name/code pairs (final) Kohei KaiGai
@ 2008-02-22 17:04 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2008-02-22 17:04 UTC (permalink / raw)
To: Kohei KaiGai; +Cc: morgan, serue, linux-security-module, linux-kernel
On Fri, Feb 22, 2008 at 10:49:26AM +0900, Kohei KaiGai wrote:
> [1/3] Add a private data field within kobj_attribute structure.
Your "Subject" did not line up with this description, please change your
patch sending format for the next time.
> This patch add a private data field, declared as void *, within kobj_attribute
> structure. The _show() and _store() method in the sysfs attribute entries can
> refer this information to identify what entry is accessed.
> It makes easier to share a single method implementation with several similar
> entries, like ones to export the list of capabilities the running kernel
> supported.
>
> Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
This looks fine, but I'll not take it unless the documentation is
updated, as well as the sample code.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-22 17:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-22 1:49 [PATCH 1/3] exporting capability name/code pairs (final) Kohei KaiGai
2008-02-22 17:04 ` Greg KH
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®