More info about kobj_attribute store and show functions
Lucas Tanure
tanure at linux.com
Wed Sep 3 20:39:50 EDT 2014
Greg,
I'm still trying to understand the sysfs.
I indeed read the documentation, I was using your "Sample kobject
implementation" as base of my code. But as 4h of work there some points
that I didn't understand yet.
Thanks
--
Lucas Tanure
+55 (19) 988176559
On Wed, Sep 3, 2014 at 9:23 PM, Greg KH <greg at kroah.com> wrote:
> On Wed, Sep 03, 2014 at 09:10:41PM -0300, Lucas Tanure wrote:
> > (Forget the last e-mail, please, stupid Gmail)
> >
> > Hi,
> >
> > I'm looking for some information about :
> >
> > struct kobj_attribute {
> > struct attribute attr;
> > ssize_t (*show)(struct kobject *kobj, struct kobj_attribute
> > *attr, char *buf);
> > ssize_t (*store)(struct kobject *kobj, struct kobj_attribute
> > *attr, const char *buf, size_t count);
> > };
> >
> >
> > My function to handle the operation:
> >
> > static ssize_t my_store(struct kobject *kobj, struct kobj_attribute
> *attr,
> > const char *buf, size_t count) {
> > char *buffer;
> >
> > buffer = (char*) kcalloc(count, sizeof(char), GFP_KERNEL);
> >
> > copy_from_user(buffer, buf, count);
> > .....
> > .....
> > etc....
> > }
> >
> > So, this *const char *buf, *where ti come from ? Kernel space?
>
> I'm guessing you didn't read the kobject documentation that is in the
> kernel tree?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140903/126ea202/attachment.html
More information about the Kernelnewbies
mailing list