kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Doubt on show() function of sysfs attribute
@ 2021-01-26 17:37 Mohana Datta Yelugoti
  2021-01-27  3:51 ` Valdis Klētnieks
  2021-01-27  8:10 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Mohana Datta Yelugoti @ 2021-01-26 17:37 UTC (permalink / raw)
  To: kernelnewbies

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].

The document also says that sysfs_emit() and sysfs_emit_at()
are the preferred function calls in show() function when
formatting the value to be returned to the user space [1].

I checked the sysfs_emit() function definition.

sysfs_emit() -> vscnprintf() -> vsnprintf() is the function
series. (-> = calls)

In the vsnprintf() function, i found that only in the case of
(start + size > end) the buffer is completely filled, in the other
case, that's not the case [2].

Isn't this contradictory to what the sysfs.rst says? (that entire
buffer should be filled)

Can you please help me understand what i am missing here?

Thank you for your time.

Cheers,
ymdatta.


[0]:
https://elixir.bootlin.com/linux/latest/source/Documentation/filesystems/sysfs.rst#L214

[1]:
https://elixir.bootlin.com/linux/latest/source/Documentation/filesystems/sysfs.rst#L246

[2]: https://elixir.bootlin.com/linux/latest/source/lib/vsprintf.c#L2689

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-27 16:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 17:37 Doubt on show() function of sysfs attribute Mohana Datta Yelugoti
2021-01-27  3:51 ` Valdis Klētnieks
2021-01-27  8:10 ` Greg KH
2021-01-27  9:39   ` Lukas Bulwahn
2021-01-27 16:21   ` Mohana Datta Yelugoti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).