drivers: fix up various ->llseek() implementations
Fix up a few ->llseek() implementations that won't deal with SEEK_HOLE/SEEK_DATA properly. Make them future proof so that if we ever add new options they will return -EINVAL. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -34,12 +34,16 @@ static ssize_t nvram_len;
|
|||||||
static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
|
static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
|
||||||
{
|
{
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
offset += file->f_pos;
|
offset += file->f_pos;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
offset += nvram_len;
|
offset += nvram_len;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
offset = -1;
|
||||||
}
|
}
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@@ -224,6 +224,8 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
|
|||||||
case 2:
|
case 2:
|
||||||
offset += NVRAM_BYTES;
|
offset += NVRAM_BYTES;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (offset >= 0) ? (file->f_pos = offset) : -EINVAL;
|
return (offset >= 0) ? (file->f_pos = offset) : -EINVAL;
|
||||||
|
@@ -101,12 +101,16 @@ static loff_t ps3flash_llseek(struct file *file, loff_t offset, int origin)
|
|||||||
|
|
||||||
mutex_lock(&file->f_mapping->host->i_mutex);
|
mutex_lock(&file->f_mapping->host->i_mutex);
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
offset += file->f_pos;
|
offset += file->f_pos;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
offset += dev->regions[dev->region_idx].size*dev->blk_size;
|
offset += dev->regions[dev->region_idx].size*dev->blk_size;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
offset = -1;
|
||||||
}
|
}
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
|
@@ -21,12 +21,16 @@
|
|||||||
static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
|
static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
|
||||||
{
|
{
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
offset += file->f_pos;
|
offset += file->f_pos;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
offset += NVRAM_SIZE;
|
offset += NVRAM_SIZE;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
offset = -1;
|
||||||
}
|
}
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
Reference in New Issue
Block a user