summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-06-13 18:58:53 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-06-13 18:58:53 +0100
commit4ee190628bc05f0c8fad1f6d9c3e85619a91e8b8 (patch)
tree7375191b94b28335116dbaed951a111c37466b72 /generator
parent1f59849a4a45a1c78488eb41b250de631b4405a6 (diff)
downloadlibguestfs-4ee190628bc05f0c8fad1f6d9c3e85619a91e8b8.tar.gz
libguestfs-4ee190628bc05f0c8fad1f6d9c3e85619a91e8b8.tar.xz
libguestfs-4ee190628bc05f0c8fad1f6d9c3e85619a91e8b8.zip
generator: Rewrite UUIDs that begin with zero byte.
In util-linux <= 2.19, mkswap -U cannot handle the first byte of the UUID being zero, so we artificially rewrite such UUIDs. See: http://article.gmane.org/gmane.linux.utilities.util-linux-ng/4273
Diffstat (limited to 'generator')
-rw-r--r--generator/generator_utils.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/generator/generator_utils.ml b/generator/generator_utils.ml
index f62b1956..4180c0d6 100644
--- a/generator/generator_utils.ml
+++ b/generator/generator_utils.ml
@@ -55,6 +55,14 @@ let string_of_errcode = function
*)
let uuidgen () =
let s = Digest.to_hex (Digest.file "generator/generator_actions.ml") in
+
+ (* In util-linux <= 2.19, mkswap -U cannot handle the first byte of
+ * the UUID being zero, so we artificially rewrite such UUIDs.
+ * http://article.gmane.org/gmane.linux.utilities.util-linux-ng/4273
+ *)
+ if s.[0] = '0' && s.[1] = '0' then
+ s.[0] <- '1';
+
String.sub s 0 8 ^ "-"
^ String.sub s 8 4 ^ "-"
^ String.sub s 12 4 ^ "-"