Patchwork ubi : generate random image_seq when attaching empty MTD device

login
register
mail settings
Submitter Matthieu CASTET
Date June 3, 2010, 2:14 p.m.
Message ID <4C07B8C3.7080304@parrot.com>
Download mbox | patch
Permalink /patch/54486/
State New
Headers show

Comments

Matthieu CASTET - June 3, 2010, 2:14 p.m.
generate random image_seq when attaching empty MTD device (kernel do the 
ubi formating).

Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
Artem Bityutskiy - June 3, 2010, 2:25 p.m.
On Thu, 2010-06-03 at 16:14 +0200, Matthieu CASTET wrote:
> generate random image_seq when attaching empty MTD device (kernel do the 
> ubi formating).
> 
> Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>

Looks OK, I'll push it to the UBI tree as soon as I have time - very
busy right now, thanks.
Artem Bityutskiy - June 8, 2010, 8:45 a.m.
On Thu, 2010-06-03 at 16:14 +0200, Matthieu CASTET wrote:
> generate random image_seq when attaching empty MTD device (kernel do the 
> ubi formating).

Your patch did not apply to the ubi-2.6.git master, because it
conflicted with my latest changes. But I amended it and pushed, but you
should probably check.

Thanks.
Matthieu CASTET - June 10, 2010, 1:37 p.m.
Artem Bityutskiy a écrit :
> On Thu, 2010-06-03 at 16:14 +0200, Matthieu CASTET wrote:
>> generate random image_seq when attaching empty MTD device (kernel do the 
>> ubi formating).
> 
> Your patch did not apply to the ubi-2.6.git master, because it
> conflicted with my latest changes. But I amended it and pushed, but you
> should probably check.
> 
It looks fine.

Thanks.

Patch

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index aed19f3..7a95ff3 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -44,6 +44,7 @@ 
 #include <linux/slab.h>
 #include <linux/crc32.h>
 #include <linux/math64.h>
+#include <linux/random.h>
 #include "ubi.h"
 
 #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
@@ -935,8 +936,10 @@  struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
 	if (si->ec_count)
 		si->mean_ec = div_u64(si->ec_sum, si->ec_count);
 
-	if (si->is_empty)
+	if (si->is_empty) {
 		ubi_msg("empty MTD device detected");
+		get_random_bytes(&ubi->image_seq, sizeof(ubi->image_seq));
+	}
 
 	/*
 	 * Few corrupted PEBs are not a problem and may be just a result of