* UIO sysfs attributes broken in 2.6.25-rc1 @ 2008-02-13 17:03 Hans-Jürgen Koch 2008-02-13 17:33 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Hans-Jürgen Koch @ 2008-02-13 17:03 UTC (permalink / raw) To: linux-kernel, Greg KH In 2.6.25-rc1, there's a strange effect: Although the map attributes "addr" and "size" show up correctly: -r--r--r-- 1 root root 4096 2008-02-13 17:49 addr -r--r--r-- 1 root root 4096 2008-02-13 17:49 size you cannot access them, not even as root. Something like "cat addr" fails with a no-permission-error. It works fine in 2.6.24-rc8. This is probably related to this patch: http://lkml.org/lkml/2008/1/25/149 Unfortunately, I signed-off that one, too... I checked if all sysfs files appear, but didn't try to access them. Sorry. Greg, any ideas? Thanks, Hans ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: UIO sysfs attributes broken in 2.6.25-rc1 2008-02-13 17:03 UIO sysfs attributes broken in 2.6.25-rc1 Hans-Jürgen Koch @ 2008-02-13 17:33 ` Greg KH 2008-02-19 9:55 ` [PATCH] UIO: introduce sysfs_ops for map_attr_ktype Brandon Philips 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2008-02-13 17:33 UTC (permalink / raw) To: Hans-J??rgen Koch; +Cc: linux-kernel On Wed, Feb 13, 2008 at 06:03:04PM +0100, Hans-J??rgen Koch wrote: > In 2.6.25-rc1, there's a strange effect: > Although the map attributes "addr" and "size" show up correctly: > > -r--r--r-- 1 root root 4096 2008-02-13 17:49 addr > -r--r--r-- 1 root root 4096 2008-02-13 17:49 size > > you cannot access them, not even as root. Something like "cat addr" > fails with a no-permission-error. It works fine in 2.6.24-rc8. > > This is probably related to this patch: > > http://lkml.org/lkml/2008/1/25/149 > > Unfortunately, I signed-off that one, too... I checked if all sysfs > files appear, but didn't try to access them. Sorry. Heh, well at least it wasn't just me that thought the patch was correct :) > Greg, any ideas? I'll look into it this afternoon... thanks, greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] UIO: introduce sysfs_ops for map_attr_ktype 2008-02-13 17:33 ` Greg KH @ 2008-02-19 9:55 ` Brandon Philips 2008-02-19 12:12 ` Hans-Jürgen Koch 2008-02-20 6:54 ` Greg KH 0 siblings, 2 replies; 5+ messages in thread From: Brandon Philips @ 2008-02-19 9:55 UTC (permalink / raw) To: Greg KH; +Cc: Hans-J??rgen Koch, linux-kernel This fixes two bugs with UIO that cropped up recently in -rc1 1) WARNING: at fs/sysfs/file.c:334 sysfs_open_file when trying to open a map addr/size file - complaining about missing sysfs_ops for ktype 2) Permission denied when reading uio/uio0/maps/map0/{addr,size} when files are mode S_IRUGO Also fix a typo: attr_attribute -> addr_attribute Signed-off-by: Brandon Philips <bphilips@suse.de> --- drivers/uio/uio.c | 54 ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 17 deletions(-) Index: linux-2.6/drivers/uio/uio.c =================================================================== --- linux-2.6.orig/drivers/uio/uio.c +++ linux-2.6/drivers/uio/uio.c @@ -57,29 +57,29 @@ struct uio_map { }; #define to_map(map) container_of(map, struct uio_map, kobj) - -static ssize_t map_attr_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) +static ssize_t map_addr_show(struct uio_mem *mem, char *buf) { - struct uio_map *map = to_map(kobj); - struct uio_mem *mem = map->mem; - - if (strncmp(attr->attr.name, "addr", 4) == 0) - return sprintf(buf, "0x%lx\n", mem->addr); - - if (strncmp(attr->attr.name, "size", 4) == 0) - return sprintf(buf, "0x%lx\n", mem->size); + return sprintf(buf, "0x%lx\n", mem->addr); +} - return -ENODEV; +static ssize_t map_size_show(struct uio_mem *mem, char *buf) +{ + return sprintf(buf, "0x%lx\n", mem->size); } -static struct kobj_attribute attr_attribute = - __ATTR(addr, S_IRUGO, map_attr_show, NULL); -static struct kobj_attribute size_attribute = - __ATTR(size, S_IRUGO, map_attr_show, NULL); +struct uio_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct uio_mem *, char *); + ssize_t (*store)(struct uio_mem *, const char *, size_t); +}; + +static struct uio_sysfs_entry addr_attribute = + __ATTR(addr, S_IRUGO, map_addr_show, NULL); +static struct uio_sysfs_entry size_attribute = + __ATTR(size, S_IRUGO, map_size_show, NULL); static struct attribute *attrs[] = { - &attr_attribute.attr, + &addr_attribute.attr, &size_attribute.attr, NULL, /* need to NULL terminate the list of attributes */ }; @@ -90,8 +90,28 @@ static void map_release(struct kobject * kfree(map); } +static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + struct uio_map *map = to_map(kobj); + struct uio_mem *mem = map->mem; + struct uio_sysfs_entry *entry; + + entry = container_of(attr, struct uio_sysfs_entry, attr); + + if (!entry->show) + return -EIO; + + return entry->show(mem, buf); +} + +static struct sysfs_ops uio_sysfs_ops = { + .show = map_type_show, +}; + static struct kobj_type map_attr_type = { .release = map_release, + .sysfs_ops = &uio_sysfs_ops, .default_attrs = attrs, }; ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] UIO: introduce sysfs_ops for map_attr_ktype 2008-02-19 9:55 ` [PATCH] UIO: introduce sysfs_ops for map_attr_ktype Brandon Philips @ 2008-02-19 12:12 ` Hans-Jürgen Koch 2008-02-20 6:54 ` Greg KH 1 sibling, 0 replies; 5+ messages in thread From: Hans-Jürgen Koch @ 2008-02-19 12:12 UTC (permalink / raw) To: Brandon Philips; +Cc: Greg KH, linux-kernel Am Tue, 19 Feb 2008 01:55:05 -0800 schrieb Brandon Philips <brandon@ifup.org>: > This fixes two bugs with UIO that cropped up recently in -rc1 > > 1) WARNING: at fs/sysfs/file.c:334 sysfs_open_file when trying to open > a map addr/size file - complaining about missing sysfs_ops for > ktype > 2) Permission denied when reading uio/uio0/maps/map0/{addr,size} when > files are mode S_IRUGO > > Also fix a typo: attr_attribute -> addr_attribute Hi Brandon, thanks a lot for that one! I've tested with 2.6.25-rc2 with a Hilscher NetX PCI card, works without problems. All attributes are accessible. Makes 2.6.25-rc usable again :-) Thanks, Hans > > Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Hans J. Koch <hjk@linutronix.de> > > --- > drivers/uio/uio.c | 54 > ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 > insertions(+), 17 deletions(-) > > Index: linux-2.6/drivers/uio/uio.c > =================================================================== > --- linux-2.6.orig/drivers/uio/uio.c > +++ linux-2.6/drivers/uio/uio.c > @@ -57,29 +57,29 @@ struct uio_map { > }; > #define to_map(map) container_of(map, struct uio_map, kobj) > > - > -static ssize_t map_attr_show(struct kobject *kobj, struct > kobj_attribute *attr, > - char *buf) > +static ssize_t map_addr_show(struct uio_mem *mem, char *buf) > { > - struct uio_map *map = to_map(kobj); > - struct uio_mem *mem = map->mem; > - > - if (strncmp(attr->attr.name, "addr", 4) == 0) > - return sprintf(buf, "0x%lx\n", mem->addr); > - > - if (strncmp(attr->attr.name, "size", 4) == 0) > - return sprintf(buf, "0x%lx\n", mem->size); > + return sprintf(buf, "0x%lx\n", mem->addr); > +} > > - return -ENODEV; > +static ssize_t map_size_show(struct uio_mem *mem, char *buf) > +{ > + return sprintf(buf, "0x%lx\n", mem->size); > } > > -static struct kobj_attribute attr_attribute = > - __ATTR(addr, S_IRUGO, map_attr_show, NULL); > -static struct kobj_attribute size_attribute = > - __ATTR(size, S_IRUGO, map_attr_show, NULL); > +struct uio_sysfs_entry { > + struct attribute attr; > + ssize_t (*show)(struct uio_mem *, char *); > + ssize_t (*store)(struct uio_mem *, const char *, size_t); > +}; > + > +static struct uio_sysfs_entry addr_attribute = > + __ATTR(addr, S_IRUGO, map_addr_show, NULL); > +static struct uio_sysfs_entry size_attribute = > + __ATTR(size, S_IRUGO, map_size_show, NULL); > > static struct attribute *attrs[] = { > - &attr_attribute.attr, > + &addr_attribute.attr, > &size_attribute.attr, > NULL, /* need to NULL terminate the list of > attributes */ }; > @@ -90,8 +90,28 @@ static void map_release(struct kobject * > kfree(map); > } > > +static ssize_t map_type_show(struct kobject *kobj, struct attribute > *attr, > + char *buf) > +{ > + struct uio_map *map = to_map(kobj); > + struct uio_mem *mem = map->mem; > + struct uio_sysfs_entry *entry; > + > + entry = container_of(attr, struct uio_sysfs_entry, attr); > + > + if (!entry->show) > + return -EIO; > + > + return entry->show(mem, buf); > +} > + > +static struct sysfs_ops uio_sysfs_ops = { > + .show = map_type_show, > +}; > + > static struct kobj_type map_attr_type = { > .release = map_release, > + .sysfs_ops = &uio_sysfs_ops, > .default_attrs = attrs, > }; ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] UIO: introduce sysfs_ops for map_attr_ktype 2008-02-19 9:55 ` [PATCH] UIO: introduce sysfs_ops for map_attr_ktype Brandon Philips 2008-02-19 12:12 ` Hans-Jürgen Koch @ 2008-02-20 6:54 ` Greg KH 1 sibling, 0 replies; 5+ messages in thread From: Greg KH @ 2008-02-20 6:54 UTC (permalink / raw) To: Brandon Philips; +Cc: Hans-J??rgen Koch, linux-kernel On Tue, Feb 19, 2008 at 01:55:05AM -0800, Brandon Philips wrote: > This fixes two bugs with UIO that cropped up recently in -rc1 > > 1) WARNING: at fs/sysfs/file.c:334 sysfs_open_file when trying to open > a map addr/size file - complaining about missing sysfs_ops for ktype > > 2) Permission denied when reading uio/uio0/maps/map0/{addr,size} when > files are mode S_IRUGO > > Also fix a typo: attr_attribute -> addr_attribute > > Signed-off-by: Brandon Philips <bphilips@suse.de> Hm, I thought I could get away with just using a kobject attribute, not a special one. Thanks for fixing this, it was my fault. greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-02-20 6:50 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-02-13 17:03 UIO sysfs attributes broken in 2.6.25-rc1 Hans-Jürgen Koch 2008-02-13 17:33 ` Greg KH 2008-02-19 9:55 ` [PATCH] UIO: introduce sysfs_ops for map_attr_ktype Brandon Philips 2008-02-19 12:12 ` Hans-Jürgen Koch 2008-02-20 6:54 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox