]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/getroot.c (pull_lvm_by_command): add --separator option
authorAndrey Borzenkov <arvidjaar@gmail.com>
Wed, 14 Aug 2013 16:40:39 +0000 (20:40 +0400)
committerAndrey Borzenkov <arvidjaar@gmail.com>
Wed, 14 Aug 2013 16:40:39 +0000 (20:40 +0400)
to vgs call to disable padding of output to 10 characters.

ChangeLog
util/getroot.c

index 94a23607ffe8dc90102334a87636b3530cbddccb..fe1f6b7e31dba878c999eccf2cb4d6856af8a961 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-14  Andrey Borzenkov <arvidjaar@gmail.com>
+
+       *  util/getroot.c (pull_lvm_by_command): add --separator option
+       to vgs call to disable padding of output to 10 characters.
+
 2013-08-14  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/kern/emu/misc.c (grub_device_mapper_supported): Move from
index ab5ff8dea6adbeaa44d08a06e02c3771d56aa0be..b6fbe5842e6ef6ba5128a3cac9fb3c2741caf18a 100644 (file)
@@ -1322,7 +1322,7 @@ grub_util_get_dev_abstraction (const char *os_dev)
 static void
 pull_lvm_by_command (const char *os_dev)
 {
-  char *argv[6];
+  char *argv[8];
   int fd;
   pid_t pid;
   FILE *mdadm;
@@ -1351,12 +1351,17 @@ pull_lvm_by_command (const char *os_dev)
 
   /* execvp has inconvenient types, hence the casts.  None of these
      strings will actually be modified.  */
+  /* by default PV name is left aligned in 10 character field, meaning that
+     we do not know where name ends. Using dummy --separator disables
+     alignment. We have a single field, so separator itself is not output */
   argv[0] = (char *) "vgs";
   argv[1] = (char *) "--options";
   argv[2] = (char *) "pv_name";
   argv[3] = (char *) "--noheadings";
-  argv[4] = vgname;
-  argv[5] = NULL;
+  argv[4] = (char *) "--separator";
+  argv[5] = (char *) ":";
+  argv[6] = vgname;
+  argv[7] = NULL;
 
   pid = exec_pipe (argv, &fd);
   free (vgname);
@@ -1376,6 +1381,7 @@ pull_lvm_by_command (const char *os_dev)
   while (getline (&buf, &len, mdadm) > 0)
     {
       char *ptr;
+      /* LVM adds two spaces as standard prefix */
       for (ptr = buf; ptr < buf + 2 && *ptr == ' '; ptr++);
       if (*ptr == '\0')
        continue;