From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HuqxZ-0005z4-Go for mharc-grub-devel@gnu.org; Sun, 03 Jun 2007 10:21:33 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HuqxX-0005up-UX for grub-devel@gnu.org; Sun, 03 Jun 2007 10:21:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HuqxX-0005sG-8b for grub-devel@gnu.org; Sun, 03 Jun 2007 10:21:31 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HuqxW-0005rf-P7 for grub-devel@gnu.org; Sun, 03 Jun 2007 10:21:30 -0400 Received: from 245.red-80-24-127.staticip.rima-tde.net ([80.24.127.245] helo=manazas.ensanjose.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HuqxV-0004JU-SX for grub-devel@gnu.org; Sun, 03 Jun 2007 10:21:30 -0400 Received: from localhost (manazas.ensanjose.net [127.0.0.1]) by manazas.ensanjose.net (Postfix) with ESMTP id 44BE5D444D for ; Sun, 3 Jun 2007 16:21:28 +0200 (CEST) Received: from manazas.ensanjose.net ([127.0.0.1]) by localhost (manazas.ensanjose.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19011-05 for ; Sun, 3 Jun 2007 16:21:28 +0200 (CEST) Received: from [192.168.161.251] (131.Red-213-96-108.staticIP.rima-tde.net [213.96.108.131]) by manazas.ensanjose.net (Postfix) with ESMTP id BA68BD32AE for ; Sun, 3 Jun 2007 16:21:27 +0200 (CEST) Message-ID: <46622EA0.6000202@raulete.net> Date: Sun, 03 Jun 2007 04:59:44 +0200 From: adrian15 User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: grub-devel@gnu.org References: <200706021604.l52G4Ar4014398@correoredir01.dinaserver.com> In-Reply-To: <200706021604.l52G4Ar4014398@correoredir01.dinaserver.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-kernel: Linux 2.4-2.6 Subject: Re: test -e patch 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: Sun, 03 Jun 2007 14:21:32 -0000 > On Wed, Jun 06, 2007 at 01:42:48AM +0200, adrian15 wrote: >> Attached you will find the patch adding test -e support for grub2. >> >> This is my first patch. I have compiled it without no errors. >> >> However as long as the grub2.tar.gz that Marco gave me did not have any >> documentation about how to create a floppy (or at least I did not manage >> to find it) > > This should work: > > cat boot.img core.img | dd of=foo.img seek=0 conv=notrunc I would like to have a floppy with the fs on it. See my other mail about my floppy creation adventure. > >> > static const struct grub_arg_option options[] = >>> { >>> {"file", 'e', 0, "test if a file exists", 0, 0}, >>> {0, 0, 0, 0, 0, 0} >>> }; >> Is this correct? What's that last line for? Is it compulsory ? > > It's common practice for arrays to make them null-terminated to be able to > determine their limits without making assumptions about their size. Doing it > with structs is akin to null-terminating a char array. Ok. I understand then. > >>> { >>> grub_file_t file; >>> >>> file = grub_file_open (key); > > What happens if file is a device node, or a directory? Does grub_file_open > work with these? I have not tried a device node, but with a directory it fails. > Perhaps grub_file_stat would make more sense You might be right but why then you (grub2 developers) have developed the search command with the help of grub_file_open ?? Should the search command be reimplemented with grub_file_stat ? >> What are the error polices ? > IMHO, an error would be if existance of the file cannot be determined. I don't > think non-existance should be considered an error too. However, existing code > in the test plugin already does this, which puzzles me. We will have to wait for marco_g for telling us how it works, then. > >>> GRUB_MOD_INIT(test) >>> { >>> (void)mod; /* To stop warning. */ >>> grub_register_command ("[", grub_cmd_test, GRUB_COMMAND_FLAG_CMDLINE, >>> "[ EXPRESSION ]", "Evaluate an expression", 0); >>> grub_register_command ("test", grub_cmd_test, GRUB_COMMAND_FLAG_CMDLINE, >>> "test EXPRESSION", "Evaluate an expression", 0); >>> } >> I understand this register commands. I suppose this information is read >> from the help command or it isn't ? > > Yes. Also with "test --help". > >> Or maybe it also reads from: >> static const struct grub_arg_option options ? > > That too. > >> The question is if the user will see the -e, -f or other options when >> querying the test command help or not ? > > Yes, based on options[]. But you should really test that and not blindly > believe me :-) I've checked that it does not read from struct grub_arg_option options , strange thing. >> +static const struct grub_arg_option options[] = >> + { >> + {"file", 'e', 0, "Test if a file exists", 0, 0}, > > Do we want a long option here? bash/coreutils don't have any. I do not want a long option :) adrian15