All of lore.kernel.org
 help / color / mirror / Atom feed
From: adrian15 <adrian15@raulete.net>
To: grub-devel@gnu.org
Subject: Re: test -e patch
Date: Sun, 03 Jun 2007 04:59:44 +0200	[thread overview]
Message-ID: <46622EA0.6000202@raulete.net> (raw)
In-Reply-To: <200706021604.l52G4Ar4014398@correoredir01.dinaserver.com>

> 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




  parent reply	other threads:[~2007-06-03 14:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200706021604.l52G4Ar4014398@correoredir01.dinaserver.com>
2007-06-03  2:59 ` test -e patch adrian15
2007-06-03  2:59 ` adrian15 [this message]
2007-06-03  2:59 ` adrian15
2007-06-04 15:34   ` Marco Gerards
     [not found] <200706041604.l54G4p0v029961@correoredir01.dinaserver.com>
2007-06-05 17:32 ` adrian15
2007-06-05 18:13   ` Marco Gerards
2007-06-05 23:42 adrian15
2007-06-02  9:07 ` Robert Millan
2007-06-02 12:05 ` Robert Millan
2007-06-04 15:26 ` Marco Gerards
     [not found] <200706051834.l55IY56F003249@correoredir01.dinaserver.com>
2007-06-06 18:04 ` adrian15

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46622EA0.6000202@raulete.net \
    --to=adrian15@raulete.net \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.