]> err.no Git - linux-2.6/commitdiff
[MTD] CORE mtdchar.c: fix off-by-one error in lseek()
authorHerbert Valerio Riedel <hvr@gnu.org>
Fri, 23 Jun 2006 22:03:36 +0000 (00:03 +0200)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 27 Jun 2006 22:22:07 +0000 (23:22 +0100)
Allow lseek(mtdchar_fd, 0, SEEK_END) to succeed, which currently fails
with EINVAL.

lseek(fd, 0, SEEK_END) should result into the same fileposition as
lseek(fd, 0, SEEK_SET) + read(fd, buf, length(fd))

Furthermore, lseek(fd, 0, SEEK_CUR) should return the current file position,
which in case of an encountered EOF should not result in EINVAL

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
drivers/mtd/mtdchar.c

index aa18d45b264bb2d3aef9c71792401ac1d7ccece5..9a4b59d925252a554c4840455b6e00455e6aa7df 100644 (file)
@@ -78,7 +78,7 @@ static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
                return -EINVAL;
        }
 
-       if (offset >= 0 && offset < mtd->size)
+       if (offset >= 0 && offset <= mtd->size)
                return file->f_pos = offset;
 
        return -EINVAL;