mtd/drivers/mtd mtdchar.c,1.73,1.74
tpoynor at infradead.org
tpoynor at infradead.org
Wed Aug 3 21:05:51 EDT 2005
Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv6744/drivers/mtd
Modified Files:
mtdchar.c
Log Message:
[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 at mvista.com>
Index: mtdchar.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdchar.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- mtdchar.c 4 Jul 2005 17:36:41 -0000 1.73
+++ mtdchar.c 4 Aug 2005 01:05:48 -0000 1.74
@@ -69,26 +69,23 @@
switch (orig) {
case 0:
/* SEEK_SET */
- file->f_pos = offset;
break;
case 1:
/* SEEK_CUR */
- file->f_pos += offset;
+ offset += file->f_pos;
break;
case 2:
/* SEEK_END */
- file->f_pos =mtd->size + offset;
+ offset += mtd->size;
break;
default:
return -EINVAL;
}
- if (file->f_pos < 0)
- file->f_pos = 0;
- else if (file->f_pos >= mtd->size)
- file->f_pos = mtd->size - 1;
+ if (offset >= 0 && offset < mtd->size)
+ return file->f_pos = offset;
- return file->f_pos;
+ return -EINVAL;
}
More information about the linux-mtd-cvs
mailing list