From: gaspa@yattaweb.it (Gasparini Andrea)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Attr Groups in sysfs.
Date: Mon, 18 Apr 2011 11:45:23 +0200 [thread overview]
Message-ID: <BANLkTi=d4DfGvzMCXpG3WUFmMkUL70v4=A@mail.gmail.com> (raw)
Hi,
I've a pattern similar to this in sysfs: /sys/.../mykobj/myattr_group/attr.
And I've some different attr groups, but I'm willing to group also the
get/set functions and recognize at runtime which kobj,group,and
attribute is called inside the functions.
But, if I'm not wrong the attribute functions are called:
static ssize_t some_attribute_set(struct kobject *kobj,
struct container_attribute *attr, const char *buf, size_t count)
And I can get the "mykobj" name with kobj->name,
and attribute names by attr->attr.name.
I'm missing only the myattr_group name... anyone has a clue of how can
I access this?
Just for completeness, I'm working on a 2.6.38 kernel, and I'm
declaring the groups this way:
struct container_attribute {
struct attribute attr;
ssize_t (*show)(struct kobject *, struct container_attribute *, char *);
ssize_t (*store)(struct kobject *, struct container_attribute *,
const char *, size_t);
};
static struct attribute *lot_of_attrs[] = {
first_attribute.attr,
and_so_on.attr,
NULL,
};
static struct attribute_group my_attr_group_0 = {
.name = "myattr_group_0",
.attrs = lots_of_attrs,
};
And adding to my kobject this way:
retval = sysfs_create_group(mykobj, &my_attr_group_0);
Thanks, bye!
--
-gaspa-
next reply other threads:[~2011-04-18 9:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-18 9:45 Gasparini Andrea [this message]
2011-04-18 14:14 ` Attr Groups in sysfs Greg KH
2011-04-18 14:29 ` Gasparini Andrea
2011-04-18 16:08 ` 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='BANLkTi=d4DfGvzMCXpG3WUFmMkUL70v4=A@mail.gmail.com' \
--to=gaspa@yattaweb.it \
--cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).