diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-04-17 14:54:48 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-04-17 14:58:40 +0100 |
commit | 8d3d5a52d2746af91f770608cce5f47462f33aba (patch) | |
tree | 65ac62066181cbb5c5049977fa04f008b07a67c6 /sparsify/utils.ml | |
parent | fb401ebff837f9df7c06acb8467b2c03d5b8ced0 (diff) | |
download | libguestfs-8d3d5a52d2746af91f770608cce5f47462f33aba.tar.gz libguestfs-8d3d5a52d2746af91f770608cce5f47462f33aba.tar.xz libguestfs-8d3d5a52d2746af91f770608cce5f47462f33aba.zip |
sparsify: Fix comma/colon and quoting in qemu-img command.
Colon characters are not allowed in qemu/qemu-img filenames. There's
no way to quote them.
Comma characters CAN be used. However they must be quoted (by
doubling) when used in the '-o' option.
Fix general quoting problems in the external command.
Diffstat (limited to 'sparsify/utils.ml')
-rw-r--r-- | sparsify/utils.ml | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sparsify/utils.ml b/sparsify/utils.ml index e34fe403..d2be12c8 100644 --- a/sparsify/utils.ml +++ b/sparsify/utils.ml @@ -76,6 +76,16 @@ let rec string_find s sub = in loop 0 +let rec replace_str s s1 s2 = + let len = String.length s in + let sublen = String.length s1 in + let i = string_find s s1 in + if i = -1 then s + else ( + let s' = String.sub s 0 i in + let s'' = String.sub s (i+sublen) (len-i-sublen) in + s' ^ s2 ^ replace_str s'' s1 s2 + ) let string_random8 = let chars = "abcdefghijklmnopqrstuvwxyz0123456789" in fun () -> |