Skip to content

Commit 0936896

Browse files
Vladimir Zapolskiygregkh
authored andcommitted
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 <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 41fb96a commit 0936896

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/sysfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static ssize_t sysfs_kf_bin_write(struct kernfs_open_file *of, char *buf,
125125

126126
if (size) {
127127
if (size <= pos)
128-
return 0;
128+
return -EFBIG;
129129
count = min_t(ssize_t, count, size - pos);
130130
}
131131
if (!count)

0 commit comments

Comments
 (0)