• NeilBrown's avatar
    sysfs/kernfs: make read requests on pre-alloc files use the buffer. · 4ef67a8c
    NeilBrown authored
    To match the previous patch which used the pre-alloc buffer for
    writes, this patch causes reads to use the same buffer.
    This is not strictly necessary as the current seq_read() will allocate
    on first read, so user-space can trigger the required pre-alloc.  But
    consistency is valuable.
    
    The read function is somewhat simpler than seq_read() and, for example,
    does not support reading from an offset into the file: reads must be
    at the start of the file.
    
    As seq_read() does not use the prealloc buffer, ->seq_show is
    incompatible with ->prealloc and caused an EINVAL return from open().
    sysfs code which calls into kernfs always chooses the correct function.
    
    As the buffer is shared with writes and other reads, the mutex is
    extended to cover the copy_to_user.
    Signed-off-by: default avatarNeilBrown <neilb@suse.de>
    Reviewed-by: default avatarTejun Heo <tj@kernel.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    4ef67a8c
file.c 11.8 KB