2009-03-29 Yoshinori K. Okuji <okuji@enbug.org>
Make the format of Environment Block plain text. The boot loader part is not tested well yet. * util/grub-editenv.c (DEFAULT_ENVBLK_SIZE): New macro. (buffer): Removed. (envblk): Likewise. (usage): Remove "info" and "clear". Add "unset". Update the description of "set", as this does not delete variables any longer. (create_envblk_file): Complete rewrite. (open_envblk_file): Likewise. (cmd_info): Removed. (cmd_list): Likewise. (cmd_set): Likewise. (cmd_clear): Likewise. (list_variables): New function. (write_envblk): Likewise. (set_variables): Likewise. (unset_variables): Likewise. (main): Complete rewrite. * commands/loadenv.c (buffer): Removed. (envblk): Likewise. (open_envblk_file): New function. (read_envblk_file): Complete rewrite. (grub_cmd_load_env): Likewise. (grub_cmd_list_env): Likewise. (struct blocklist): New struct. (free_blocklists): New function. (check_blocklists): Likewise. (write_blocklists): Likewise. (grub_cmd_save_env): Complete rewrite. * include/grub/lib/envblk.h (GRUB_ENVBLK_SIGNATURE): Replaced with a plain text signature. (GRUB_ENVBLK_MAXLEN): Removed. (struct grub_envblk): Complete rewrite. (grub_envblk_find): Removed. (grub_envblk_insert): Likewise. (grub_envblk_open): New prototype. (grub_envblk_set): Likewise. (grub_envblk_delete): Put const to VALUE. (grub_envblk_iterate): Put const to NAME and VALUE. (grub_envblk_close): New prototype. (grub_envblk_buffer): New inline function. (grub_envblk_size): Likewise. * lib/envblk.c: Include grub/mm.h. (grub_env_find): Removed. (grub_envblk_open): New function. (grub_envblk_close): Likewise. (escaped_value_len): Likewise. (find_next_line): Likewise. (grub_envblk_insert): Removed. (grub_envblk_set): New function. (grub_envblk_delete): Complete rewrite. (grub_envblk_iterate): Likewise.
This commit is contained in:
parent
a9368fd30c
commit
5709cfc4d1
7 changed files with 3685 additions and 2644 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2008,2009 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
|
||||
|
@ -19,27 +19,37 @@
|
|||
#ifndef GRUB_ENVBLK_HEADER
|
||||
#define GRUB_ENVBLK_HEADER 1
|
||||
|
||||
#define GRUB_ENVBLK_SIGNATURE 0x764e6547 /* GeNv */
|
||||
|
||||
#define GRUB_ENVBLK_MAXLEN 8192
|
||||
|
||||
#define GRUB_ENVBLK_SIGNATURE "# GRUB Environment Block\n"
|
||||
#define GRUB_ENVBLK_DEFCFG "grubenv"
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
struct grub_envblk
|
||||
{
|
||||
grub_uint32_t signature;
|
||||
grub_uint16_t length;
|
||||
char data[0];
|
||||
} __attribute__ ((packed));
|
||||
char *buf;
|
||||
grub_size_t size;
|
||||
};
|
||||
typedef struct grub_envblk *grub_envblk_t;
|
||||
|
||||
grub_envblk_t grub_envblk_find (char *buf);
|
||||
int grub_envblk_insert (grub_envblk_t envblk, char *name, char *value);
|
||||
void grub_envblk_delete (grub_envblk_t envblk, char *name);
|
||||
void grub_envblk_iterate (grub_envblk_t envblk, int hook (char *name, char *value));
|
||||
grub_envblk_t grub_envblk_open (char *buf, grub_size_t size);
|
||||
int grub_envblk_set (grub_envblk_t envblk, const char *name, const char *value);
|
||||
void grub_envblk_delete (grub_envblk_t envblk, const char *name);
|
||||
void grub_envblk_iterate (grub_envblk_t envblk,
|
||||
int hook (const char *name, const char *value));
|
||||
void grub_envblk_close (grub_envblk_t envblk);
|
||||
|
||||
#endif
|
||||
static inline char *
|
||||
grub_envblk_buffer (const grub_envblk_t envblk)
|
||||
{
|
||||
return envblk->buf;
|
||||
}
|
||||
|
||||
static inline grub_size_t
|
||||
grub_envblk_size (const grub_envblk_t envblk)
|
||||
{
|
||||
return envblk->size;
|
||||
}
|
||||
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
#endif /* ! GRUB_ENVBLK_HEADER */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue