Thread (5 messages) flat view 5 messages, 4 authors, 2021-01-27

Re: Doubt on show() function of sysfs attribute

From: Greg KH <hidden>
Date: 2021-01-27 08:10:54

On Tue, Jan 26, 2021 at 11:07:24PM +0530, Mohana Datta Yelugoti wrote:
Hello everyone,

I am going through Documentation/filesystems/sysfs.rst.

It says that sysfs allocates a buffer of size PAGE_SIZE and
passes it to the show/store functions of the attribute. On
read(), the show() method should fill the entire buffer[0].
No, that's not the case.  Please only fill in what you need sent back to
userspace and return the number of bytes you used.  A simple call to
sprintf() or better yet, sysfs_emit(), as a return statement is all you
need to do.

See the thousands of examples in the kernel of this if you need proof :)

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help