Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KQJeO-0008QH-N9 for mharc-grub-devel@gnu.org; Tue, 05 Aug 2008 06:20:20 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KQJeI-0008P8-9i for grub-devel@gnu.org; Tue, 05 Aug 2008 06:20:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KQJeD-0008OV-Ag for grub-devel@gnu.org; Tue, 05 Aug 2008 06:20:12 -0400 Received: from [199.232.76.173] (port=44870 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KQJeB-0008OA-C6 for grub-devel@gnu.org; Tue, 05 Aug 2008 06:20:08 -0400 Received: from smtp-vbr2.xs4all.nl ([194.109.24.22]:2667) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KQJeB-0005PT-3Q for grub-devel@gnu.org; Tue, 05 Aug 2008 06:20:07 -0400 Received: from localhost.localdomain (249-174.surfsnel.dsl.internl.net [145.99.174.249]) by smtp-vbr2.xs4all.nl (8.13.8/8.13.8) with ESMTP id m75AK5H4009069 for ; Tue, 5 Aug 2008 12:20:06 +0200 (CEST) (envelope-from mgerards@xs4all.nl) From: Marco Gerards To: The development of GRUB 2 References: <1217445082.23034.22.camel@fz-deb.local> <20080801131201.GB12405@thorin> <1217603381.4354.9.camel@fz-deb.local> <1217610057.4354.22.camel@fz-deb.local> Mail-Copies-To: mgerards@xs4all.nl Date: Tue, 05 Aug 2008 12:22:44 +0200 In-Reply-To: <1217610057.4354.22.camel@fz-deb.local> (Felix Zielcke's message of "Fri, 01 Aug 2008 19:00:57 +0200") Message-ID: <8763qfhibv.fsf@xs4all.nl> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by XS4ALL Virus Scanner X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 Subject: Re: [PATCH] Add support for /dev/md/N style mdraid devices X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Aug 2008 10:20:16 -0000 Felix Zielcke writes: > Am Freitag, den 01.08.2008, 17:09 +0200 schrieb Felix Zielcke: > >> Maybe there's a way to make it even better so please comment all of you >> grub-devels :) > > Thanks to Robert who suggested asprintf > > I hope the #define _GNU_SOURCE which is needed for it isn't a problem, > you use anyway gcc specific extentions and GRUB is a GNU project :) AFAIK it isn't, so better leave it away. > I hadn't yet an idea how to solve that md_dNNpNN case with it, so I just > moved the xmalloc() call down to that. What's the problem? > Please comment which way you mostly like. I would prefer a changelog entry while commenting. > Index: util/getroot.c > =================================================================== > --- util/getroot.c (Revision 1757) > +++ util/getroot.c (Arbeitskopie) > @@ -17,6 +17,7 @@ > * along with GRUB. If not, see . > */ > > +#define _GNU_SOURCE > #include > #include > #include > @@ -407,17 +408,16 @@ > switch (grub_util_get_dev_abstraction (os_dev)) > { > case GRUB_DEV_ABSTRACTION_LVM: > - grub_dev = xmalloc (strlen (os_dev) - 12 + 1); > > - strcpy (grub_dev, os_dev + 12); > - > + asprintf(&grub_dev,"%s",os_dev + strlen("/dev/mapper/") -1); Please add a space between asprintf and (&grub_dev .... Same for the lines below. > break; > > case GRUB_DEV_ABSTRACTION_RAID: > - grub_dev = xmalloc (20); > > if (os_dev[7] == '_' && os_dev[8] == 'd') > { > + grub_dev = xmalloc (20); > + > const char *p; > > /* This a partitionable RAID device of the form /dev/md_dNNpMM. */ > @@ -457,9 +457,12 @@ > } > else if (os_dev[7] >= '0' && os_dev[7] <= '9') > { > - memcpy (grub_dev, os_dev + 5, 7); > - grub_dev[7] = '\0'; > + asprintf(&grub_dev,"md%s",os_dev + sizeof("/dev/md") -1); > } > + else if (os_dev[7] == '/' && os_dev[8] >= '0' && os_dev[8] <= '9') > + { > + asprintf(&grub_dev,"md%s",os_dev + sizeof("/dev/md/") -1); > + } > else > grub_util_error ("Unknown kind of RAID device `%s'", os_dev); > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel