diff options
author | Jeff Liu <jeff.liu@oracle.com> | 2011-09-18 10:34:02 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-09-18 10:34:02 -0400 |
commit | 48802c8ae2a9d618ec734a61283d645ad527e06c (patch) | |
tree | ee6da3e2edae6e355e6133dafd08d5323c136ac5 /fs | |
parent | 2cf4ce7c2a07782c3f4d899b380a78522bca3238 (diff) | |
download | kernel_goldelico_gta04-48802c8ae2a9d618ec734a61283d645ad527e06c.zip kernel_goldelico_gta04-48802c8ae2a9d618ec734a61283d645ad527e06c.tar.gz kernel_goldelico_gta04-48802c8ae2a9d618ec734a61283d645ad527e06c.tar.bz2 |
BTRFS: Fix lseek return value for error
The recent reworking of btrfs' lseek lead to incorrect
values being returned. This adds checks for seeking
beyond EOF in SEEK_HOLE and makes sure the error
values come back correct.
Andi Kleen also sent in similar patches.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Reported-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/file.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 3c3abff..a381cd2 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1817,6 +1817,11 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int origin) goto out; case SEEK_DATA: case SEEK_HOLE: + if (offset >= i_size_read(inode)) { + mutex_unlock(&inode->i_mutex); + return -ENXIO; + } + ret = find_desired_extent(inode, &offset, origin); if (ret) { mutex_unlock(&inode->i_mutex); @@ -1825,11 +1830,11 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int origin) } if (offset < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET)) { - ret = -EINVAL; + offset = -EINVAL; goto out; } if (offset > inode->i_sb->s_maxbytes) { - ret = -EINVAL; + offset = -EINVAL; goto out; } |