mirror of
https://github.com/adulau/aha.git
synced 2025-01-04 07:03:38 +00:00
[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>
This commit is contained in:
parent
1da2c9a638
commit
8b491d7508
1 changed files with 6 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Id: mtdchar.c,v 1.73 2005/07/04 17:36:41 gleixner Exp $
|
* $Id: mtdchar.c,v 1.74 2005/08/04 01:05:48 tpoynor Exp $
|
||||||
*
|
*
|
||||||
* Character-device access to raw MTD devices.
|
* Character-device access to raw MTD devices.
|
||||||
*
|
*
|
||||||
|
@ -69,26 +69,23 @@ static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
|
||||||
switch (orig) {
|
switch (orig) {
|
||||||
case 0:
|
case 0:
|
||||||
/* SEEK_SET */
|
/* SEEK_SET */
|
||||||
file->f_pos = offset;
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* SEEK_CUR */
|
/* SEEK_CUR */
|
||||||
file->f_pos += offset;
|
offset += file->f_pos;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* SEEK_END */
|
/* SEEK_END */
|
||||||
file->f_pos =mtd->size + offset;
|
offset += mtd->size;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->f_pos < 0)
|
if (offset >= 0 && offset < mtd->size)
|
||||||
file->f_pos = 0;
|
return file->f_pos = offset;
|
||||||
else if (file->f_pos >= mtd->size)
|
|
||||||
file->f_pos = mtd->size - 1;
|
|
||||||
|
|
||||||
return file->f_pos;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue