diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-06-13 18:58:53 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-06-13 19:00:17 +0100 |
commit | dc6b633ea55145d1552ae60812dc1000d33890a3 (patch) | |
tree | e249f3475e5d5a7f107d074ae9481cf91e39535b | |
parent | 4c8bab2f3ea68dbb0c2029501ec21b4f1ca9049d (diff) | |
download | libguestfs-dc6b633ea55145d1552ae60812dc1000d33890a3.tar.gz libguestfs-dc6b633ea55145d1552ae60812dc1000d33890a3.tar.xz libguestfs-dc6b633ea55145d1552ae60812dc1000d33890a3.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
(cherry picked from commit 4ee190628bc05f0c8fad1f6d9c3e85619a91e8b8)
-rw-r--r-- | generator/generator_utils.ml | 8 |
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 ^ "-" |