Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Josef Bacik and committed by
Al Viro
22735068 06222e49

+14
+4
drivers/char/generic_nvram.c
··· 34 34 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) 35 35 { 36 36 switch (origin) { 37 + case 0: 38 + break; 37 39 case 1: 38 40 offset += file->f_pos; 39 41 break; 40 42 case 2: 41 43 offset += nvram_len; 42 44 break; 45 + default: 46 + offset = -1; 43 47 } 44 48 if (offset < 0) 45 49 return -EINVAL;
+2
drivers/char/nvram.c
··· 224 224 case 2: 225 225 offset += NVRAM_BYTES; 226 226 break; 227 + default: 228 + return -EINVAL; 227 229 } 228 230 229 231 return (offset >= 0) ? (file->f_pos = offset) : -EINVAL;
+4
drivers/char/ps3flash.c
··· 101 101 102 102 mutex_lock(&file->f_mapping->host->i_mutex); 103 103 switch (origin) { 104 + case 0: 105 + break; 104 106 case 1: 105 107 offset += file->f_pos; 106 108 break; 107 109 case 2: 108 110 offset += dev->regions[dev->region_idx].size*dev->blk_size; 109 111 break; 112 + default: 113 + offset = -1; 110 114 } 111 115 if (offset < 0) { 112 116 res = -EINVAL;
+4
drivers/macintosh/nvram.c
··· 21 21 static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) 22 22 { 23 23 switch (origin) { 24 + case 0: 25 + break; 24 26 case 1: 25 27 offset += file->f_pos; 26 28 break; 27 29 case 2: 28 30 offset += NVRAM_SIZE; 29 31 break; 32 + default: 33 + offset = -1; 30 34 } 31 35 if (offset < 0) 32 36 return -EINVAL;