/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
*
* 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/partition.h>
GRUB_MOD_LICENSE ("GPLv3+");
{
{0, 0, 0, 0, 0, 0}
};
static grub_file_t
{
if (! filename)
{
const char *prefix;
if (prefix)
{
int len;
if (! filename)
return 0;
return file;
}
else
{
return 0;
}
}
return grub_file_open (filename);
}
static grub_envblk_t
{
char *buf;
if (! buf)
return 0;
while (size > 0)
{
if (ret <= 0)
{
if (grub_errno == GRUB_ERR_NONE)
return 0;
}
}
if (! envblk)
{
return 0;
}
return envblk;
}
static grub_err_t
{
{
return 0;
}
if (! file)
return grub_errno;
if (! envblk)
goto fail;
fail:
return grub_errno;
}
static grub_err_t
{
/* Print all variables in current context. */
{
return 0;
}
if (! file)
return grub_errno;
if (! envblk)
goto fail;
fail:
return grub_errno;
}
/* Used to maintain a variable length of blocklists internally. */
struct blocklist
{
unsigned offset;
unsigned length;
};
static void
{
struct blocklist *q;
for (; p; p = q)
{
q = p->next;
grub_free (p);
}
}
static grub_err_t
{
struct blocklist *p;
char *buf;
/* Sanity checks. */
total_length = 0;
for (p = blocklists; p; p = p->next)
{
struct blocklist *q;
{
/* Check if any pair of blocks overlap. */
{
/* This might be actually valid, but it is unbelievable that
any filesystem makes such a silly allocation. */
}
}
total_length += p->length;
}
{
/* Maybe sparse, unallocated sectors. No way in GRUB. */
}
/* One more sanity check. Re-read all sectors by blocklists, and compare
those with the data read via a file. */
{
return grub_errno;
}
return GRUB_ERR_NONE;
}
static int
{
char *buf;
struct blocklist *p;
index = 0;
{
return 0;
}
return 1;
}
static grub_err_t
{
/* Store blocklists in a linked list. */
unsigned offset,
unsigned length);
{
/* Seemingly a bug. */
return;
if (! block)
return;
/* Slightly complicated, because the list should be FIFO. */
if (tail)
if (! head)
}
if (! argc)
if (! file)
return grub_errno;
{
}
if (! envblk)
goto fail;
goto fail;
while (argc)
{
const char *value;
if (value)
{
{
goto fail;
}
}
argc--;
args++;
}
fail:
if (envblk)
return grub_errno;
}
{
cmd_load =
N_("Load variables from environment block file."),
options);
cmd_list =
N_("List variables from environment block file."),
options);
cmd_save =
N_("[-f FILE] variable_name [...]"),
N_("Save variables to environment block file."),
options);
}
{
}