All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mohana Datta Yelugoti <ymdatta.work@gmail.com>
To: kernelnewbies@kernelnewbies.org
Subject: Doubt on show() function of sysfs attribute
Date: Tue, 26 Jan 2021 23:07:24 +0530	[thread overview]
Message-ID: <98fe87f5-19ac-dfa7-41eb-2e00d7415021@gmail.com> (raw)

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

             reply	other threads:[~2021-01-26 17:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 17:37 Mohana Datta Yelugoti [this message]
2021-01-27  3:51 ` Doubt on show() function of sysfs attribute 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98fe87f5-19ac-dfa7-41eb-2e00d7415021@gmail.com \
    --to=ymdatta.work@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.