Konstantin Khlebnikov 625ddb785d sysfs: correctly handle read offset on PREALLOC attrs
commit 17d0774f80681020eccc9638d925a23f1fc4f671 upstream.

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.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Fixes: 4ef67a8c95f3 ("sysfs/kernfs: make read requests on pre-alloc files use the buffer.")
Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787950
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-07 08:32:46 +02:00
..
2016-08-10 11:49:27 +02:00
2016-03-03 15:07:12 -08:00
2016-08-20 18:09:20 +02:00
2015-11-13 20:34:33 -05:00
2015-11-23 21:11:08 -05:00
2016-07-27 09:47:31 -07:00
2015-11-10 12:07:22 -08:00
2015-11-16 23:54:45 -08:00
2015-11-16 23:54:45 -08:00
2015-08-12 15:28:45 -05:00
2016-08-10 11:49:27 +02:00
2016-05-18 17:06:48 -07:00
2016-07-27 09:47:30 -07:00
2016-09-07 08:32:43 +02:00
2015-11-13 20:34:33 -05:00