diff options
author | Todd Poynor <tpoynor@mvista.com> | 2005-08-03 21:05:51 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-08-04 06:52:40 -0400 |
commit | 8b491d750885ebe8e7d385ce4186c85957d67123 (patch) | |
tree | 18c7eb52bfc8821eaf08430fdaa5ce70078f2200 /drivers/mtd/mtdchar.c | |
parent | 1da2c9a638f8af7be3daf1fa8dbd087b3284d16e (diff) |
[MTD] mtdchar: Return EINVAL for bad seeks instead of fixing up to valid byte
mtdchar return -EINVAL for seek prior to offset 0 or to beyond the last
byte in the device/partition, similar to various other seek methods,
instead of fixing up to first or last byte.
Signed-off-by: Todd Poynor <tpoynor@mvista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r-- | drivers/mtd/mtdchar.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 1ed602a0f24c..4b3c6263e7fc 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: mtdchar.c,v 1.73 2005/07/04 17:36:41 gleixner Exp $ | 2 | * $Id: mtdchar.c,v 1.74 2005/08/04 01:05:48 tpoynor Exp $ |
3 | * | 3 | * |
4 | * Character-device access to raw MTD devices. | 4 | * Character-device access to raw MTD devices. |
5 | * | 5 | * |
@@ -69,26 +69,23 @@ static loff_t mtd_lseek (struct file *file, loff_t offset, int orig) | |||
69 | switch (orig) { | 69 | switch (orig) { |
70 | case 0: | 70 | case 0: |
71 | /* SEEK_SET */ | 71 | /* SEEK_SET */ |
72 | file->f_pos = offset; | ||
73 | break; | 72 | break; |
74 | case 1: | 73 | case 1: |
75 | /* SEEK_CUR */ | 74 | /* SEEK_CUR */ |
76 | file->f_pos += offset; | 75 | offset += file->f_pos; |
77 | break; | 76 | break; |
78 | case 2: | 77 | case 2: |
79 | /* SEEK_END */ | 78 | /* SEEK_END */ |
80 | file->f_pos =mtd->size + offset; | 79 | offset += mtd->size; |
81 | break; | 80 | break; |
82 | default: | 81 | default: |
83 | return -EINVAL; | 82 | return -EINVAL; |
84 | } | 83 | } |
85 | 84 | ||
86 | if (file->f_pos < 0) | 85 | if (offset >= 0 && offset < mtd->size) |
87 | file->f_pos = 0; | 86 | return file->f_pos = offset; |
88 | else if (file->f_pos >= mtd->size) | ||
89 | file->f_pos = mtd->size - 1; | ||
90 | 87 | ||
91 | return file->f_pos; | 88 | return -EINVAL; |
92 | } | 89 | } |
93 | 90 | ||
94 | 91 | ||