grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grub2 common argument parser


From: adrian15
Subject: grub2 common argument parser
Date: Sat, 09 Jun 2007 09:34:41 +0200
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

        I have an idea that I am not able to implement in bash because I have
no time. It consists about an xml file that has all the arguments of a
command and how they should be (a file, a device, an string), if an
argument is compulsory or not, if two arguments are incompatible.
        This xml file can be read by a GUI program that can present you a GUI
to any of your console programs. Like if it was an interactive 'man'.
Each option has its explanation and you can fill the empty boxes.
        And the next step is that the man files instead of being man files
would be these xml files.

        Well one thing more or less equivalent that could be done in grub2 is a
"grub2 common argument parser".

        I think it can be done because most of the argument types are the same
ones: FILE, ENVVAR, MODULE, TERM, EXPRESSION, DEVICENME, PATTERN.

        Why we should let every command parse its own arguments when we could
have a common argument parser.

        The idea is the following one:

        When you define a command argument by the means of options...

        static const struct grub_arg_option options[] =
  {
    {"file", 'f', 0, "search devices by a file (default)", 0, 0},
    {"label", 'l', 0, "search devices by a filesystem label", 0, 0},
    {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first
device found", "VAR", ARG_TYPE_STRING},
    {0, 0, 0, 0, 0, 0}
  };

Hey... there's something about it on the search.c code but it is not
complete. It seems that the 3rd filed is what I need and maybe the last one.

Hey it seems that this is already in the TODO list.

 (normal/arg.c)
            case ARG_TYPE_DEVICE:
            case ARG_TYPE_DIR:
            case ARG_TYPE_FILE:
            case ARG_TYPE_PATHNAME:
              /* XXX: Not implemented.  */


That's a good and bad piece of news. That means that I will have to
reimplement the test -e command in a future in order to take advantage
of this implementation.

The ARG_TYPE_FILE check is only trying to open it with grub_file_open ()
or maybe the grub_file_stat ... hummm... someone on the mailing list
adviced me to use this second one but I do not find it.

It seems for me that the filesystem modules or drivers do only have
these commands:

    .name = "ext2",
    .dir = grub_ext2_dir,
    .open = grub_ext2_open,
    .read = grub_ext2_read,
    .close = grub_ext2_close,
    .label = grub_ext2_label,
    .next = 0


A question for marco_g
==========================

This .next is for file iteration inside a folder, maybe?

And another question for everybody... do we need to implement a
grub_file_stat function or not?

adrian15





reply via email to

[Prev in Thread] Current Thread [Next in Thread]