Skip to content

Commit fc46820

Browse files
Andreas Gruenbachertorvalds
authored andcommitted
vfs: Return -ENXIO for negative SEEK_HOLE / SEEK_DATA offsets
In generic_file_llseek_size, return -ENXIO for negative offsets as well as offsets beyond EOF. This affects filesystems which don't implement SEEK_HOLE / SEEK_DATA internally, possibly because they don't support holes. Fixes xfstest generic/448. Signed-off-by: Andreas Gruenbacher <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent e365806 commit fc46820

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/read_write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence,
112112
* In the generic case the entire file is data, so as long as
113113
* offset isn't at the end of the file then the offset is data.
114114
*/
115-
if (offset >= eof)
115+
if ((unsigned long long)offset >= eof)
116116
return -ENXIO;
117117
break;
118118
case SEEK_HOLE:
119119
/*
120120
* There is a virtual hole at the end of the file, so as long as
121121
* offset isn't i_size or larger, return i_size.
122122
*/
123-
if (offset >= eof)
123+
if ((unsigned long long)offset >= eof)
124124
return -ENXIO;
125125
offset = eof;
126126
break;

0 commit comments

Comments
 (0)