summaryrefslogtreecommitdiff
path: root/nand-utils/nandwrite.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2017-01-11 11:45:18 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2017-01-12 11:02:18 +0100
commitdffaa1d4d1cfabdf325967dd9766adde7320e05e (patch)
tree992115ea6994f8f22a4efd6a1c763d08e73e7fdc /nand-utils/nandwrite.c
parent1bfee8660131fca7a18f68e9548a18ca6b3378a0 (diff)
nandwrite: add stricter sanity checking for blockalign
This patch makes sure that a virtual erase block is always composed of a postivie number of erase blocks (i.e. 1 or more) and enforces the block alignment to be a power of two as suggested by the help text and assumed throughout the program. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'nand-utils/nandwrite.c')
-rw-r--r--nand-utils/nandwrite.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/nand-utils/nandwrite.c b/nand-utils/nandwrite.c
index 9602a6e..998c68c 100644
--- a/nand-utils/nandwrite.c
+++ b/nand-utils/nandwrite.c
@@ -191,9 +191,13 @@ static void process_options(int argc, char * const argv[])
errmsg_die("Can't specify negative device offset with option"
" -s: %lld", mtdoffset);
- if (blockalign < 0)
- errmsg_die("Can't specify negative blockalign with option -b:"
- " %d", blockalign);
+ if (blockalign <= 0)
+ errmsg_die("Can't specify negative or zero blockalign with "
+ "option -b: %d", blockalign);
+
+ if (!is_power_of_2(blockalign))
+ errmsg_die("Can't specify a non-power-of-two blockalign with "
+ "option -b: %d", blockalign);
if (autoplace && noecc)
errmsg_die("Autoplacement and no-ECC are mutually exclusive");