From: Kohei KaiGai <kaigai@ak.jp.nec.com>
To: Greg KH <greg@kroah.com>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>,
Li Zefan <lizf@cn.fujitsu.com>,
akpm@osdl.org, "Andrew G. Morgan" <morgan@kernel.org>,
jmorris@namei.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, adobriyan@gmail.com
Subject: Re: [PATCH] exporting capability code/name pairs (try #6)
Date: Wed, 20 Feb 2008 14:38:16 +0900 [thread overview]
Message-ID: <47BBBCC8.7070707@ak.jp.nec.com> (raw)
In-Reply-To: <20080220050236.GA20181@kroah.com>
Greg KH wrote:
> On Wed, Feb 20, 2008 at 01:38:59PM +0900, Kohei KaiGai wrote:
>>>> If we can have a private member in kobj_attribute, we can found the
>> content
>>>> to be returned in a single step.
>>> Ok, again, just send me a patch that adds this functionality and we will
>>> be very glad to consider it.
>> [1/2] Add a private data field within kobj_attribute structure.
>>
>> This patch add a private data field, declared as void *, within
>> kobj_attribute
>> structure. Anyone wants to use sysfs can store their private data to refer
>> at
>> _show() and _store() method.
>> It enables to share a single method function with several similar entries,
>> like ones to export the list of capabilities the running kernel supported.
>
> But your patch 2/2 doesn't use this interface, why not?
Really?
The following two _show() methods shared by every capabilities refer
the private member of kobj_attribute.
| +static ssize_t capability_name_show(struct kobject *kobj,
| + struct kobj_attribute *attr,
| + char *buffer)
| +{
| + /* It returns numerical representation of capability. */
| + return scnprintf(buffer, PAGE_SIZE, "%d\n", (int) attr->data);
| +}
| +
| +static ssize_t capability_code_show(struct kobject *kobj,
| + struct kobj_attribute *attr,
| + char *buffer)
| +{
| + /* It returns symbolic representation of capability. */
| + return scnprintf(buffer, PAGE_SIZE, "%s\n", (char *) attr->data);
| +}
>> 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 */
>
> Hm, can you really use this?
Yes,
>> 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), \
>> +}
>
> I don't see how this would be any different from the original? You are
> always passed a kobject, which can be embedded in anything else.
The intension of the latest patch is same as the version which uses
capability_attribute structure.
It enables to store the content to be returned in the expanded field.
Applying kobj_attribute killed needs to declare my own structure.
However, every entries had its own _show() method, generated by macros
automatically, in the previous version. It fundamentally differ from
the latest one.
> Could you also modify the documentation and the sample code to use this
> new field, showing how it is to be used, and testing that it works
> properly at the same time?
OK, Please wait for a while.
Thanks,
--
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai@ak.jp.nec.com>
next prev parent reply other threads:[~2008-02-20 5:39 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-25 5:18 [PATCH 1/3] exporting capability code/name pairs (try 2nd) Kohei KaiGai
2008-01-25 7:32 ` Andrew G. Morgan
2008-01-25 11:41 ` Kohei KaiGai
2008-02-01 5:17 ` [PATCH 1/3] exporting capability code/name pairs (try #3) Kohei KaiGai
2008-02-04 16:21 ` Serge E. Hallyn
2008-02-06 2:27 ` Kohei KaiGai
2008-02-06 5:08 ` Serge E. Hallyn
2008-02-08 9:42 ` [PATCH] exporting capability code/name pairs (try #4) Kohei KaiGai
2008-02-08 16:48 ` Andrew G. Morgan
2008-02-12 0:56 ` Kohei KaiGai
2008-02-08 19:23 ` Alexey Dobriyan
2008-02-12 1:10 ` Kohei KaiGai
2008-02-12 21:58 ` Alexey Dobriyan
2008-02-13 8:14 ` Kohei KaiGai
2008-02-12 18:08 ` Serge E. Hallyn
2008-02-13 8:01 ` Kohei KaiGai
2008-02-15 1:38 ` [PATCH] exporting capability code/name pairs (try #5) Kohei KaiGai
2008-02-15 1:58 ` Li Zefan
2008-02-15 2:58 ` [PATCH] exporting capability code/name pairs (try #5.1) Kohei KaiGai
2008-02-15 18:38 ` Serge E. Hallyn
2008-02-15 18:50 ` Greg KH
2008-02-18 7:12 ` Kohei KaiGai
2008-02-18 7:40 ` Greg KH
2008-02-18 8:45 ` Kohei KaiGai
2008-02-19 16:16 ` Greg KH
2008-02-20 4:38 ` [PATCH] exporting capability code/name pairs (try #6) Kohei KaiGai
2008-02-20 5:02 ` Greg KH
2008-02-20 5:38 ` Kohei KaiGai [this message]
2008-02-20 5:53 ` Greg KH
2008-02-20 6:19 ` [PATCH] exporting capability code/name pairs (try #6.1) Kohei KaiGai
2008-02-20 6:16 ` Kohei KaiGai
2008-02-20 4:39 ` [PATCH] exporting capability code/name pairs (try #6) Kohei KaiGai
2008-02-20 6:16 ` [PATCH] exporting capability code/name pairs (try #6.1) Kohei KaiGai
2008-02-18 15:15 ` [PATCH] exporting capability code/name pairs (try #5.1) Serge E. Hallyn
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=47BBBCC8.7070707@ak.jp.nec.com \
--to=kaigai@ak.jp.nec.com \
--cc=adobriyan@gmail.com \
--cc=akpm@osdl.org \
--cc=greg@kroah.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=morgan@kernel.org \
--cc=serue@us.ibm.com \
/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