lkml.org 
[lkml]   [2020]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] kernel/printk: add kmsg SEEK_CUR handling
On (20/03/17 07:33), Bruno Meneguele wrote:
> Userspace libraries, e.g. glibc's dprintf(), perform a SEEK_CUR operation
> over any file descriptor requested to make sure the current position isn't
> pointing to junk due to previous manipulation of that same fd. And whenever
> that fd doesn't have support for such operation, the userspace code expects
> -ESPIPE to be returned.
>
> However, when the fd in question references the /dev/kmsg interface, the
> current kernel code state returns -EINVAL instead, causing an unexpected
> behavior in userspace: in the case of glibc, when -ESPIPE is returned it
> gets ignored and the call completes successfully, while returning -EINVAL
> forces dprintf to fail without performing any action over that fd:
>
> if (_IO_SEEKOFF (fp, (off64_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT) ==
> _IO_pos_BAD && errno != ESPIPE)
> return NULL;
>
> With this patch we make sure to return the correct value when SEEK_CUR is
> requested over kmsg and also add some kernel doc information to formalize
> this behavior.
>
> Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>

Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

-ss

\
 
 \ /
  Last update: 2020-03-20 03:45    [W:0.043 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site