[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] daemon: lvm: change the separator character to '\r'



Commit b91b39e06ab7eb9b9b06c8b4dfef2ef9f381ab19 changed the separator to
':', although this creates parsing issues when there are fields with
colons (for example lv_tags=imgbased:pool).

Change once more the separator, but this time using a non-printable
character such as '\r': while it will produce uglier debug logs, this
should greatly reduce the possibilities of conflicts with texts of
metadata.
---
 generator/daemon.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generator/daemon.ml b/generator/daemon.ml
index d8dc9cf..1d79126 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -563,7 +563,7 @@ cleanup_free_mountable (mountable_t *mountable)
             pr "    fprintf (stderr, \"%%s: failed: string finished early, around token %%s\\n\", __func__, \"%s\");\n" name;
             pr "    return -1;\n";
             pr "  }\n";
-            pr "  p = strchrnul (tok, ':');\n";
+            pr "  p = strchrnul (tok, '\\r');\n";
             pr "  if (*p) next = p+1; else next = NULL;\n";
             pr "  *p = '\\0';\n";
             (match coltype with
@@ -633,7 +633,7 @@ cleanup_free_mountable (mountable_t *mountable)
         pr "  r = command (&out, &err,\n";
         pr "	       \"lvm\", \"%ss\",\n" typ;
         pr "	       \"-o\", lvm_%s_cols, \"--unbuffered\", \"--noheadings\",\n" typ;
-        pr "	       \"--nosuffix\", \"--separator\", \":\", \"--units\", \"b\", NULL);\n";
+        pr "	       \"--nosuffix\", \"--separator\", \"\\r\", \"--units\", \"b\", NULL);\n";
         pr "  if (r == -1) {\n";
         pr "    reply_with_error (\"%%s\", err);\n";
         pr "    free (out);\n";
-- 
2.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]