diff options
| author | Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> | 2014-09-24 11:21:04 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-07 13:52:20 -0500 |
| commit | 0936896056365349afa867c16e9f9100a6707cbf (patch) | |
| tree | 0fa7c920611d832417e38ab661a5795a2f6d8de1 /fs/sysfs | |
| parent | 41fb96a4b619afd2272acb6e981a7581efa8e118 (diff) | |
fs: sysfs: return EGBIG on write if offset is larger than file size
According to the user expectations common utilities like dd or sh
redirection operator > should work correctly over binary files from
sysfs. At the moment doing excessive write can not be completed:
write(1, "\0\0\0\0\0\0\0\0", 8) = 4
write(1, "\0\0\0\0", 4) = 0
write(1, "\0\0\0\0", 4) = 0
write(1, "\0\0\0\0", 4) = 0
...
Fix the problem by returning EFBIG described in man 2 write.
Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs')
| -rw-r--r-- | fs/sysfs/file.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index e9ef59b3abb1..589abee16a39 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
| @@ -125,7 +125,7 @@ static ssize_t sysfs_kf_bin_write(struct kernfs_open_file *of, char *buf, | |||
| 125 | 125 | ||
| 126 | if (size) { | 126 | if (size) { |
| 127 | if (size <= pos) | 127 | if (size <= pos) |
| 128 | return 0; | 128 | return -EFBIG; |
| 129 | count = min_t(ssize_t, count, size - pos); | 129 | count = min_t(ssize_t, count, size - pos); |
| 130 | } | 130 | } |
| 131 | if (!count) | 131 | if (!count) |
