Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] wic: improve generating disk system identifier
@ 2017-07-31 10:53 Jonathan Liu
  0 siblings, 0 replies; only message in thread
From: Jonathan Liu @ 2017-07-31 10:53 UTC (permalink / raw)
  To: openembedded-core

This should reduce the chance of generating 0xffffffff as the disk
system identifier.

Signed-off-by: Jonathan Liu <net147@gmail.com>
---
 scripts/lib/wic/plugins/imager/direct.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 51bdd3a984..5765bbb527 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -26,6 +26,7 @@
 
 import logging
 import os
+import random
 import shutil
 import tempfile
 import uuid
@@ -303,7 +304,7 @@ class PartitionedImage():
                           # all partitions (in bytes)
         self.ptable_format = ptable_format  # Partition table format
         # Disk system identifier
-        self.identifier = int.from_bytes(os.urandom(4), 'little') or 0xffffffff
+        self.identifier = random.SystemRandom().randint(1, 0xffffffff)
 
         self.partitions = partitions
         self.partimages = []
-- 
2.13.2



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-31 10:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-31 10:53 [PATCH] wic: improve generating disk system identifier Jonathan Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox