merge mainline into nested
This commit is contained in:
commit
dedb5f9be2
125 changed files with 7481 additions and 1152 deletions
|
@ -37,6 +37,8 @@
|
|||
#define GRUB_COMMAND_FLAG_EXTCMD 0x10
|
||||
/* This is an dynamic command. */
|
||||
#define GRUB_COMMAND_FLAG_DYNCMD 0x20
|
||||
/* This command accepts block arguments. */
|
||||
#define GRUB_COMMAND_FLAG_BLOCKS 0x40
|
||||
|
||||
struct grub_command;
|
||||
|
||||
|
|
|
@ -243,10 +243,12 @@ extern gcry_md_spec_t _gcry_digest_spec_md5;
|
|||
extern gcry_md_spec_t _gcry_digest_spec_sha1;
|
||||
extern gcry_md_spec_t _gcry_digest_spec_sha256;
|
||||
extern gcry_md_spec_t _gcry_digest_spec_sha512;
|
||||
extern gcry_md_spec_t _gcry_digest_spec_crc32;
|
||||
#define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5)
|
||||
#define GRUB_MD_SHA1 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha1)
|
||||
#define GRUB_MD_SHA256 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha256)
|
||||
#define GRUB_MD_SHA512 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha512)
|
||||
#define GRUB_MD_CRC32 ((const gcry_md_spec_t *) &_gcry_digest_spec_crc32)
|
||||
|
||||
/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant
|
||||
of digest supplied by MD. Inputs are the password P of length PLEN,
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef enum
|
|||
GRUB_ERR_BAD_FONT,
|
||||
GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
GRUB_ERR_SYMLINK_LOOP,
|
||||
GRUB_ERR_BAD_GZIP_DATA,
|
||||
GRUB_ERR_BAD_COMPRESSED_DATA,
|
||||
GRUB_ERR_MENU,
|
||||
GRUB_ERR_TIMEOUT,
|
||||
GRUB_ERR_IO,
|
||||
|
|
|
@ -21,10 +21,12 @@
|
|||
|
||||
#include <grub/lib/arg.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/script_sh.h>
|
||||
|
||||
struct grub_extcmd;
|
||||
struct grub_extcmd_context;
|
||||
|
||||
typedef grub_err_t (*grub_extcmd_func_t) (struct grub_extcmd *cmd,
|
||||
typedef grub_err_t (*grub_extcmd_func_t) (struct grub_extcmd_context *ctxt,
|
||||
int argc, char **args);
|
||||
|
||||
/* The argcmd description. */
|
||||
|
@ -38,11 +40,21 @@ struct grub_extcmd
|
|||
const struct grub_arg_option *options;
|
||||
|
||||
void *data;
|
||||
|
||||
struct grub_arg_list *state;
|
||||
};
|
||||
typedef struct grub_extcmd *grub_extcmd_t;
|
||||
|
||||
/* Command context for each instance of execution. */
|
||||
struct grub_extcmd_context
|
||||
{
|
||||
struct grub_extcmd *extcmd;
|
||||
|
||||
struct grub_arg_list *state;
|
||||
|
||||
/* Script parameter, if any. */
|
||||
struct grub_script *script;
|
||||
};
|
||||
typedef struct grub_extcmd_context *grub_extcmd_context_t;
|
||||
|
||||
grub_extcmd_t grub_register_extcmd (const char *name,
|
||||
grub_extcmd_func_t func,
|
||||
unsigned flags,
|
||||
|
@ -50,6 +62,18 @@ grub_extcmd_t grub_register_extcmd (const char *name,
|
|||
const char *description,
|
||||
const struct grub_arg_option *parser);
|
||||
|
||||
grub_extcmd_t grub_register_extcmd_prio (const char *name,
|
||||
grub_extcmd_func_t func,
|
||||
unsigned flags,
|
||||
const char *summary,
|
||||
const char *description,
|
||||
const struct grub_arg_option *parser,
|
||||
int prio);
|
||||
|
||||
void grub_unregister_extcmd (grub_extcmd_t cmd);
|
||||
|
||||
grub_err_t
|
||||
grub_extcmd_dispatcher (struct grub_command *cmd, int argc, char **args,
|
||||
struct grub_script *script);
|
||||
|
||||
#endif /* ! GRUB_EXTCMD_HEADER */
|
||||
|
|
|
@ -39,6 +39,9 @@ struct grub_file
|
|||
/* The file size. */
|
||||
grub_off_t size;
|
||||
|
||||
/* If file is not easly seekable. Should be set by underlying layer. */
|
||||
int not_easly_seekable;
|
||||
|
||||
/* Filesystem-specific data. */
|
||||
void *data;
|
||||
|
||||
|
@ -48,6 +51,51 @@ struct grub_file
|
|||
};
|
||||
typedef struct grub_file *grub_file_t;
|
||||
|
||||
/* Filters with lower ID are executed first. */
|
||||
typedef enum grub_file_filter_id
|
||||
{
|
||||
GRUB_FILE_FILTER_GZIO,
|
||||
GRUB_FILE_FILTER_XZIO,
|
||||
GRUB_FILE_FILTER_MAX,
|
||||
GRUB_FILE_FILTER_COMPRESSION_FIRST = GRUB_FILE_FILTER_GZIO,
|
||||
GRUB_FILE_FILTER_COMPRESSION_LAST = GRUB_FILE_FILTER_XZIO,
|
||||
} grub_file_filter_id_t;
|
||||
|
||||
typedef grub_file_t (*grub_file_filter_t) (grub_file_t in);
|
||||
|
||||
extern grub_file_filter_t EXPORT_VAR(grub_file_filters_all)[GRUB_FILE_FILTER_MAX];
|
||||
extern grub_file_filter_t EXPORT_VAR(grub_file_filters_enabled)[GRUB_FILE_FILTER_MAX];
|
||||
|
||||
static inline void
|
||||
grub_file_filter_register (grub_file_filter_id_t id, grub_file_filter_t filter)
|
||||
{
|
||||
grub_file_filters_all[id] = filter;
|
||||
grub_file_filters_enabled[id] = filter;
|
||||
};
|
||||
|
||||
static inline void
|
||||
grub_file_filter_unregister (grub_file_filter_id_t id)
|
||||
{
|
||||
grub_file_filters_all[id] = 0;
|
||||
grub_file_filters_enabled[id] = 0;
|
||||
};
|
||||
|
||||
static inline void
|
||||
grub_file_filter_disable (grub_file_filter_id_t id)
|
||||
{
|
||||
grub_file_filters_enabled[id] = 0;
|
||||
};
|
||||
|
||||
static inline void
|
||||
grub_file_filter_disable_compression (void)
|
||||
{
|
||||
grub_file_filter_id_t id;
|
||||
|
||||
for (id = GRUB_FILE_FILTER_COMPRESSION_FIRST;
|
||||
id <= GRUB_FILE_FILTER_COMPRESSION_LAST; id++)
|
||||
grub_file_filters_enabled[id] = 0;
|
||||
};
|
||||
|
||||
/* Get a device name from NAME. */
|
||||
char *EXPORT_FUNC(grub_file_get_device_name) (const char *name);
|
||||
|
||||
|
@ -57,6 +105,9 @@ grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf,
|
|||
grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
|
||||
grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
|
||||
|
||||
/* Return value of grub_file_size() in case file size is unknown. */
|
||||
#define GRUB_FILE_SIZE_UNKNOWN 0xffffffffffffffffULL
|
||||
|
||||
static inline grub_off_t
|
||||
grub_file_size (const grub_file_t file)
|
||||
{
|
||||
|
@ -69,4 +120,10 @@ grub_file_tell (const grub_file_t file)
|
|||
return file->offset;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_file_seekable (const grub_file_t file)
|
||||
{
|
||||
return !file->not_easly_seekable;
|
||||
}
|
||||
|
||||
#endif /* ! GRUB_FILE_HEADER */
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/* gzio.h - prototypes for gzio */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007 Free Software Foundation, 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/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_GZIO_H
|
||||
#define GRUB_GZIO_H 1
|
||||
|
||||
#include <grub/file.h>
|
||||
|
||||
grub_file_t grub_gzio_open (grub_file_t io, int transparent);
|
||||
grub_file_t grub_gzfile_open (const char *name, int transparent);
|
||||
|
||||
#endif /* ! GRUB_GZIO_H */
|
|
@ -103,6 +103,9 @@ enum grub_ieee1275_flag
|
|||
|
||||
/* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
|
||||
GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM,
|
||||
|
||||
/* OLPC / XO firmware has the cursor ON/OFF routines. */
|
||||
GRUB_IEEE1275_FLAG_HAS_CURSORONOFF,
|
||||
};
|
||||
|
||||
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);
|
||||
|
|
|
@ -38,6 +38,8 @@ typedef enum grub_arg_type grub_arg_type_t;
|
|||
|
||||
/* Flags for the option field op grub_arg_option. */
|
||||
#define GRUB_ARG_OPTION_OPTIONAL (1 << 1)
|
||||
/* Flags for an option that can appear multiple times. */
|
||||
#define GRUB_ARG_OPTION_REPEATABLE (1 << 2)
|
||||
|
||||
enum grub_key_type
|
||||
{
|
||||
|
@ -59,7 +61,10 @@ struct grub_arg_option
|
|||
struct grub_arg_list
|
||||
{
|
||||
int set;
|
||||
char *arg;
|
||||
union {
|
||||
char *arg;
|
||||
char **args;
|
||||
};
|
||||
};
|
||||
|
||||
struct grub_extcmd;
|
||||
|
@ -68,5 +73,7 @@ int grub_arg_parse (struct grub_extcmd *cmd, int argc, char **argv,
|
|||
struct grub_arg_list *usr, char ***args, int *argnum);
|
||||
|
||||
void grub_arg_show_help (struct grub_extcmd *cmd);
|
||||
struct grub_arg_list* grub_arg_list_alloc (struct grub_extcmd *cmd,
|
||||
int argc, char *argv[]);
|
||||
|
||||
#endif /* ! GRUB_ARG_HEADER */
|
||||
|
|
|
@ -47,6 +47,10 @@ struct grub_menu_entry
|
|||
/* The sourcecode of the menu entry, used by the editor. */
|
||||
const char *sourcecode;
|
||||
|
||||
/* Parameters to be passed to menu definition. */
|
||||
int argc;
|
||||
char **args;
|
||||
|
||||
int hotkey;
|
||||
|
||||
/* The next element. */
|
||||
|
@ -96,4 +100,7 @@ void grub_menu_execute_with_fallback (grub_menu_t menu,
|
|||
void grub_menu_entry_run (grub_menu_entry_t entry);
|
||||
int grub_menu_get_default_entry_index (grub_menu_t menu);
|
||||
|
||||
void grub_menu_init (void);
|
||||
void grub_menu_fini (void);
|
||||
|
||||
#endif /* GRUB_MENU_HEADER */
|
||||
|
|
|
@ -54,8 +54,6 @@ void grub_normal_execute (const char *config, int nested, int batch);
|
|||
void grub_menu_init_page (int nested, int edit,
|
||||
struct grub_term_output *term);
|
||||
void grub_normal_init_page (struct grub_term_output *term);
|
||||
grub_err_t grub_normal_add_menu_entry (int argc, const char **args,
|
||||
const char *sourcecode);
|
||||
char *grub_file_getline (grub_file_t file);
|
||||
void grub_cmdline_run (int nested);
|
||||
|
||||
|
|
|
@ -40,8 +40,13 @@ struct grub_script_cmd
|
|||
|
||||
struct grub_script
|
||||
{
|
||||
unsigned refcnt;
|
||||
struct grub_script_mem *mem;
|
||||
struct grub_script_cmd *cmd;
|
||||
|
||||
/* grub_scripts from block arguments. */
|
||||
struct grub_script *next_siblings;
|
||||
struct grub_script *children;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
|
@ -50,7 +55,8 @@ typedef enum
|
|||
GRUB_SCRIPT_ARG_TYPE_TEXT,
|
||||
GRUB_SCRIPT_ARG_TYPE_DQVAR,
|
||||
GRUB_SCRIPT_ARG_TYPE_DQSTR,
|
||||
GRUB_SCRIPT_ARG_TYPE_SQSTR
|
||||
GRUB_SCRIPT_ARG_TYPE_SQSTR,
|
||||
GRUB_SCRIPT_ARG_TYPE_BLOCK
|
||||
} grub_script_arg_type_t;
|
||||
|
||||
/* A part of an argument. */
|
||||
|
@ -60,6 +66,9 @@ struct grub_script_arg
|
|||
|
||||
char *str;
|
||||
|
||||
/* Parsed block argument. */
|
||||
struct grub_script *script;
|
||||
|
||||
/* Next argument part. */
|
||||
struct grub_script_arg *next;
|
||||
};
|
||||
|
@ -69,8 +78,19 @@ struct grub_script_argv
|
|||
{
|
||||
unsigned argc;
|
||||
char **args;
|
||||
struct grub_script *script;
|
||||
};
|
||||
|
||||
/* Pluggable wildcard translator. */
|
||||
struct grub_script_wildcard_translator
|
||||
{
|
||||
char *(*escape) (const char *str);
|
||||
char *(*unescape) (const char *str);
|
||||
grub_err_t (*expand) (const char *str, char ***expansions);
|
||||
};
|
||||
extern struct grub_script_wildcard_translator *grub_wildcard_translator;
|
||||
extern struct grub_script_wildcard_translator grub_filename_translator;
|
||||
|
||||
/* A complete argument. It consists of a list of one or more `struct
|
||||
grub_script_arg's. */
|
||||
struct grub_script_arglist
|
||||
|
@ -135,21 +155,6 @@ struct grub_script_cmdwhile
|
|||
int until;
|
||||
};
|
||||
|
||||
/* A menu entry generate statement. */
|
||||
struct grub_script_cmd_menuentry
|
||||
{
|
||||
struct grub_script_cmd cmd;
|
||||
|
||||
/* The arguments for this menu entry. */
|
||||
struct grub_script_arglist *arglist;
|
||||
|
||||
/* The sourcecode the entry will be generated from. */
|
||||
const char *sourcecode;
|
||||
|
||||
/* Options. XXX: Not used yet. */
|
||||
int options;
|
||||
};
|
||||
|
||||
/* State of the lexer as passed to the lexer. */
|
||||
struct grub_lexer_param
|
||||
{
|
||||
|
@ -194,6 +199,12 @@ struct grub_lexer_param
|
|||
/* Type of text. */
|
||||
grub_script_arg_type_t type;
|
||||
|
||||
/* Flag to indicate resplit in progres. */
|
||||
unsigned resplit;
|
||||
|
||||
/* Text that is unput. */
|
||||
char *prefix;
|
||||
|
||||
/* Flex scanner. */
|
||||
void *yyscanner;
|
||||
|
||||
|
@ -217,6 +228,9 @@ struct grub_parser_param
|
|||
/* The memory that was used while parsing and scanning. */
|
||||
struct grub_script_mem *memused;
|
||||
|
||||
/* The block argument scripts. */
|
||||
struct grub_script *scripts;
|
||||
|
||||
/* The result of the parser. */
|
||||
struct grub_script_cmd *parsed;
|
||||
|
||||
|
@ -226,7 +240,10 @@ struct grub_parser_param
|
|||
void grub_script_init (void);
|
||||
void grub_script_fini (void);
|
||||
|
||||
void grub_script_mem_free (struct grub_script_mem *mem);
|
||||
|
||||
void grub_script_argv_free (struct grub_script_argv *argv);
|
||||
int grub_script_argv_make (struct grub_script_argv *argv, int argc, char **args);
|
||||
int grub_script_argv_next (struct grub_script_argv *argv);
|
||||
int grub_script_argv_append (struct grub_script_argv *argv, const char *s);
|
||||
int grub_script_argv_split_append (struct grub_script_argv *argv, char *s);
|
||||
|
@ -260,12 +277,6 @@ grub_script_create_cmdwhile (struct grub_parser_param *state,
|
|||
struct grub_script_cmd *list,
|
||||
int is_an_until_loop);
|
||||
|
||||
struct grub_script_cmd *
|
||||
grub_script_create_cmdmenu (struct grub_parser_param *state,
|
||||
struct grub_script_arglist *arglist,
|
||||
char *sourcecode,
|
||||
int options);
|
||||
|
||||
struct grub_script_cmd *
|
||||
grub_script_append_cmd (struct grub_parser_param *state,
|
||||
struct grub_script_cmd *list,
|
||||
|
@ -287,9 +298,9 @@ struct grub_lexer_param *grub_script_lexer_init (struct grub_parser_param *parse
|
|||
void grub_script_lexer_fini (struct grub_lexer_param *);
|
||||
void grub_script_lexer_ref (struct grub_lexer_param *);
|
||||
void grub_script_lexer_deref (struct grub_lexer_param *);
|
||||
void grub_script_lexer_record_start (struct grub_parser_param *);
|
||||
char *grub_script_lexer_record_stop (struct grub_parser_param *);
|
||||
int grub_script_lexer_yywrap (struct grub_parser_param *);
|
||||
unsigned grub_script_lexer_record_start (struct grub_parser_param *);
|
||||
char *grub_script_lexer_record_stop (struct grub_parser_param *, unsigned);
|
||||
int grub_script_lexer_yywrap (struct grub_parser_param *, const char *input);
|
||||
void grub_script_lexer_record (struct grub_parser_param *, char *);
|
||||
|
||||
/* Functions to track allocated memory. */
|
||||
|
@ -310,10 +321,10 @@ grub_err_t grub_script_execute_cmdlist (struct grub_script_cmd *cmd);
|
|||
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
|
||||
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
|
||||
grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
|
||||
grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
|
||||
|
||||
/* Execute any GRUB pre-parsed command or script. */
|
||||
grub_err_t grub_script_execute (struct grub_script *script);
|
||||
grub_err_t grub_script_execute_sourcecode (const char *source, int argc, char **args);
|
||||
|
||||
/* Break command for loops. */
|
||||
grub_err_t grub_script_break (grub_command_t cmd, int argc, char *argv[]);
|
||||
|
@ -321,6 +332,12 @@ grub_err_t grub_script_break (grub_command_t cmd, int argc, char *argv[]);
|
|||
/* SHIFT command for GRUB script. */
|
||||
grub_err_t grub_script_shift (grub_command_t cmd, int argc, char *argv[]);
|
||||
|
||||
/* SETPARAMS command for GRUB script functions. */
|
||||
grub_err_t grub_script_setparams (grub_command_t cmd, int argc, char *argv[]);
|
||||
|
||||
/* RETURN command for functions. */
|
||||
grub_err_t grub_script_return (grub_command_t cmd, int argc, char *argv[]);
|
||||
|
||||
/* This variable points to the parsed command. This is used to
|
||||
communicate with the bison code. */
|
||||
extern struct grub_script_cmd *grub_script_parsed;
|
||||
|
@ -365,4 +382,24 @@ grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *c
|
|||
grub_err_t
|
||||
grub_normal_parse_line (char *line, grub_reader_getline_t getline);
|
||||
|
||||
static inline struct grub_script *
|
||||
grub_script_ref (struct grub_script *script)
|
||||
{
|
||||
if (script)
|
||||
script->refcnt++;
|
||||
return script;
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_script_unref (struct grub_script *script)
|
||||
{
|
||||
if (! script)
|
||||
return;
|
||||
|
||||
if (script->refcnt == 0)
|
||||
grub_script_free (script);
|
||||
else
|
||||
script->refcnt--;
|
||||
}
|
||||
|
||||
#endif /* ! GRUB_NORMAL_PARSER_HEADER */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue