summaryrefslogtreecommitdiffstats
path: root/include/fs.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-04-18 11:56:00 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-19 08:26:51 +0200
commitcb8cf33ce849f71f7fe1d717aa02b5669a54a19e (patch)
tree6d6f9692573033e1b516a896a8fb1333f25d1a37 /include/fs.h
parent24a6b3f8eabf08b589a2860aee9b670fa88cd085 (diff)
downloadbarebox-cb8cf33ce849f71f7fe1d717aa02b5669a54a19e.tar.gz
barebox-cb8cf33ce849f71f7fe1d717aa02b5669a54a19e.tar.xz
fix erasing/protecting flashes with unspecified size
fixes: 81737c1 mtd: Fix erasing of devices >4GiB Several places erased a complete flash partition passing ~0 as count to erase(). With the above commit count to erase was changed from an unsigned type to a signed type, so the (count > f->size - offset) check in erase() no longer triggers and the ~0 count is no longer adjusted to the whole device size. Among other things this results in saveenv failures on NOR flashes. This patch fixes this by introducing an explicit macro for erasing the whole device which is tested for in erase(). All other negative values are rejected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Giorgio <giorgio.nicole@arcor.de>
Diffstat (limited to 'include/fs.h')
-rw-r--r--include/fs.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/fs.h b/include/fs.h
index b9d1e6e09a..943ba55439 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -147,6 +147,7 @@ int umount(const char *pathname);
int umount_by_cdev(struct cdev *cdev);
/* not-so-standard functions */
+#define ERASE_SIZE_ALL ((loff_t) - 1)
int erase(int fd, loff_t count, loff_t offset);
int protect(int fd, size_t count, loff_t offset, int prot);
int protect_file(const char *file, int prot);