From: Petr Mladek <pmladek@suse.com>
To: Bruno Meneguele <bmeneg@redhat.com>
Cc: linux-kernel@vger.kernel.org, sergey.senozhatsky@gmail.com,
torvalds@linux-foundation.org, Jason@zx2c4.com
Subject: Re: [PATCH] doc:kmsg: explictly state the return value in case of SEEK_CUR
Date: Fri, 10 Jul 2020 14:19:23 +0200 [thread overview]
Message-ID: <20200710121923.GO4751@alley> (raw)
In-Reply-To: <20200709155415.41207-1-bmeneg@redhat.com>
On Thu 2020-07-09 12:54:15, Bruno Meneguele wrote:
> The commit 625d3449788f ("Revert "kernel/printk: add kmsg SEEK_CUR
> handling"") reverted a change done to the return value in case a SEEK_CUR
> operation was performed for kmsg buffer based on the fact that different
> userspace apps were handling the new return value (-ESPIPE) in different
> ways, breaking them.
>
> At the same time -ESPIPE was the wrong decision because kmsg /does support/
> seek() but doesn't follow the "normal" behavior userspace is used to.
> Because of that and also considering the time -EINVAL has been used, it was
> decided to keep this way to avoid more userspace breakage.
>
> This patch adds an official statement to the kmsg documentation pointing to
> the current return value for SEEK_CUR, -EINVAL, thus userspace libraries and
> apps can refer to it for a definitive guide on what to expected.
>
> --- a/Documentation/ABI/testing/dev-kmsg
> +++ b/Documentation/ABI/testing/dev-kmsg
> @@ -56,6 +56,11 @@ Description: The /dev/kmsg character device node provides userspace access
> seek after the last record available at the time
> the last SYSLOG_ACTION_CLEAR was issued.
>
> + Considering that the seek operation is supported but has
> + special meaning to the device, any attempt to seek specific
> + positions on the buffer (i.e. using SEEK_CUR) results in an
> + -EINVAL error returned to userspace.
Sigh, I see that devkmsg_llseek() returns -ESPIPE when offset is not
zero. This is a real mess.
I wonder if we could afford to switch this one to -EINVAL and reduce
the mess.
Anyway, for a random reader, it might be pretty unclear what is
exactly special about /dev/kmsg. I wonder if the following might
be more explanatory and strightforward:
Other seek operations or offsets are not supported because of
the special behavior. The device allows to read or write
only whole variable lenght messages that are stored in
a ring buffer.
Because of the non-standard behavior also the error values
are non-standardand. -ESPIPE is returned for non-zero offset.
-EINVAL is returned for other operations, e.g. SEEK_CUR.
This behavior is historical and could not be modified
wihtout the risk of breaking userspace.
Finally, only few people read documentation. We should add some
warning also to the code. I think about a something like:
/*
* Be careful when modifying this function!!!
*
* Only few operations are supported because the device works only with
* the entire variable length messages. Non-standard error values are
* returned in the other cases. User space applications might depend
* on this behavior.
*/
Best Regards,
Petr
next prev parent reply other threads:[~2020-07-10 12:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 15:54 Bruno Meneguele
2020-07-10 12:19 ` Petr Mladek [this message]
2020-07-10 13:10 ` Bruno Meneguele
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=20200710121923.GO4751@alley \
--to=pmladek@suse.com \
--cc=Jason@zx2c4.com \
--cc=bmeneg@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®