Skip to content

Commit bc885f1

Browse files
bmenegpmladek
authored andcommitted
doc:kmsg: explicitly state the return value in case of SEEK_CUR
The commit 625d344 ("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 expect. Signed-off-by: Bruno Meneguele <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8eda94b commit bc885f1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Documentation/ABI/testing/dev-kmsg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ Description: The /dev/kmsg character device node provides userspace access
6161
SEEK_CUR is not supported, returning -ESPIPE (invalid seek) to
6262
errno whenever requested.
6363

64+
Other seek operations or offsets are not supported because of
65+
the special behavior this device has. The device allows to read
66+
or write only whole variable length messages (records) that are
67+
stored in a ring buffer.
68+
69+
Because of the non-standard behavior also the error values are
70+
non-standard. -ESPIPE is returned for non-zero offset. -EINVAL
71+
is returned for other operations, e.g. SEEK_CUR. This behavior
72+
and values are historical and could not be modified without the
73+
risk of breaking userspace.
74+
6475
The output format consists of a prefix carrying the syslog
6576
prefix including priority and facility, the 64 bit message
6677
sequence number and the monotonic timestamp in microseconds,

kernel/printk/printk.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,14 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
943943
return ret;
944944
}
945945

946+
/*
947+
* Be careful when modifying this function!!!
948+
*
949+
* Only few operations are supported because the device works only with the
950+
* entire variable length messages (records). Non-standard values are
951+
* returned in the other cases and has been this way for quite some time.
952+
* User space applications might depend on this behavior.
953+
*/
946954
static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
947955
{
948956
struct devkmsg_user *user = file->private_data;

0 commit comments

Comments
 (0)