Skip to contentSkip to conversation

ubi : generate random image_seq when attaching empty MTD device

PATCH In review Matthieu CASTET 2 participants 4 messages Jun 3, 2010 – Jun 10, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ubi : generate random image_seq when attaching empty MTD device

generate random image_seq when attaching empty MTD device (kernel do the ubi formating).

drivers/mtd/ubi/scan.c +4 -1
index aed19f3..7a95ff3 100644
@@ -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
#1 lore raw
Quoted 4 lines · Matthieu CASTET

generate random image_seq when attaching empty MTD device (kernel do the ubi formating).

Looks OK, I'll push it to the UBI tree as soon as I have time - very busy right now, thanks.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
#2 lore raw
In reply to Matthieu CASTET
Quoted 2 lines · Matthieu CASTET

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.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
#3 lore raw
Quoted 7 lines · Artem Bityutskiy
Quoted 1 line · Matthieu CASTET

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.