Doubt on show() function of sysfs attribute

Lukas Bulwahn lukas.bulwahn at
Wed Jan 27 04:39:44 EST 2021

On Wed, Jan 27, 2021 at 9:10 AM Greg KH <greg at> wrote:
> 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 :)

And Mohana, try it out and once you understand how the API really
works, feel free to provide a patch to
Documentation/filesystems/sysfs.rst to describe the actual behavior.


More information about the Kernelnewbies mailing list