Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KOxzv-00058v-Dr for mharc-grub-devel@gnu.org; Fri, 01 Aug 2008 13:00:59 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KOxzt-00058N-JR for grub-devel@gnu.org; Fri, 01 Aug 2008 13:00:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KOxzs-00057h-7b for grub-devel@gnu.org; Fri, 01 Aug 2008 13:00:57 -0400 Received: from [199.232.76.173] (port=52795 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KOxzs-00057X-0j for grub-devel@gnu.org; Fri, 01 Aug 2008 13:00:56 -0400 Received: from moutng.kundenserver.de ([212.227.126.188]:55701) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KOxzr-00007n-EY for grub-devel@gnu.org; Fri, 01 Aug 2008 13:00:55 -0400 Received: from [85.180.39.34] (e180039034.adsl.alicedsl.de [85.180.39.34]) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis) id 0ML31I-1KOxzq2PfC-0000ws; Fri, 01 Aug 2008 19:00:54 +0200 From: Felix Zielcke To: The development of GRUB 2 In-Reply-To: <1217603381.4354.9.camel@fz-deb.local> References: <1217445082.23034.22.camel@fz-deb.local> <20080801131201.GB12405@thorin> <1217603381.4354.9.camel@fz-deb.local> Content-Type: multipart/mixed; boundary="=-9kKGljhlvSXzT13BE8k3" Date: Fri, 01 Aug 2008 19:00:57 +0200 Message-Id: <1217610057.4354.22.camel@fz-deb.local> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-Provags-ID: V01U2FsdGVkX1/TiTYEvJPHrJ+OHASDedEStZEtIHtxZfnF9nr hDKlE41PRc2FD48RaUP4BUVND+YJByt7OgMjL1ndjfscS1oP+z w6C7AuzWBcyVwt9BXkYDVZpRvqjfLz7 X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) 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: Fri, 01 Aug 2008 17:00:57 -0000 --=-9kKGljhlvSXzT13BE8k3 Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 :) 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. Please comment which way you mostly like. --=-9kKGljhlvSXzT13BE8k3 Content-Disposition: attachment; filename=asprintf.diff Content-Type: text/x-patch; name=asprintf.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit 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); 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); --=-9kKGljhlvSXzT13BE8k3--