diff options
| -rw-r--r-- | fs/ext4/file.c | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index e4095e988eba..b9548f477bb8 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
| @@ -224,53 +224,8 @@ loff_t ext4_llseek(struct file *file, loff_t offset, int origin) | |||
| 224 | maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes; | 224 | maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes; |
| 225 | else | 225 | else |
| 226 | maxbytes = inode->i_sb->s_maxbytes; | 226 | maxbytes = inode->i_sb->s_maxbytes; |
| 227 | mutex_lock(&inode->i_mutex); | ||
| 228 | switch (origin) { | ||
| 229 | case SEEK_END: | ||
| 230 | offset += inode->i_size; | ||
| 231 | break; | ||
| 232 | case SEEK_CUR: | ||
| 233 | if (offset == 0) { | ||
| 234 | mutex_unlock(&inode->i_mutex); | ||
| 235 | return file->f_pos; | ||
| 236 | } | ||
| 237 | offset += file->f_pos; | ||
| 238 | break; | ||
| 239 | case SEEK_DATA: | ||
| 240 | /* | ||
| 241 | * In the generic case the entire file is data, so as long as | ||
| 242 | * offset isn't at the end of the file then the offset is data. | ||
| 243 | */ | ||
| 244 | if (offset >= inode->i_size) { | ||
| 245 | mutex_unlock(&inode->i_mutex); | ||
| 246 | return -ENXIO; | ||
| 247 | } | ||
| 248 | break; | ||
| 249 | case SEEK_HOLE: | ||
| 250 | /* | ||
| 251 | * There is a virtual hole at the end of the file, so as long as | ||
| 252 | * offset isn't i_size or larger, return i_size. | ||
| 253 | */ | ||
| 254 | if (offset >= inode->i_size) { | ||
| 255 | mutex_unlock(&inode->i_mutex); | ||
| 256 | return -ENXIO; | ||
| 257 | } | ||
| 258 | offset = inode->i_size; | ||
| 259 | break; | ||
| 260 | } | ||
| 261 | |||
| 262 | if (offset < 0 || offset > maxbytes) { | ||
| 263 | mutex_unlock(&inode->i_mutex); | ||
| 264 | return -EINVAL; | ||
| 265 | } | ||
| 266 | |||
| 267 | if (offset != file->f_pos) { | ||
| 268 | file->f_pos = offset; | ||
| 269 | file->f_version = 0; | ||
| 270 | } | ||
| 271 | mutex_unlock(&inode->i_mutex); | ||
| 272 | 227 | ||
| 273 | return offset; | 228 | return generic_file_llseek_size(file, offset, origin, maxbytes); |
| 274 | } | 229 | } |
| 275 | 230 | ||
| 276 | const struct file_operations ext4_file_operations = { | 231 | const struct file_operations ext4_file_operations = { |
