Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1CD55r-0001HL-IV for mharc-grub-devel@gnu.org; Thu, 30 Sep 2004 13:51:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CD55q-0001HB-E5 for grub-devel@gnu.org; Thu, 30 Sep 2004 13:51:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CD55p-0001Gj-Ko for grub-devel@gnu.org; Thu, 30 Sep 2004 13:51:49 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CD55p-0001Gg-9r for grub-devel@gnu.org; Thu, 30 Sep 2004 13:51:49 -0400 Received: from [195.113.31.125] (helo=artax.karlin.mff.cuni.cz) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CD4zC-00008D-8Y for grub-devel@gnu.org; Thu, 30 Sep 2004 13:44:58 -0400 Received: by artax.karlin.mff.cuni.cz (Postfix, from userid 17122) id C27325332; Thu, 30 Sep 2004 19:44:56 +0200 (CEST) Date: Thu, 30 Sep 2004 19:44:56 +0200 From: Tomas Ebenlendr To: The development of GRUB 2 Message-ID: <20040930174456.GC31587@artax.karlin.mff.cuni.cz> Mail-Followup-To: The development of GRUB 2 References: <20040928190544.GA24852@artax.karlin.mff.cuni.cz> <200409291702.16894.okuji@enbug.org> <20040929213801.GC30478@artax.karlin.mff.cuni.cz> <200409301533.28151.okuji@enbug.org> <871xgjg5ll.fsf@marco.marco-g.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871xgjg5ll.fsf@marco.marco-g.com> User-Agent: Mutt/1.5.6i Subject: Re: Automagic command loading 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: Thu, 30 Sep 2004 17:51:50 -0000 > "Yoshinori K. Okuji" writes: > > > On Wednesday 29 September 2004 23:38, Tomas Ebenlendr wrote: > >> Disadvantage: current solution slowly reads the contens of directory. > >> This is probably caused by opening files by /full/ path, where we > >> principially have opened directory (and resolved path to it.). > > > > I think this is a critical problem. For example, if the user has a > > broken module which may crash GRUB, the user can easily break GRUB by > > trying a non-existent command. > > As far as I understood what Tomas said, the modules are loaded and > only the new section is checked. So it will not be initialized. > > > Also, if my understanding is correct, the list of modules is stored in a > > binary form. This means that the user cannot (easily) modify the list > > after building GRUB. > > Every module contains the list of commands it exports, AFAIK. So the > is no single big central list. > > > The advantage of autocmd.lst is that it makes customization much easier. > > Suppose that the user wants to add a new command and build his own > > module. Then, how to autoload this command? > > The new module will contain this specific section as well. > Yes, exactly. The section name is ".uinfo.norm_cmds" and command "command_name" is stored there when NORMAL_COMMAND("command_name") occurs in file from command_name_mod_SOURCES. So typical use should be: #ifdef GRUB_UTIL module_name_init (...) { grub_register_command("command_name", ...) } #else MODULE_INIT { grub_register_command(NORMAL_COMMAND("command_name"), ...) } #endif The first line with grub_register_command() does not affect module code. So no NORMAL_COMMAND should be used. On the other hand, the second line with grub_register_command() is code that occurs in module. So using NORMAL_COMMAND ensures, that the "command_name" also occurs in the special elf section. -- Tomas 'ebi' Ebenlendr http://get.to/ebik PF 2004.74813635271