patch "sysfs: correctly handle read offset on PREALLOC attrs" added to driver-core-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
sysfs: correctly handle read offset on PREALLOC attrs
to my driver-core git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
in the driver-core-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
Quoted 1 line
From
17d0774f80681020eccc9638d925a23f1fc4f671Mon Sep 17 00:00:00 2001
From: Konstantin Khlebnikov <[email protected]>
Date: Wed, 22 Jun 2016 21:42:16 +0300
Subject: sysfs: correctly handle read offset on PREALLOC attrs
Attributes declared with __ATTR_PREALLOC use sysfs_kf_read() which returns zero bytes for non-zero offset. This breaks script checkarray in mdadm tool in debian where /bin/sh is 'dash' because its builtin 'read' reads only one byte at a time. Script gets 'i' instead of 'idle' when reads current action from /sys/block/$dev/md/sync_action and as a result does nothing.
This patch adds trivial implementation of partial read: generate whole string and move required part into buffer head.
--- fs/sysfs/file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/sysfs/file.c +7 -1
@@ -114,9 +114,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf,* If buf != of->prealloc_buf, we don't know how * large it is, so cannot safely pass it to ->show */ -if (pos ||WARN_ON_ONCE (buf != of->prealloc_buf)) +if (WARN_ON_ONCE (buf != of->prealloc_buf))return 0 ; len = ops->show (kobj, of->kn->priv, buf); +if (pos) { +if (len <= pos) +return 0 ; + len -= pos; +memmove (buf, buf + pos, len); + }return min (count, len); }
Signature · 1 line
2.9.3