From: Greg KH <greg@kroah.com>
To: James Bottomley <James.Bottomley@SteelEye.com>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>,
Kay Sievers <kay.sievers@vrfy.org>,
linux-scsi <linux-scsi@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sysfs: add filter function to groups
Date: Tue, 30 Oct 2007 20:55:06 -0700 [thread overview]
Message-ID: <20071031035506.GH14910@kroah.com> (raw)
In-Reply-To: <1193768743.3321.91.camel@localhost.localdomain>
On Tue, Oct 30, 2007 at 01:25:43PM -0500, James Bottomley wrote:
> On Mon, 2007-10-29 at 18:58 +0100, Stefan Richter wrote:
> > James Bottomley wrote:
> > >> > struct attribute_group {
> > >> > const char *name;
> > >> > + int (*filter_show)(struct kobject *, int);
> >
> > > Actually, it returns a true/false value indicating whether the given
> > > attribute should be displayed.
> >
> > How about this:
> >
> > int (*is_visible)(...);
>
> OK, so is this latest revision acceptable to everyone?
>
> James
>
> Index: BUILD-2.6/fs/sysfs/group.c
> ===================================================================
> --- BUILD-2.6.orig/fs/sysfs/group.c 2007-10-28 17:27:04.000000000 -0500
> +++ BUILD-2.6/fs/sysfs/group.c 2007-10-30 12:35:47.000000000 -0500
> @@ -16,25 +16,31 @@
> #include "sysfs.h"
>
>
> -static void remove_files(struct sysfs_dirent *dir_sd,
> +static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
> const struct attribute_group *grp)
> {
> struct attribute *const* attr;
> + int i;
>
> - for (attr = grp->attrs; *attr; attr++)
> - sysfs_hash_and_remove(dir_sd, (*attr)->name);
> + for (i = 0, attr = grp->attrs; *attr; i++, attr++)
> + if (grp->is_visible &&
> + grp->is_visible(kobj, *attr, i))
> + sysfs_hash_and_remove(dir_sd, (*attr)->name);
Hm, doesn't this break for the zillions of attribute groups that do not
have the is_visible function set?
> -static int create_files(struct sysfs_dirent *dir_sd,
> +static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
> const struct attribute_group *grp)
> {
> struct attribute *const* attr;
> - int error = 0;
> + int error = 0, i;
>
> - for (attr = grp->attrs; *attr && !error; attr++)
> - error = sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR);
> + for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++)
> + if (grp->is_visible &&
> + grp->is_visible(kobj, *attr, i))
> + error |=
> + sysfs_add_file(dir_sd, *attr, SYSFS_KOBJ_ATTR);
Same problem here, if grp->is_visible is not set, sysfs_add_file() would
never be called, right?
Other than the logic problem (I think), I have no issue with this idea
at all. Care to redo this so it works?
thanks,
greg k-h
next prev parent reply other threads:[~2007-10-31 3:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-29 15:16 [PATCH] sysfs: add filter function to groups James Bottomley
2007-10-29 16:54 ` Kay Sievers
2007-10-29 16:57 ` James Bottomley
2007-10-29 17:18 ` Cornelia Huck
2007-10-29 17:24 ` James Bottomley
2007-10-29 17:27 ` Jeff Garzik
2007-10-29 17:29 ` James Bottomley
2007-10-30 9:00 ` Cornelia Huck
2007-10-30 8:55 ` Cornelia Huck
2007-10-29 17:27 ` Kay Sievers
2007-10-29 17:28 ` James Bottomley
2007-10-29 17:43 ` Kay Sievers
2007-10-29 17:58 ` Stefan Richter
2007-10-29 18:12 ` James Bottomley
2007-10-30 18:25 ` James Bottomley
2007-10-30 19:31 ` Stefan Richter
2007-10-30 19:47 ` Kay Sievers
2007-10-31 0:40 ` Mark M. Hoffman
2007-10-31 2:01 ` Kay Sievers
2007-10-31 11:28 ` Mark M. Hoffman
2007-10-31 3:55 ` Greg KH [this message]
2007-10-31 9:41 ` Cornelia Huck
2007-10-31 9:52 ` Stefan Richter
2007-10-31 10:20 ` Cornelia Huck
2007-10-31 10:37 ` Stefan Richter
2007-10-31 12:19 ` Cornelia Huck
2007-10-31 14:38 ` James Bottomley
2007-10-31 17:29 ` Greg KH
2007-11-04 14:12 ` James Bottomley
2007-11-04 19:06 ` 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=20071031035506.GH14910@kroah.com \
--to=greg@kroah.com \
--cc=James.Bottomley@SteelEye.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=stefanr@s5r6.in-berlin.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.