Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KOwGO-0000h3-3w for mharc-grub-devel@gnu.org; Fri, 01 Aug 2008 11:09:52 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KOwGK-0000dS-SZ for grub-devel@gnu.org; Fri, 01 Aug 2008 11:09:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KOwGE-0000YO-Dn for grub-devel@gnu.org; Fri, 01 Aug 2008 11:09:47 -0400 Received: from [199.232.76.173] (port=52326 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KOwGE-0000Y7-7U for grub-devel@gnu.org; Fri, 01 Aug 2008 11:09:42 -0400 Received: from moutng.kundenserver.de ([212.227.126.187]:52758) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KOwGD-0007Oj-9H for grub-devel@gnu.org; Fri, 01 Aug 2008 11:09:41 -0400 Received: from [85.180.39.34] (e180039034.adsl.alicedsl.de [85.180.39.34]) by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis) id 0ML21M-1KOwGA3hrv-0000pN; Fri, 01 Aug 2008 17:09:39 +0200 From: Felix Zielcke To: The development of GRUB 2 In-Reply-To: <20080801131201.GB12405@thorin> References: <1217445082.23034.22.camel@fz-deb.local> <20080801131201.GB12405@thorin> Content-Type: multipart/mixed; boundary="=-IeiUkfz2YgbLWEpeq6ve" Date: Fri, 01 Aug 2008 17:09:41 +0200 Message-Id: <1217603381.4354.9.camel@fz-deb.local> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-Provags-ID: V01U2FsdGVkX1/ysy4jDxxKEEr2/8EheF9+3slPUfuI/BEWPxQ IbzcifG+50bLEiNnFBAKUjNg+46of6jsRCW6tmJ71Vr6DOTuv2 H+v4EXnfjgoB0WJGDG1sTE2ggXsPPIm 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 15:09:50 -0000 --=-IeiUkfz2YgbLWEpeq6ve Content-Type: text/plain Content-Transfer-Encoding: 7bit Am Freitag, den 01.08.2008, 15:12 +0200 schrieb Robert Millan: > This looks fine, but I'd suggest to avoid hardcoding numbers when possible. So > if you're adding 5 because that's the size of "/dev/", I think it's a good idea > to use sizeof("/dev/")-1, and so on. This way the code is much easier to > understand IMHO. > > (yes, I know the existing code above yours doesn't do this, but i think it's > a good idea to push for higher quality standards anyway ;-)) > Attached are now 2 patches for my added code and the one above. I personally prefer the strcpy one, there's no need to use memcpy, it should never happen that the /dev/md* devices contain a ASCII NUL Maybe there's a way to make it even better so please comment all of you grub-devels :) --=-IeiUkfz2YgbLWEpeq6ve Content-Disposition: attachment; filename=memcpy.diff Content-Type: text/x-patch; name=memcpy.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: util/getroot.c =================================================================== --- util/getroot.c (Revision 1757) +++ util/getroot.c (Arbeitskopie) @@ -457,9 +457,15 @@ } else if (os_dev[7] >= '0' && os_dev[7] <= '9') { - memcpy (grub_dev, os_dev + 5, 7); + memcpy (grub_dev, os_dev + sizeof("/dev/") -1, 7); grub_dev[7] = '\0'; } + else if (os_dev[7] == '/' && os_dev[8] >= '0' && os_dev[8] <= '9') + { + memcpy (grub_dev, "md", sizeof("md") -1); + memcpy (grub_dev + sizeof ("md") -1, os_dev + sizeof("/dev/md/") -1, 5); + grub_dev[7] = '\0'; + } else grub_util_error ("Unknown kind of RAID device `%s'", os_dev); --=-IeiUkfz2YgbLWEpeq6ve Content-Disposition: attachment; filename=strcpy.diff Content-Type: text/x-patch; name=strcpy.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: util/getroot.c =================================================================== --- util/getroot.c (Revision 1757) +++ util/getroot.c (Arbeitskopie) @@ -457,9 +457,16 @@ } else if (os_dev[7] >= '0' && os_dev[7] <= '9') { - memcpy (grub_dev, os_dev + 5, 7); + strcpy (grub_dev,"md"); + strncpy (grub_dev, os_dev + sizeof("/dev/md") -1,5); grub_dev[7] = '\0'; } + else if (os_dev[7] == '/' && os_dev[8] >= '0' && os_dev[8] <= '9') + { + strcpy (grub_dev,"md"); + strncpy (grub_dev + sizeof ("md") -1, os_dev + sizeof("/dev/md/") -1, 5); + grub_dev[7] = '\0'; + } else grub_util_error ("Unknown kind of RAID device `%s'", os_dev); --=-IeiUkfz2YgbLWEpeq6ve--