Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1K7bgN-0003wJ-62 for mharc-grub-devel@gnu.org; Sat, 14 Jun 2008 15:45:03 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K7bgL-0003v8-B6 for grub-devel@gnu.org; Sat, 14 Jun 2008 15:45:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K7bgI-0003uC-Qc for grub-devel@gnu.org; Sat, 14 Jun 2008 15:44:59 -0400 Received: from [199.232.76.173] (port=55735 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7bgI-0003tz-GA for grub-devel@gnu.org; Sat, 14 Jun 2008 15:44:58 -0400 Received: from rv-out-0708.google.com ([209.85.198.248]:37115) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K7bgH-0002Rk-Og for grub-devel@gnu.org; Sat, 14 Jun 2008 15:44:58 -0400 Received: by rv-out-0708.google.com with SMTP id k29so5309948rvb.6 for ; Sat, 14 Jun 2008 12:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=8zl27BqGyfRHExxK4o5ZDwUFobgc09AbK44nnUle5po=; b=A4bWRZNlxK+56s5lXmpJGQ/0LPOmTwLnuQutNSY27dYGeBXH3LQVC5XPbk+0hTShfE 5DMcB2tfbdtytyNOWuwuUpXxImC62ycsWDgWGOFlbrOLB7B+97Ki1KgedrP5HCEY/PAY D1/lYMatZcHxjdOr5SzkHOx/+2e0DGhk2l3Wg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=S2uQbbNHvkSzaHzTWMxeeGHvSDixyS1OZ1P8VGH8mJoo5TKTS2RvXdc+DdiK0ROjqw MjXZweGkb7fF31GQMKqqVWtRmJartr0JxXIPcvmQPJkT15QPQLcMLYgovQY9c3BI91Bm WUyvU756hFWQbW9+HJf0nN8i02lHaLzzKzfzA= Received: by 10.141.69.1 with SMTP id w1mr2692958rvk.185.1213472696429; Sat, 14 Jun 2008 12:44:56 -0700 (PDT) Received: by 10.141.66.21 with HTTP; Sat, 14 Jun 2008 12:44:56 -0700 (PDT) Message-ID: Date: Sun, 15 Jun 2008 03:44:56 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <20080614193028.GB840@thorin> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080614193028.GB840@thorin> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: [PATCH] Save/Load environment variable support 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: Sat, 14 Jun 2008 19:45:01 -0000 On Sun, Jun 15, 2008 at 3:30 AM, Robert Millan wrote: > On Fri, Jun 13, 2008 at 03:07:54PM +0800, Bean wrote: >> # Misc. >> -pkglib_MODULES += gzio.mod elf.mod >> +pkglib_MODULES += gzio.mod elf.mod findroot.mod >> >> [...] >> +# For findroot.mod. >> +findroot_mod_SOURCES = kern/findroot.c >> +findroot_mod_CFLAGS = $(COMMON_CFLAGS) >> +findroot_mod_LDFLAGS = $(COMMON_LDFLAGS) > > Some findroot bits were mixed up in the patch. Oh, I forget to remove them. > >> +/* Names of important environment variables. */ >> +#define GRUB_ENVBLK_RDIR "rdir" >> +#define GRUB_ENVBLK_UUID "uuid" >> +#define GRUB_ENVBLK_LABEL "label" >> +#define GRUB_ENVBLK_IDFILE "idfile" > > I'd prefer if the envblk part was agnostic about which variables have a > meaning. > >> +++ b/util/envblk.c >> @@ -0,0 +1,171 @@ >> +/* envblk.c - Common function for environment block. */ >> [...] >> + >> +#ifdef GRUB_UTIL > > Files that are meant to be used both by grub and util are usually put in > the non-util dir (I'm not sure which non-util dir would fit, though, as it > depends on what you want to do next). > >> +#include >> + >> +#define grub_strlen strlen >> +#define grub_strcpy strcpy >> +#define grub_strchr strchr >> +#define grub_memcmp memcmp >> +#define grub_memcpy memcpy > > Uhm can we avoid this? The rest of non-util code just calls the grub_* > functions (linking with kern/misc.c in this case). I fount out that if I use grub_*, I end up adding quite a few of extra modules that serve no purpose other than string manipulation. Perhaps we should separate those routines from kern/misc.c ? > >> +grub_envblk_t >> +grub_envblk_find (char *buf) >> +{ >> + grub_uint32_t *pd; >> + int len; >> + >> + pd = (grub_uint32_t *) buf; >> + >> + for (len = GRUB_ENVBLK_MAXLEN - 6; len > 0; len -= 4, pd++) >> + if (*pd == GRUB_ENVBLK_SIGNATURE) > > I wonder if this would be dangerous when run on files where env block > presence is optional, like core.img (though we can always think about this > later when that option is added). Yes, perhaps we should store a pointer to environment block so that we don't need to scan for it. -- Bean