02.12.2015 17:52, Ignat Korchagin пишет: > OK. Updated patch below: > > diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def > index 0cc40bb..aa7b927 100644 > --- a/grub-core/Makefile.core.def > +++ b/grub-core/Makefile.core.def > @@ -735,6 +735,12 @@ module = { > }; > > module = { > + name = efivar; > + efi = commands/efi/efivar.c; > + enable = efi; > +}; > + > +module = { > name = blocklist; > common = commands/blocklist.c; > }; > diff --git a/grub-core/commands/efi/efivar.c b/grub-core/commands/efi/efivar.c > new file mode 100644 > index 0000000..8acd0c2 > --- /dev/null > +++ b/grub-core/commands/efi/efivar.c > @@ -0,0 +1,238 @@ > +/* efivar.c - Read EFI global variables. */ > +/* > + * GRUB -- GRand Unified Bootloader > + * Copyright (C) 2015 Free Software Foundation, Inc. > + * Copyright (C) 2015 CloudFlare, Inc. > + * > + * GRUB is free software: you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation, either version 3 of the License, or > + * (at your option) any later version. > + * > + * GRUB is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. > + */ > + > +#include <grub/types.h> > +#include <grub/mm.h> > +#include <grub/misc.h> > +#include <grub/efi/api.h> > +#include <grub/efi/efi.h> > +#include <grub/extcmd.h> > +#include <grub/env.h> > +#include <grub/lib/hexdump.h> > + > +GRUB_MOD_LICENSE ("GPLv3+"); > + > +static const struct grub_arg_option options[] = { > + {"format", 'f', GRUB_ARG_OPTION_OPTIONAL, N_("Parse EFI_VAR in > specific format (hex, uint8, ascii, dump). Default: hex."), > N_("FORMAT"), ARG_TYPE_STRING}, > + {"set", 's', GRUB_ARG_OPTION_OPTIONAL, N_("Save parsed result to > environment variable (does not work with dump)."), N_("ENV_VAR"), > ARG_TYPE_STRING}, > + {0, 0, 0, 0, 0, 0} > +}; > + > +enum efi_var_type > + { > + EFI_VAR_ASCII = 0, > + EFI_VAR_UINT8, > + EFI_VAR_HEX, > + EFI_VAR_DUMP, > + EFI_VAR_INVALID = -1 > + }; > + > +static enum efi_var_type > +parse_efi_var_type (const char *type) > +{ > + if (!grub_strncmp (type, "ascii", sizeof("ascii"))) > + return EFI_VAR_ASCII; > + > + if (!grub_strncmp (type, "uint8", sizeof("uint8"))) > + return EFI_VAR_UINT8; > + > + if (!grub_strncmp (type, "hex", sizeof("hex"))) > + return EFI_VAR_HEX; > + > + if (!grub_strncmp (type, "dump", sizeof("dump"))) > + return EFI_VAR_DUMP; > + > + return EFI_VAR_INVALID; > +} > +
This should be grub_strcmp everywhere, there is no reason to use grub_strncmp. > + > +GRUB_MOD_INIT (efivar) > +{ > + cmd = grub_register_extcmd ("get_efivar", grub_cmd_get_efi_var, 0, > N_("[-f FORMAT] [-s ENV_VAR] EFI_VAR"), > + N_("Read EFI variable and print it or save its contents to I believe it should be "content" (without final `s') but English is not native. Otherwise OK from my side. Could you also add documentation part for it? _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel