aboutsummaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-07-18 13:21:38 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 20:47:58 -0400
commit06222e491e663dac939f04b125c9dc52126a75c4 (patch)
tree99636fd666c8148a5bf58ea4844263d4b3a36310 /fs/block_dev.c
parentc334b1138bd44bea578eab7971c59bd9212a1093 (diff)
fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek
This converts everybody to handle SEEK_HOLE/SEEK_DATA properly. In some cases we just return -EINVAL, in others we do the normal generic thing, and in others we're simply making sure that the properly due-dilligence is done. For example in NFS/CIFS we need to make sure the file size is update properly for the SEEK_HOLE and SEEK_DATA case, but since it calls the generic llseek stuff itself that is all we have to do. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 610e8e0b04b8..966617a422d9 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -355,20 +355,25 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
355 mutex_lock(&bd_inode->i_mutex); 355 mutex_lock(&bd_inode->i_mutex);
356 size = i_size_read(bd_inode); 356 size = i_size_read(bd_inode);
357 357
358 retval = -EINVAL;
358 switch (origin) { 359 switch (origin) {
359 case 2: 360 case SEEK_END:
360 offset += size; 361 offset += size;
361 break; 362 break;
362 case 1: 363 case SEEK_CUR:
363 offset += file->f_pos; 364 offset += file->f_pos;
365 case SEEK_SET:
366 break;
367 default:
368 goto out;
364 } 369 }
365 retval = -EINVAL;
366 if (offset >= 0 && offset <= size) { 370 if (offset >= 0 && offset <= size) {
367 if (offset != file->f_pos) { 371 if (offset != file->f_pos) {
368 file->f_pos = offset; 372 file->f_pos = offset;
369 } 373 }
370 retval = offset; 374 retval = offset;
371 } 375 }
376out:
372 mutex_unlock(&bd_inode->i_mutex); 377 mutex_unlock(&bd_inode->i_mutex);
373 return retval; 378 return retval;
374} 379}