alistair23-linux/fs/sysfs
Tejun Heo 044e3bc333 sysfs: use generic_file_llseek() for sysfs_file_operations
13c589d5b0 ("sysfs: use seq_file when reading regular files")
converted regular sysfs files to use seq_file.  The commit substituted
generic_file_llseek() with seq_lseek() for llseek implementation.

Before the change, all regular sysfs files were allowed to seek to any
position in [0, PAGE_SIZE] as the file size is always PAGE_SIZE and
generic_file_llseek() allows any seeking inside the range under file
size; however, seq_lseek()'s behavior is different.  It traverses the
output by repeatedly invoking ->show() until it reaches the target
offset or traversal indicates EOF.  As seq_files are fully dynamic and
may not end at all, it doesn't support seeking from the end
(SEEK_END).

Apparently, there are userland tools which uses SEEK_END to discover
the buffer size to use and the switch to seq_lseek() disturbs them as
SEEK_END fails with -EINVAL.

The only benefits of using seq_lseek() instead of
generic_file_llseek() are

* Early failure.  If traversing to certain file position should fail,
  seq_lseek() will report such failures on lseek(2) instead of the
  following read/write operations.

* EOF detection.  While SEEK_END is not supported, SEEK_SET/CUR +
  large offset can be used to detect eof - eof at the time of the seek
  anyway as the file size may change dynamically.

Both aren't necessary for sysfs or prospect kernfs users.  Revert to
genefic_file_llseek() and preserve the original behavior.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Link: https://lkml.kernel.org/r/20131031114358.GA5551@osiris
Tested-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-11-01 12:13:37 -07:00
..
dir.c sysfs: separate out dup filename warning into a separate function 2013-10-29 15:12:07 -07:00
file.c sysfs: use generic_file_llseek() for sysfs_file_operations 2013-11-01 12:13:37 -07:00
group.c sysfs: introduce [__]sysfs_remove() 2013-10-03 16:38:52 -07:00
inode.c sysfs: move sysfs_hash_and_remove() to fs/sysfs/dir.c 2013-10-29 15:12:07 -07:00
Kconfig kconfig: rename CONFIG_EMBEDDED to CONFIG_EXPERT 2011-01-20 17:02:05 -08:00
Makefile sysfs: merge regular and bin file handling 2013-10-05 17:27:40 -07:00
mount.c sysfs: drop kobj_ns_type handling 2013-09-26 15:30:22 -07:00
symlink.c sysfs: remove sysfs_addrm_cxt->parent_sd 2013-10-03 16:16:43 -07:00
sysfs.h sysfs: separate out dup filename warning into a separate function 2013-10-29 15:12:07 -07:00