drivers: fix up various ->llseek() implementations
authorJosef Bacik <josef@redhat.com>
Mon, 18 Jul 2011 17:21:39 +0000 (13:21 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Jul 2011 00:47:58 +0000 (20:47 -0400)
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>
drivers/char/generic_nvram.c
drivers/char/nvram.c
drivers/char/ps3flash.c
drivers/macintosh/nvram.c

index 0e941b57482e7d1021d409320e9184148888412b..6c4f4b5a9dd3aebb80920b2cae781c4a858fccac 100644 (file)
@@ -34,12 +34,16 @@ static ssize_t nvram_len;
 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
 {
        switch (origin) {
+       case 0:
+               break;
        case 1:
                offset += file->f_pos;
                break;
        case 2:
                offset += nvram_len;
                break;
+       default:
+               offset = -1;
        }
        if (offset < 0)
                return -EINVAL;
index 166f1e7aaa7ee844c4a36b8950cb9f343e0f5c82..da3cfee782dc32eb76a724cb640b92d4da5f0dee 100644 (file)
@@ -224,6 +224,8 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
        case 2:
                offset += NVRAM_BYTES;
                break;
+       default:
+               return -EINVAL;
        }
 
        return (offset >= 0) ? (file->f_pos = offset) : -EINVAL;
index 85c004a518ee1d9196aebb28a75e5464fce6354b..5a06787e5be350cd425340c9b2fda18f07bb118f 100644 (file)
@@ -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);
        switch (origin) {
+       case 0:
+               break;
        case 1:
                offset += file->f_pos;
                break;
        case 2:
                offset += dev->regions[dev->region_idx].size*dev->blk_size;
                break;
+       default:
+               offset = -1;
        }
        if (offset < 0) {
                res = -EINVAL;
index a271c8218d82b00c3311c3c77d26f135ce5791ec..f0e03e7937e31483540d1a910dd250eb14368dc2 100644 (file)
 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
 {
        switch (origin) {
+       case 0:
+               break;
        case 1:
                offset += file->f_pos;
                break;
        case 2:
                offset += NVRAM_SIZE;
                break;
+       default:
+               offset = -1;
        }
        if (offset < 0)
                return -EINVAL;