Doubt on show() function of sysfs attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux