summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-07-15 10:50:59 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-07-15 11:08:38 +0200
commiteb135abe5aa13190160ba45fcd5defdc573c24ba (patch)
treebb93f504ceb7fe948ae9eee9a07c89a94fa45e89 /commands
parentaf66ec677c40dfaed68a124d21dd59d5f8c63381 (diff)
downloadbarebox-eb135abe5aa13190160ba45fcd5defdc573c24ba.tar.gz
ubiformat: improve generation of UBI image sequence
The UBI ec_hdr has an image_seq field. During attaching UBI expects that its value is the same for all eraseblocks. The value should be changed with every ubiformat and is used to detect half written images. In barebox we use a pseudo random number generated with rand() for this value. The ubiformat command calls srand(get_time_ns()) to initialize the pseudo random numbber generator. This is done in the option parser, so when ubiformat() is called directly (from fastboot for example) the pseudo random number generator is not initialized and we get the same values after every barebox restart. This patch moves the pseudo random number generator initialization to the place where the numbers are generated. Also use random32() rather than rand() to generate 32bit values rather than 15bit values (0 - RAND_MAX). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/ubiformat.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/commands/ubiformat.c b/commands/ubiformat.c
index a88672d..7537e6b 100644
--- a/commands/ubiformat.c
+++ b/commands/ubiformat.c
@@ -58,7 +58,6 @@
static int parse_opt(int argc, char *argv[], struct ubiformat_args *args,
char **node)
{
- srand(get_time_ns());
memset(args, 0, sizeof(*args));
while (1) {