From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1V9cwX-000787-B2 for mharc-grub-devel@gnu.org; Wed, 14 Aug 2013 11:25:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9cwM-000774-Oa for grub-devel@gnu.org; Wed, 14 Aug 2013 11:25:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9cwE-00050u-Bt for grub-devel@gnu.org; Wed, 14 Aug 2013 11:24:50 -0400 Received: from mail-ea0-x236.google.com ([2a00:1450:4013:c01::236]:50911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9cwE-00050f-52 for grub-devel@gnu.org; Wed, 14 Aug 2013 11:24:42 -0400 Received: by mail-ea0-f182.google.com with SMTP id o10so4893135eaj.41 for ; Wed, 14 Aug 2013 08:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=e+6vCjSh/Ww7maK2e11d+8rfaB76Qsb9s7b0dknDav8=; b=tZi5QVjRoU5/ymNaOPqoCbGgo5n1p3ykbV1dWgbWi1HryMQJIjDQYEHQfrXCopbPpe 3ROS4dvg7xsDMzdJ+BnYemW/nQZrncwE2D4hqy88vpZkaiRydUn0owsKC1MhTIrl668d MJj+me5WZwvj/NMqtYjxds/3HLzBl3NL3Bgbay28JTkGs/Vat/Yh2bSs5UfM1fZP6vl8 U+udTOLlHgabrmXfB4VkSPtdD4EfpB3pagEbzIS7C11miEMztKaCGiWGgs5gj0yCeUWM Pt+X+IXYHGwPA6YCB/IgrMb5KSJvVc5lMuvhKNkR8dqNUsLlK0JK/eKUN2M3Yfd0YsP+ zw7g== X-Received: by 10.14.173.5 with SMTP id u5mr1610873eel.89.1376493881453; Wed, 14 Aug 2013 08:24:41 -0700 (PDT) Received: from [192.168.42.216] (223-226.197-178.cust.bluewin.ch. [178.197.226.223]) by mx.google.com with ESMTPSA id d8sm62775254eeh.8.2013.08.14.08.24.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Aug 2013 08:24:40 -0700 (PDT) Message-ID: <520BA131.5000308@gmail.com> Date: Wed, 14 Aug 2013 17:24:33 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130630 Icedove/17.0.7 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: [PATCH] fix parsing of LVM PV names for short names References: <1374217896-21412-1-git-send-email-arvidjaar@gmail.com> <1374919798-21531-1-git-send-email-arvidjaar@gmail.com> In-Reply-To: <1374919798-21531-1-git-send-email-arvidjaar@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::236 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Aug 2013 15:25:00 -0000 Go ahead On 27.07.2013 12:09, Andrey Borzenkov wrote: > Default format of vgs output is > > - two spaces as standard prefix > - PV name left aligned to field width which is 10 characters > > This means that if PV name has less than 10 chacaters it has some spaces at > the end. > > Example: > > linux-chxo:~ # vgs -o pv_name --noheadings | cat -E > /dev/md1 $ > /dev/md101$ > linux-chxo:~ # > > There is no explicit option to turn off alignment; it is implicitly > disabled if one of --separator or --nameprefixes option is used. > > --separator was added in 2007, --nameprefixes - in 2009. So let's use > --separator to extend range of versions we are compatible with. Note that > one or another must be used, current parsing is broken otherwise. > > Signed-off-by: Andrey Borzenkov > > --- > util/getroot.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/util/getroot.c b/util/getroot.c > index 2ad8a55..3afcf96 100644 > --- a/util/getroot.c > +++ b/util/getroot.c > @@ -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; >